Sha256: 80591949dbb9547aa16146953383b4d31714eb582727b4773e2f07d7d5dae941

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module Tay
  module CLI
    class Generate < ::Thor
      desc "browser_action", "Generate a browser action"
      method_option 'action-name', :type => :string, :default => 'Browser Action',
        :aliases => '-n', :banner => 'The name of the browser action'
      def browser_action
        raise Tay::InvalidSpecification.new("Browser action already specified") if spec.browser_action
        raise Tay::InvalidSpecification.new("You cannot have both browser and page actions") if spec.browser_action
        raise Tay::InvalidSpecification.new("You cannot have both browser actions and packaged apps") if spec.packaged_app

        fs_name = Utils.filesystem_name(options['action-name'])
        copy_file('browser_action/action.js', javascript_dir.join(fs_name+ '.js'))
        copy_file('browser_action/action.css', stylesheet_dir.join(fs_name+ '.css'))

        create_file(html_dir.join(fs_name + '.html'), render_template('browser_action/action.html', :fs_name => fs_name))

        inject_tayfile_content(render_template('browser_action/tayfile', :fs_name => fs_name))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tay-0.1.0 lib/tay/cli/generators/browser_action.rb
tay-0.0.5 lib/tay/cli/generators/browser_action.rb
tay-0.0.4 lib/tay/cli/generators/browser_action.rb