Class: Guard::I18next
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :output => Pathname.pwd.join('app', 'assets', 'javascripts', 'i18n'), }
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ I18next
constructor
Initialize Guard::i18next.
-
#run_on_change(paths) ⇒ Object
Gets called when watched paths and files have changes.
Constructor Details
#initialize(watchers = [], options = {}) ⇒ I18next
Initialize Guard::i18next
19 20 21 22 23 24 |
# File 'lib/guard/i18next.rb', line 19 def initialize(watchers = [], = {}) watchers = [] if !watchers defaults = DEFAULT_OPTIONS.clone super(watchers, defaults.merge()) end |
Instance Method Details
#run_on_change(paths) ⇒ Object
Gets called when watched paths and files have changes.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/guard/i18next.rb', line 31 def run_on_change(paths) Dir::mkdir([:output]) unless File.directory?([:output]) paths.each do |locale_path| filename = File.basename(locale_path, ".yml") input = File.new(locale_path, 'r') locale = YAML.load(input.read) input.close File.open([:output] + "/#{filename}.json", "w") do |f| f.puts locale.to_json end end end |