Class: SolidusDevSupport::RakeTasks
- Inherits:
-
Object
- Object
- SolidusDevSupport::RakeTasks
- Includes:
- Rake::DSL
- Defined in:
- lib/solidus_dev_support/rake_tasks.rb
Instance Attribute Summary collapse
-
#gemspec ⇒ Object
readonly
Returns the value of attribute gemspec.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#test_app_path ⇒ Object
readonly
Returns the value of attribute test_app_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(root: Dir.pwd, user_class: "Spree::LegacyUser") ⇒ RakeTasks
constructor
A new instance of RakeTasks.
- #install ⇒ Object
- #install_changelog_task ⇒ Object
- #install_dev_app_task ⇒ Object
- #install_rspec_task ⇒ Object
- #install_test_app_task ⇒ Object
Constructor Details
#initialize(root: Dir.pwd, user_class: "Spree::LegacyUser") ⇒ RakeTasks
Returns a new instance of RakeTasks.
14 15 16 17 18 19 |
# File 'lib/solidus_dev_support/rake_tasks.rb', line 14 def initialize(root: Dir.pwd, user_class: "Spree::LegacyUser") @root = Pathname(root) @test_app_path = @root.join(ENV.fetch('DUMMY_PATH', 'spec/dummy')) @gemspec = Bundler.load_gemspec(@root.glob("{,*}.gemspec").first) @user_class = user_class end |
Instance Attribute Details
#gemspec ⇒ Object (readonly)
Returns the value of attribute gemspec.
21 22 23 |
# File 'lib/solidus_dev_support/rake_tasks.rb', line 21 def gemspec @gemspec end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
21 22 23 |
# File 'lib/solidus_dev_support/rake_tasks.rb', line 21 def root @root end |
#test_app_path ⇒ Object (readonly)
Returns the value of attribute test_app_path.
21 22 23 |
# File 'lib/solidus_dev_support/rake_tasks.rb', line 21 def test_app_path @test_app_path end |
Class Method Details
.install(**args) ⇒ Object
10 11 12 |
# File 'lib/solidus_dev_support/rake_tasks.rb', line 10 def self.install(**args) new(**args).tap(&:install) end |
Instance Method Details
#install ⇒ Object
23 24 25 26 27 28 |
# File 'lib/solidus_dev_support/rake_tasks.rb', line 23 def install install_test_app_task install_dev_app_task install_rspec_task install_changelog_task end |
#install_changelog_task ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/solidus_dev_support/rake_tasks.rb', line 77 def install_changelog_task require 'github_changelog_generator/task' GitHubChangelogGenerator::RakeTask.new(:changelog) do |config| require 'octokit' repo = Octokit::Repository.from_url(gemspec.['source_code_uri'] || gemspec.homepage) config.user = repo.owner config.project = repo.name config.future_release = "v#{ENV.fetch('UNRELEASED_VERSION') { gemspec.version }}" rescue Octokit::InvalidRepository warn <<~WARN It won't be possible to automatically generate the CHANGELOG for this extension because the gemspec is missing the `source_code_uri` metadata. Please add this line to the gemspec to enable automatic CHANGELOG generation: s.metadata["source_code_uri"] = 'https://github.com/org/repo' WARN end end |
#install_dev_app_task ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/solidus_dev_support/rake_tasks.rb', line 53 def install_dev_app_task desc "Creates a sandbox application for simulating the Extension code in a deployed Rails app" task :sandbox do warn "DEPRECATED TASK: This task is here just for parity with solidus, please use bin/sandbox directly." exec("bin/sandbox", gemspec.name) end end |
#install_rspec_task ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/solidus_dev_support/rake_tasks.rb', line 61 def install_rspec_task require 'rspec/core/rake_task' namespace :extension do ::RSpec::Core::RakeTask.new(:specs, [] => FileList[ENV.fetch('DUMMY_PATH', nil)]) do |t| # Ref: https://circleci.com/docs/2.0/configuration-reference#store_test_results # Ref: https://github.com/solidusio/circleci-orbs-extensions#test-results-rspec if ENV['TEST_RESULTS_PATH'] t.rspec_opts = "--format progress " \ "--format RspecJunitFormatter --out #{ENV['TEST_RESULTS_PATH']}" end end end end |
#install_test_app_task ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/solidus_dev_support/rake_tasks.rb', line 30 def install_test_app_task require 'rake/clean' require 'spree/testing_support/extension_rake' ENV['DUMMY_PATH'] = test_app_path.to_s ENV['LIB_NAME'] = gemspec.name ::CLOBBER.include test_app_path namespace :extension do # We need to go back to the gem root since the upstream # extension:test_app changes the working directory to be the dummy app. task :test_app do Rake::Task['extension:test_app'].invoke(@user_class) cd root end directory ENV.fetch('DUMMY_PATH', nil) do Rake::Task['extension:test_app'].invoke(@user_class) end end end |