Skip to content

Commit

Permalink
Move local gem installation back to tasks
Browse files Browse the repository at this point in the history
These can be useful to try out unreleased generator changes.
  • Loading branch information
deivid-rodriguez committed Jun 27, 2018
1 parent be5b8c1 commit 577111d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 21 deletions.
10 changes: 10 additions & 0 deletions Rakefile
Expand Up @@ -46,6 +46,16 @@ task :test_component do
Decidim::GemManager.test_component
end

desc "Installs all local gem versions globally"
task :install_all do
Decidim::GemManager.install_all
end

desc "Uninstalls all local gem versions"
task :uninstall_all do
Decidim::GemManager.uninstall_all
end

desc "Pushes a new build for each gem."
task release_all: [:update_versions, :check_locale_completeness, :webpack] do
Decidim::GemManager.run_all("rake release")
Expand Down
22 changes: 2 additions & 20 deletions decidim-generators/spec/generators_spec.rb
Expand Up @@ -31,29 +31,11 @@ module Decidim

# rubocop:disable RSpec/BeforeAfterAll
before(:all) do
Decidim::GemManager.run_all(
"gem build %name && mv %name-%version.gem ..",
include_root: false,
out: File::NULL
)

Decidim::GemManager.new(repo_root).run(
"gem build %name && gem install *.gem",
out: File::NULL
)
Decidim::GemManager.install_all(out: File::NULL)
end

after(:all) do
Decidim::GemManager.run_all(
"gem uninstall %name -v %version --executables --force",
include_root: false,
out: File::NULL
)

Decidim::GemManager.new(repo_root).run(
"gem uninstall %name -v %version --executables --force && rm decidim-*.gem",
out: File::NULL
)
Decidim::GemManager.uninstall_all(out: File::NULL)
end
# rubocop:enable RSpec/BeforeAfterAll

Expand Down
31 changes: 30 additions & 1 deletion lib/decidim/gem_manager.rb
Expand Up @@ -95,6 +95,31 @@ def replace_versions
end
end

def install_all(out: STDOUT)
run_all(
"gem build %name && mv %name-%version.gem ..",
include_root: false,
out: out
)

new(root).run(
"gem build %name && gem install *.gem",
out: out
)
end

def uninstall_all(out: STDOUT)
run_all(
"gem uninstall %name -v %version --executables --force",
out: out
)

new(root).run(
"rm decidim-*.gem",
out: out
)
end

def run_all(command, out: STDOUT, include_root: true)
all_dirs(include_root: include_root) do |dir|
status = new(dir).run(command, out: out)
Expand Down Expand Up @@ -135,7 +160,11 @@ def semver_friendly_version
end

def version_file
File.expand_path(File.join("..", "..", ".decidim-version"), __dir__)
File.join(root, ".decidim-version")
end

def root
File.expand_path(File.join("..", ".."), __dir__)
end
end

Expand Down

0 comments on commit 577111d

Please sign in to comment.