Sha256: a54535dd9a827836f31e554ba94a61562fd3bfd95a9945a0282e997a4395c41b

Contents?: true

Size: 1.8 KB

Versions: 70

Compression:

Stored size: 1.8 KB

Contents

module SpreeCmd
  class Extension < Thor::Group
    include Thor::Actions

    desc 'builds a spree extension'
    argument :file_name, type: :string, desc: 'rails app_path', default: 'sample_extension'

    source_root File.expand_path('templates/extension', __dir__)

    def generate
      use_prefix 'spree_'

      empty_directory file_name

      directory 'app',      "#{file_name}/app"
      directory 'lib',      "#{file_name}/lib"
      directory 'bin',      "#{file_name}/bin"
      directory 'spec',     "#{file_name}/spec"
      directory 'gemfiles', "#{file_name}/gemfiles"

      chmod "#{file_name}/bin/rails", 0o755

      template 'extension.gemspec', "#{file_name}/#{file_name}.gemspec"
      template 'Gemfile', "#{file_name}/Gemfile"
      template 'gitignore', "#{file_name}/.gitignore"
      template 'LICENSE', "#{file_name}/LICENSE"
      template 'Rakefile', "#{file_name}/Rakefile"
      template 'README.md', "#{file_name}/README.md"
      template 'config/routes.rb', "#{file_name}/config/routes.rb"
      template 'config/locales/en.yml', "#{file_name}/config/locales/en.yml"
      template 'rspec', "#{file_name}/.rspec"
      template 'travis.yml', "#{file_name}/.travis.yml"
      template 'Appraisals', "#{file_name}/Appraisals"
      template '.rubocop.yml', "#{file_name}/.rubocop.yml"
    end

    def final_banner
      say %{
        #{'*' * 80}

        Your extension has been generated with a gemspec dependency on Spree #{spree_version}.

        #{'*' * 80}
      }
    end

    no_tasks do
      def class_name
        Thor::Util.camel_case file_name
      end

      def spree_version
        Gem.loaded_specs['spree_cmd'].version.to_s
      end

      def use_prefix(prefix)
        @file_name = prefix + Thor::Util.snake_case(file_name) unless file_name =~ /^#{prefix}/
      end
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
spree_cmd-4.0.9 lib/spree_cmd/extension.rb
spree_cmd-4.1.15 lib/spree_cmd/extension.rb
spree_cmd-4.2.7 lib/spree_cmd/extension.rb
spree_cmd-4.2.6 lib/spree_cmd/extension.rb
spree_cmd-4.3.0.rc1 lib/spree_cmd/extension.rb
spree_cmd-4.2.5 lib/spree_cmd/extension.rb
spree_cmd-4.1.14 lib/spree_cmd/extension.rb
spree_cmd-4.0.8 lib/spree_cmd/extension.rb
spree_cmd-4.2.4 lib/spree_cmd/extension.rb
spree_cmd-3.7.14.1 lib/spree_cmd/extension.rb
spree_cmd-4.2.3.1 lib/spree_cmd/extension.rb
spree_cmd-4.1.13.1 lib/spree_cmd/extension.rb
spree_cmd-4.0.7.1 lib/spree_cmd/extension.rb
spree_cmd-4.2.3 lib/spree_cmd/extension.rb
spree_cmd-4.2.2 lib/spree_cmd/extension.rb
spree_cmd-4.2.1 lib/spree_cmd/extension.rb
spree_cmd-4.0.7 lib/spree_cmd/extension.rb
spree_cmd-3.7.14 lib/spree_cmd/extension.rb
spree_cmd-4.2.0 lib/spree_cmd/extension.rb
spree_cmd-4.2.0.rc5 lib/spree_cmd/extension.rb