Sha256: 4ccfa07934ff993798368e4e1301c8bae10d3cab4694d0210fe101e6960ead44
Contents?: true
Size: 900 Bytes
Versions: 37
Compression:
Stored size: 900 Bytes
Contents
require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb") class WebtranslateitGenerator < Rails::Generator::Base def add_options!(opt) opt.on('-k', '--api-key=key', String, "Your Web Translate It API key") {|v| options[:api_key] = v} end def manifest if !api_key_configured? && !options[:api_key] puts "You must pass --api-key or create config/translations.yml" exit end record do |m| if options[:api_key] project_details = YAML.load WebTranslateIt::Project.fetch_info(options[:api_key]) m.template 'translation.yml', 'config/translation.yml', :assigns => { :api_key => options[:api_key], :project => project_details["project"] } m.append_to 'Rakefile', "require 'web_translate_it' rescue LoadError" end end end def api_key_configured? File.exists?('config/translations.yml') end end
Version data entries
37 entries across 37 versions & 1 rubygems