engine_cart 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/Rakefile +3 -0
- data/lib/engine_cart/tasks/engine_cart.rake +12 -5
- data/lib/engine_cart/version.rb +1 -1
- data/lib/generators/engine_cart/install_generator.rb +8 -6
- data/spec/integration/engine_cart_spec.rb +7 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 813b3a634c45dead4343d6bcea735499e70e930d
|
4
|
+
data.tar.gz: a3f6f5a013a9e978c8807c2aca3578fe5d5c38a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8db75de72d6e85d16e0617105d561e87c9f3615c6d2c43d4b2a6eda11948d9f20d11af40398c750c8683cb5598c1dc87d91072722bd45fea0b850403f0e0ca7
|
7
|
+
data.tar.gz: d588131b98de57585e760109c3c339c9859e11e624e52f1c070c6e3110356cee19596a5f82a5f42360867429f5eccef532a6bfa0f5195f77c88dd76a1bff6028
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/cbeer/engine_cart.svg?branch=master)](https://travis-ci.org/cbeer/engine_cart) [![Gem Version](https://badge.fury.io/rb/engine_cart.svg)](http://badge.fury.io/rb/engine_cart)
|
2
|
+
|
1
3
|
# EngineCart
|
2
4
|
|
3
5
|
Rake tasks to generate a test application for a Rails Engine gem.
|
data/Rakefile
CHANGED
@@ -11,6 +11,9 @@ end
|
|
11
11
|
task :generate_test_gem => ['engine_cart:setup'] do
|
12
12
|
system("rm -rf spec/internal")
|
13
13
|
system("rails plugin new spec/internal_gem")
|
14
|
+
IO.write("spec/internal_gem/internal_gem.gemspec", File.open("spec/internal_gem/internal_gem.gemspec") {|f| f.read.gsub(/TODO/, "DONTCARE")})
|
15
|
+
IO.write("spec/internal_gem/internal_gem.gemspec", File.open("spec/internal_gem/internal_gem.gemspec") {|f| f.read.gsub(/.*homepage.*/, "")})
|
16
|
+
|
14
17
|
system("mv spec/internal_gem spec/internal")
|
15
18
|
Rake::Task['engine_cart:inject_gemfile_extras'].invoke
|
16
19
|
EngineCart.within_test_app do
|
@@ -40,10 +40,17 @@ namespace :engine_cart do
|
|
40
40
|
raise "Error generating new rails app. Aborting."
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
44
|
-
Rake::Task['engine_cart:clean'].invoke if File.
|
43
|
+
|
44
|
+
Rake::Task['engine_cart:clean'].invoke if File.exist? EngineCart.destination
|
45
45
|
FileUtils.move "#{dir}/internal", "#{EngineCart.destination}"
|
46
46
|
|
47
|
+
# Hack for https://github.com/rails/web-console/issues/150
|
48
|
+
IO.write("spec/internal/Gemfile", File.open("spec/internal/Gemfile") do |f|
|
49
|
+
f.read.gsub(/.*web-console.*/, "").gsub(/.*IRB console on exception pages.*/, "")
|
50
|
+
end)
|
51
|
+
File.open("spec/internal/Gemfile", "a") do |f|
|
52
|
+
f.puts 'gem "web-console", group: :development'
|
53
|
+
end
|
47
54
|
end
|
48
55
|
end
|
49
56
|
|
@@ -53,7 +60,7 @@ namespace :engine_cart do
|
|
53
60
|
gemfile_extras_path = File.expand_path("Gemfile.extra", EngineCart.templates_path)
|
54
61
|
|
55
62
|
f.write <<-EOF
|
56
|
-
#{File.read(gemfile_extras_path) if File.
|
63
|
+
#{File.read(gemfile_extras_path) if File.exist?(gemfile_extras_path)}
|
57
64
|
gem '#{EngineCart.current_engine_name}', :path => '#{File.expand_path('.')}'
|
58
65
|
EOF
|
59
66
|
end
|
@@ -65,7 +72,7 @@ EOF
|
|
65
72
|
args.with_defaults(:fingerprint => EngineCart.fingerprint) unless original_fingerprint
|
66
73
|
|
67
74
|
f = File.expand_path('.generated_engine_cart', EngineCart.destination)
|
68
|
-
unless File.
|
75
|
+
unless File.exist?(f) && File.read(f) == args[:fingerprint]
|
69
76
|
|
70
77
|
# Create a new test rails app
|
71
78
|
Rake::Task['engine_cart:create_test_rails_app'].invoke
|
@@ -75,7 +82,7 @@ EOF
|
|
75
82
|
Rake::Task['engine_cart:inject_gemfile_extras'].invoke
|
76
83
|
|
77
84
|
# Copy our test app generators into the app and prepare it
|
78
|
-
if File.
|
85
|
+
if File.exist? "#{EngineCart.templates_path}/lib/generators"
|
79
86
|
system "cp -r #{EngineCart.templates_path}/lib/generators #{EngineCart.destination}/lib"
|
80
87
|
end
|
81
88
|
|
data/lib/engine_cart/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
|
3
3
|
##
|
4
|
-
# EngineCartGenerator sets up an engine to
|
4
|
+
# EngineCartGenerator sets up an engine to
|
5
5
|
# use engine_cart-generated test apps
|
6
6
|
module EngineCart
|
7
7
|
class InstallGenerator < Rails::Generators::Base
|
@@ -35,28 +35,30 @@ module EngineCart
|
|
35
35
|
git_root = (`git rev-parse --show-toplevel` rescue '.').strip
|
36
36
|
|
37
37
|
# If we don't have a .gitignore file already, don't worry about it
|
38
|
-
return unless File.
|
38
|
+
return unless File.exist? File.expand_path('.gitignore', git_root)
|
39
39
|
|
40
40
|
# If the directory is already ignored (somehow) don't worry about it
|
41
41
|
return if (system('git', 'check-ignore', TEST_APP, '-q') rescue false)
|
42
42
|
|
43
|
-
append_file File.expand_path('.gitignore', git_root) do
|
43
|
+
append_file File.expand_path('.gitignore', git_root) do
|
44
44
|
"\n#{EngineCart.destination}\n"
|
45
|
-
end
|
45
|
+
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def add_gemfile_include
|
49
49
|
append_file "Gemfile" do
|
50
50
|
<<-EOF
|
51
51
|
|
52
|
+
# the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app
|
52
53
|
file = File.expand_path("Gemfile", ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path("../spec/internal", __FILE__))
|
53
|
-
if File.
|
54
|
+
if File.exist?(file)
|
54
55
|
puts "Loading \#{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
|
55
56
|
instance_eval File.read(file)
|
56
57
|
else
|
58
|
+
# we get here when we haven't yet generated the testing app via engine_cart
|
57
59
|
gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
|
58
60
|
|
59
|
-
if ENV['RAILS_VERSION']
|
61
|
+
if ENV['RAILS_VERSION'] && ENV['RAILS_VERSION'] =~ /^4.2/
|
60
62
|
gem 'responders', "~> 2.0"
|
61
63
|
gem 'sass-rails', ">= 5.0"
|
62
64
|
else
|
@@ -28,27 +28,27 @@ describe "EngineCart powered application" do
|
|
28
28
|
it "should create a rails app when the engine_cart:generate task is invoked" do
|
29
29
|
EngineCart.within_test_app do
|
30
30
|
`rake engine_cart:generate`
|
31
|
-
expect(File).to exist(File.expand_path(
|
31
|
+
expect(File).to exist(File.expand_path(EngineCart.destination))
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should not recreate an existing rails app when the engine_cart:generate task is reinvoked" do
|
36
36
|
EngineCart.within_test_app do
|
37
37
|
`rake engine_cart:generate`
|
38
|
-
expect(File).to exist(File.expand_path(
|
39
|
-
FileUtils.touch "
|
38
|
+
expect(File).to exist(File.expand_path(EngineCart.destination))
|
39
|
+
FileUtils.touch File.join(EngineCart.destination, ".this_should_still_exist")
|
40
40
|
`rake engine_cart:generate`
|
41
|
-
expect(File).to exist(File.expand_path("
|
41
|
+
expect(File).to exist(File.expand_path(File.join(EngineCart.destination, ".this_should_still_exist")))
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should create a rails app when the fingerprint argument is changed" do
|
46
46
|
EngineCart.within_test_app do
|
47
47
|
`rake engine_cart:generate[this-fingerprint]`
|
48
|
-
expect(File).to exist(File.expand_path(
|
49
|
-
FileUtils.touch "
|
48
|
+
expect(File).to exist(File.expand_path(EngineCart.destination))
|
49
|
+
FileUtils.touch File.join(EngineCart.destination, ".this_should_not_exist")
|
50
50
|
`rake engine_cart:generate[that-fingerprint]`
|
51
|
-
expect(File).to_not exist(File.expand_path("
|
51
|
+
expect(File).to_not exist(File.expand_path(File.join(EngineCart.destination, ".this_should_not_exist")))
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engine_cart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|