From ccd188bc2f5c6aa6c5df59efae7563e27e3bdfc2 Mon Sep 17 00:00:00 2001 From: nishiki Date: Sun, 21 Jun 2015 23:45:25 +0200 Subject: [PATCH] add install with gem --- CHANGELOG | 6 ++++++ Makefile | 23 ----------------------- VERSION | 2 +- mpw => bin/mpw | 9 ++++----- mpw-server => bin/mpw-server | 4 ++-- mpw-ssh => bin/mpw-ssh | 13 ++++++------- lib/{Config.rb => mpw/config.rb} | 0 lib/{Item.rb => mpw/item.rb} | 0 lib/{MPW.rb => mpw/mpw.rb} | 3 +-- lib/{Server.rb => mpw/server.rb} | 0 lib/{Sync.rb => mpw/sync.rb} | 11 +++++------ lib/{Sync/FTP.rb => mpw/sync/ftp.rb} | 0 lib/{Sync/SyncMPW.rb => mpw/sync/mpw.rb} | 0 lib/{Sync/SSH.rb => mpw/sync/ssh.rb} | 0 lib/{UI/Cli.rb => mpw/ui/cli.rb} | 7 +++---- lib/{UI/CliSSH.rb => mpw/ui/clissh.rb} | 2 +- mpw.gemspec | 19 +++++++++++++++++++ 17 files changed, 48 insertions(+), 51 deletions(-) delete mode 100644 Makefile rename mpw => bin/mpw (96%) rename mpw-server => bin/mpw-server (95%) rename mpw-ssh => bin/mpw-ssh (94%) rename lib/{Config.rb => mpw/config.rb} (100%) rename lib/{Item.rb => mpw/item.rb} (100%) rename lib/{MPW.rb => mpw/mpw.rb} (99%) rename lib/{Server.rb => mpw/server.rb} (100%) rename lib/{Sync.rb => mpw/sync.rb} (95%) rename lib/{Sync/FTP.rb => mpw/sync/ftp.rb} (100%) rename lib/{Sync/SyncMPW.rb => mpw/sync/mpw.rb} (100%) rename lib/{Sync/SSH.rb => mpw/sync/ssh.rb} (100%) rename lib/{UI/Cli.rb => mpw/ui/cli.rb} (99%) rename lib/{UI/CliSSH.rb => mpw/ui/clissh.rb} (96%) create mode 100644 mpw.gemspec diff --git a/CHANGELOG b/CHANGELOG index 21cf7ae..1ce4809 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,10 @@ = CHANGELOG = +== v2.0.0 == + +* change format csv to yaml +* easy install with gem +* add sync with ftp and ssh +* many improvement == v1.1.0 == diff --git a/Makefile b/Makefile deleted file mode 100644 index cb1fa7a..0000000 --- a/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -all: - $(info 'Nothing todo!') - $(info 'Use make install or make uninstall') - -dep-ubuntu: - apt-get install ruby ruby-gpgme ruby-highline ruby-i18n ruby-locale - -install: - mkdir -p /usr/local/mpw - cp -r ./lib /usr/local/mpw/ - cp -r ./i18n /usr/local/mpw/ - cp ./mpw /usr/local/mpw/ - ln -snf /usr/local/mpw/mpw /usr/local/bin/ - cp ./mpw-server /usr/local/mpw/ - ln -snf /usr/local/mpw/mpw-server /usr/local/bin/mpw-server - cp ./mpw-ssh /usr/local/mpw/ - ln -snf /usr/local/mpw/mpw-ssh /usr/local/bin/mpw-ssh - -uninstall: - rm /usr/local/bin/mpw-server - rm /usr/local/bin/mpw - rm /usr/local/bin/mpw-ssh - rm -rf /usr/local/mpw diff --git a/VERSION b/VERSION index 5d32997..227cea2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0 - dev +2.0.0 diff --git a/mpw b/bin/mpw similarity index 96% rename from mpw rename to bin/mpw index bda314c..d8a76c7 100755 --- a/mpw +++ b/bin/mpw @@ -9,10 +9,9 @@ require 'pathname' require 'locale' require 'set' require 'i18n' - -require_relative 'lib/UI/Cli' -require_relative 'lib/Config' -require_relative 'lib/MPW' +require 'mpw/mpw' +require 'mpw/config' +require 'mpw/ui/cli' # --------------------------------------------------------- # # Set local @@ -27,7 +26,7 @@ end APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath) I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) -I18n.load_path = Dir["#{APP_ROOT}/i18n/cli/*.yml"] +I18n.load_path = Dir["#{APP_ROOT}/../i18n/cli/*.yml"] I18n.default_locale = :en I18n.locale = lang.to_sym diff --git a/mpw-server b/bin/mpw-server similarity index 95% rename from mpw-server rename to bin/mpw-server index 30f6105..3a7ce5a 100755 --- a/mpw-server +++ b/bin/mpw-server @@ -8,9 +8,9 @@ require 'optparse' require 'pathname' require 'locale' require 'i18n' +require 'mpw/server' APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath) -require "#{APP_ROOT}/lib/Server.rb" # --------------------------------------------------------- # # Set local @@ -23,7 +23,7 @@ if defined?(I18n.enforce_available_locales) end I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) -I18n.load_path = Dir["#{APP_ROOT}/i18n/server/*.yml"] +I18n.load_path = Dir["#{APP_ROOT}/../i18n/server/*.yml"] I18n.default_locale = :en I18n.locale = lang.to_sym diff --git a/mpw-ssh b/bin/mpw-ssh similarity index 94% rename from mpw-ssh rename to bin/mpw-ssh index 89a8c99..b5f1252 100755 --- a/mpw-ssh +++ b/bin/mpw-ssh @@ -8,23 +8,22 @@ require 'optparse' require 'pathname' require 'locale' require 'i18n' - -APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath) -require "#{APP_ROOT}/lib/UI/CliSSH" -require "#{APP_ROOT}/lib/Config" - -lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1] +require 'mpw/ui/clissh' +require 'mpw/config' # --------------------------------------------------------- # # Set local # --------------------------------------------------------- # +APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath) +lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1] + if defined?(I18n.enforce_available_locales) I18n.enforce_available_locales = true end I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) -I18n.load_path = Dir["#{APP_ROOT}/i18n/cli/*.yml"] +I18n.load_path = Dir["#{APP_ROOT}/../i18n/cli/*.yml"] I18n.default_locale = :en I18n.locale = lang.to_sym diff --git a/lib/Config.rb b/lib/mpw/config.rb similarity index 100% rename from lib/Config.rb rename to lib/mpw/config.rb diff --git a/lib/Item.rb b/lib/mpw/item.rb similarity index 100% rename from lib/Item.rb rename to lib/mpw/item.rb diff --git a/lib/MPW.rb b/lib/mpw/mpw.rb similarity index 99% rename from lib/MPW.rb rename to lib/mpw/mpw.rb index 0677af9..57a6bce 100644 --- a/lib/MPW.rb +++ b/lib/mpw/mpw.rb @@ -8,8 +8,7 @@ require 'csv' require 'i18n' require 'fileutils' require 'yaml' - -require_relative './Item' +require 'mpw/item' module MPW class MPW diff --git a/lib/Server.rb b/lib/mpw/server.rb similarity index 100% rename from lib/Server.rb rename to lib/mpw/server.rb diff --git a/lib/Sync.rb b/lib/mpw/sync.rb similarity index 95% rename from lib/Sync.rb rename to lib/mpw/sync.rb index 22a289e..3e18d32 100644 --- a/lib/Sync.rb +++ b/lib/mpw/sync.rb @@ -7,9 +7,8 @@ require 'rubygems' require 'i18n' require 'yaml' require 'tempfile' - -require_relative './MPW' -require_relative './Item' +require 'mpw/mpw' +require 'mpw/item' module MPW class Sync @@ -32,13 +31,13 @@ module MPW def get_remote case @config.sync_type when 'mpw' - require "#{APP_ROOT}/lib/Sync/SyncMPW" + require 'mpw/sync/mpw' @sync = SyncMPW.new(@config.sync_host, @config.sync_user, @config.sync_pwd, @config.sync_path, @config.sync_port) when 'sftp', 'scp', 'ssh' - require "#{APP_ROOT}/lib/Sync/SSH" + require 'mpw/sync/ssh' @sync = SyncSSH.new(@config.sync_host, @config.sync_user, @config.sync_pwd, @config.sync_path, @config.sync_port) when 'ftp' - require "#{APP_ROOT}/lib/Sync/FTP" + require 'mpw/sync/ftp' @sync = SyncFTP.new(@config.sync_host, @config.sync_user, @config.sync_pwd, @config.sync_path, @config.sync_port) else @error_msg = I18n.t('error.unknown_type') diff --git a/lib/Sync/FTP.rb b/lib/mpw/sync/ftp.rb similarity index 100% rename from lib/Sync/FTP.rb rename to lib/mpw/sync/ftp.rb diff --git a/lib/Sync/SyncMPW.rb b/lib/mpw/sync/mpw.rb similarity index 100% rename from lib/Sync/SyncMPW.rb rename to lib/mpw/sync/mpw.rb diff --git a/lib/Sync/SSH.rb b/lib/mpw/sync/ssh.rb similarity index 100% rename from lib/Sync/SSH.rb rename to lib/mpw/sync/ssh.rb diff --git a/lib/UI/Cli.rb b/lib/mpw/ui/cli.rb similarity index 99% rename from lib/UI/Cli.rb rename to lib/mpw/ui/cli.rb index 9352ed9..3875be5 100644 --- a/lib/UI/Cli.rb +++ b/lib/mpw/ui/cli.rb @@ -9,10 +9,9 @@ require 'pathname' require 'readline' require 'i18n' require 'colorize' - -require_relative '../Sync' -require_relative '../MPW' -require_relative '../Item' +require 'mpw/sync' +require 'mpw/mpw' +require 'mpw/item' class Cli diff --git a/lib/UI/CliSSH.rb b/lib/mpw/ui/clissh.rb similarity index 96% rename from lib/UI/CliSSH.rb rename to lib/mpw/ui/clissh.rb index b32097e..83d1d3b 100644 --- a/lib/UI/CliSSH.rb +++ b/lib/mpw/ui/clissh.rb @@ -3,7 +3,7 @@ # mail: nishiki@yaegashi.fr # info: a simple script who manage your passwords -require "#{APP_ROOT}/lib/UI/Cli" +require 'mpw/ui/cli' class CliSSH < Cli diff --git a/mpw.gemspec b/mpw.gemspec new file mode 100644 index 0000000..b930a24 --- /dev/null +++ b/mpw.gemspec @@ -0,0 +1,19 @@ +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) + +Gem::Specification.new do |spec| + spec.name = 'mpw' + spec.version = File.open('VERSION').read + spec.authors = ['nishiki'] + spec.email = ['gems@yae.im'] + spec.summary = 'Manage your password' + spec.description = 'Save and read your password with gpg' + spec.homepage = 'https://github.com/nishiki/checkupdate' + spec.license = 'GPL' + + spec.files = `git ls-files -z`.split("\x0") + spec.executables = ['mpw', 'mpw-server'] + spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.require_paths = ['lib'] +end