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

Version Path
web_translate_it-1.8.1.9 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.8.1.8 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.8.1.7 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.8.1.6 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.8.1.5 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.8.1.4 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.8.1.3 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.8.1.2 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.8.1.1 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.8.1.0 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.8.0.1 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.8.0.0 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.7.3.1 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.7.3.0 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.7.2.1 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.7.2.0 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.7.1.7 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.7.1.6 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.7.1.5 generators/webtranslateit/webtranslateit_generator.rb
web_translate_it-1.7.1.3 generators/webtranslateit/webtranslateit_generator.rb