Sha256: 1234b0810ba0ae58b2a4b23234eaf668c315a8d399562c7e1695f73e1981dab8
Contents?: true
Size: 925 Bytes
Versions: 5
Compression:
Stored size: 925 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 # rubocop:todo Metrics/AbcSize, Metrics/MethodLength 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 '.wti', '.wti', 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.exist?('config/translations.yml') end end
Version data entries
5 entries across 5 versions & 1 rubygems