From 4569ad4d1c3451da23f8d19e1e155f2406e5977b Mon Sep 17 00:00:00 2001 From: nishiki Date: Sun, 8 Feb 2015 22:54:04 +0100 Subject: [PATCH] add require_relative --- lib/Config.rb | 13 +++++-------- lib/MPW.rb | 3 ++- lib/Sync.rb | 5 +++-- lib/UI/Cli.rb | 5 +++-- mpw | 9 +++++---- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/Config.rb b/lib/Config.rb index 92abad8..7663809 100644 --- a/lib/Config.rb +++ b/lib/Config.rb @@ -1,15 +1,13 @@ #!/usr/bin/ruby # author: nishiki # mail: nishiki@yaegashi.fr -# info: a simple script who manage your passwords -module MPW - - require 'rubygems' - require 'gpgme' - require 'yaml' - require 'i18n' +require 'rubygems' +require 'gpgme' +require 'yaml' +require 'i18n' +module MPW class Config attr_accessor :error_msg @@ -231,5 +229,4 @@ module MPW end end - end diff --git a/lib/MPW.rb b/lib/MPW.rb index 6817755..a29cff0 100644 --- a/lib/MPW.rb +++ b/lib/MPW.rb @@ -8,7 +8,8 @@ require 'csv' require 'i18n' require 'fileutils' require 'yaml' -require "#{APP_ROOT}/lib/Item" + +require_relative './Item' module MPW class MPW diff --git a/lib/Sync.rb b/lib/Sync.rb index 3f18f26..18dbad9 100644 --- a/lib/Sync.rb +++ b/lib/Sync.rb @@ -7,8 +7,9 @@ require 'rubygems' require 'i18n' require 'yaml' require 'tempfile' -require "#{APP_ROOT}/lib/Item" -require "#{APP_ROOT}/lib/MPW" + +require_relative './MPW' +require_relative './Item' module MPW class Sync diff --git a/lib/UI/Cli.rb b/lib/UI/Cli.rb index 98bcf70..eba7273 100644 --- a/lib/UI/Cli.rb +++ b/lib/UI/Cli.rb @@ -10,8 +10,9 @@ require 'readline' require 'i18n' require 'colorize' -require "#{APP_ROOT}/lib/MPW" -require "#{APP_ROOT}/lib/Sync" +require_relative '../Sync' +require_relative '../MPW' +require_relative '../Item' class Cli diff --git a/mpw b/mpw index 6689ade..bc63313 100755 --- a/mpw +++ b/mpw @@ -10,10 +10,9 @@ require 'locale' require 'set' require 'i18n' -APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath) -require "#{APP_ROOT}/lib/UI/Cli" -require "#{APP_ROOT}/lib/Config" -require "#{APP_ROOT}/lib/MPW" +require_relative 'lib/UI/Cli' +require_relative 'lib/Config' +require_relative 'lib/MPW' # --------------------------------------------------------- # # Set local @@ -25,6 +24,8 @@ if defined?(I18n.enforce_available_locales) I18n.enforce_available_locales = true 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.default_locale = :en