engine_cart 0.10.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d338f4c1822f3975c981752fe0e7ef0fb417f54
4
- data.tar.gz: d7ca112daff894c79df45a376e804919b79b45f7
3
+ metadata.gz: 8aa18a8e8f45266a8f194866541e61ab3db7c9b8
4
+ data.tar.gz: 8ab588fb5abcb9c192c96f4bb95fbecf31f1a29f
5
5
  SHA512:
6
- metadata.gz: cbf59d6d25f6f34f76d83a3e9495c03d5ac7a0dd3812d8dafa804e82f350a7a198f87a40d0d69ea387fed75c282864a8da73cdda754b2c754f19d12565c53be8
7
- data.tar.gz: 2504e8bd319a7e6c9d239776d7b3e844ec887b6d4af0ac29cc96ef4d8ae54a30a0098f3eba6b91e2f686e297f865c2b7b2a04eeffb5a5614520a340377bc0fb0
6
+ metadata.gz: b2643ac9390770f6101da94bd5f720cb9621ba849da7ca9d374d341cbc8dd57bc4f1a44d1ec81bdb567044778f911e3cec47eb00493fa17124d25e300aaccc74
7
+ data.tar.gz: c6b91a8a882496a0e86abd115d3d4b458dafbd0b90a182c83a003efa128e4ef30a507d1be578ca9df88c0e0d5a7935ed390c2d9b587e8cd188438f760f2ee5d4
@@ -0,0 +1 @@
1
+ destination: '.internal_test_gem'
@@ -6,9 +6,7 @@ rvm:
6
6
  matrix:
7
7
  include:
8
8
  - rvm: '2.2.5'
9
- env: "RAILS_VERSION=4.1.15"
10
- - rvm: '2.2.5'
11
- env: "RAILS_VERSION=4.2.6"
9
+ env: "RAILS_VERSION=4.2.7.1"
12
10
 
13
11
  env:
14
- - "RAILS_VERSION=5.0.0"
12
+ - "RAILS_VERSION=5.0.0.1"
data/Gemfile CHANGED
@@ -4,8 +4,3 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
7
-
8
- if ENV['RAILS_VERSION'] && ENV['RAILS_VERSION'] < '4.2'
9
- gem 'sass', '~> 3.2.15'
10
- gem 'sprockets', '~> 2.11.0'
11
- end
data/Rakefile CHANGED
@@ -23,8 +23,6 @@ task :generate_test_gem => ['engine_cart:setup'] do
23
23
  IO.write(".internal_test_gem/internal_test_gem.gemspec", File.open(".internal_test_gem/internal_test_gem.gemspec") {|f| f.read.gsub(/TODO/, "DONTCARE")})
24
24
  IO.write(".internal_test_gem/internal_test_gem.gemspec", File.open(".internal_test_gem/internal_test_gem.gemspec") {|f| f.read.gsub(/.*homepage.*/, "")})
25
25
 
26
- EngineCart.destination = '.internal_test_gem'
27
-
28
26
  Rake::Task['engine_cart:inject_gemfile_extras'].invoke
29
27
  EngineCart.within_test_app do
30
28
  system "git init"
@@ -1,14 +1,10 @@
1
+ require 'engine_cart/configuration'
1
2
  require "engine_cart/version"
2
3
  require 'engine_cart/gemfile_stanza'
3
4
  require 'bundler'
4
5
 
5
6
  module EngineCart
6
7
  require "engine_cart/engine" if defined? Rails
7
- require 'engine_cart/params'
8
-
9
- def self.current_engine_name
10
- engine_name || File.basename(Dir.glob("*.gemspec").first, '.gemspec')
11
- end
12
8
 
13
9
  def self.load_application! path = nil
14
10
  require File.expand_path("config/environment", path || EngineCart.destination)
@@ -25,11 +21,11 @@ module EngineCart
25
21
  def self.fingerprint
26
22
  @fingerprint || (@fingerprint_proc || method(:default_fingerprint)).call
27
23
  end
28
-
24
+
29
25
  def self.fingerprint= fingerprint
30
26
  @fingerprint = fingerprint
31
27
  end
32
-
28
+
33
29
  def self.fingerprint_proc= fingerprint_proc
34
30
  @fingerprint_proc = fingerprint_proc
35
31
  end
@@ -48,6 +44,18 @@ module EngineCart
48
44
  { 'RUBY_DESCRIPTION' => RUBY_DESCRIPTION, 'BUNDLE_GEMFILE' => Bundler.default_gemfile.to_s }.reject { |k, v| v.nil? || v.empty? }.to_s
49
45
  end
50
46
 
47
+ def self.configuration(options = {})
48
+ @configuration ||= EngineCart::Configuration.new(options)
49
+ end
50
+
51
+ class << self
52
+ %w(destination engine_name templates_path template rails_options).each do |method|
53
+ define_method(method) do
54
+ configuration.send(method)
55
+ end
56
+ end
57
+ end
58
+
51
59
  def self.check_for_gemfile_stanza
52
60
  return unless File.exist? 'Gemfile'
53
61
 
@@ -0,0 +1,98 @@
1
+ require 'yaml'
2
+
3
+ module EngineCart
4
+ class Configuration
5
+ attr_reader :options
6
+
7
+ def initialize(options = {})
8
+ @verbose = options[:verbose]
9
+
10
+ @options = load_configs(Array[options[:config]]).merge(options)
11
+ end
12
+
13
+ def load_configs(config_files)
14
+ config = default_config
15
+
16
+ (default_configuration_paths + config_files.compact).each do |p|
17
+ path = File.expand_path(p)
18
+ next unless File.exist? path
19
+ config.merge!(read_config(path))
20
+ end
21
+
22
+ config
23
+ end
24
+
25
+ ##
26
+ # Name of the engine we're testing
27
+ def engine_name
28
+ options[:engine_name]
29
+ end
30
+
31
+ ##
32
+ # Destination to generate the test app into
33
+ def destination
34
+ options[:destination]
35
+ end
36
+
37
+ ##
38
+ # Path to a Rails application template
39
+ def template
40
+ options[:template]
41
+ end
42
+
43
+ ##
44
+ # Path to test app templates to make available to
45
+ # the test app generator
46
+ def templates_path
47
+ options[:templates_path]
48
+ end
49
+
50
+ ##
51
+ # Additional options when generating a test rails application
52
+ def rails_options
53
+ options[:rails_options]
54
+ end
55
+
56
+ def default_destination
57
+ '.internal_test_app'
58
+ end
59
+
60
+ def default_engine_name
61
+ File.basename(Dir.glob('*.gemspec').first, '.gemspec')
62
+ end
63
+
64
+ def verbose?
65
+ @verbose || (options && !!options.fetch(:verbose, false))
66
+ end
67
+
68
+ private
69
+
70
+ def default_config
71
+ {
72
+ engine_name: ENV['CURRENT_ENGINE_NAME'] || default_engine_name,
73
+ destination: ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || default_destination,
74
+ template: ENV['ENGINE_CART_TEMPLATE'],
75
+ templates_path: ENV['ENGINE_CART_TEMPLATES_PATH'] || './spec/test_app_templates',
76
+ rails_options: ENV['ENGINE_CART_RAILS_OPTIONS']
77
+ }
78
+ end
79
+
80
+ def read_config(config_file)
81
+ $stdout.puts "Loading configuration from #{config_file}" if verbose?
82
+ config = YAML.load(ERB.new(IO.read(config_file)).result(binding))
83
+ unless config
84
+ $stderr.puts "Unable to parse config #{config_file}" if verbose?
85
+ return {}
86
+ end
87
+ convert_keys(config)
88
+ end
89
+
90
+ def convert_keys(hash)
91
+ hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
92
+ end
93
+
94
+ def default_configuration_paths
95
+ ['~/.engine_cart.yml', '.engine_cart.yml']
96
+ end
97
+ end
98
+ end
@@ -1,5 +1,3 @@
1
- require 'engine_cart/params'
2
-
3
1
  module EngineCart
4
2
  def self.gemfile_stanza_check_line
5
3
  "engine_cart stanza: 0.10.0"
@@ -69,10 +69,10 @@ namespace :engine_cart do
69
69
  task :inject_gemfile_extras => [:setup] do
70
70
  # Add our gem and extras to the generated Rails app
71
71
  open(File.expand_path('Gemfile', EngineCart.destination), 'a') do |f|
72
- gemfile_extras_path = File.expand_path("Gemfile.extra", EngineCart.templates_path)
72
+ f.puts "gem '#{EngineCart.engine_name}', path: '#{File.expand_path('.')}'"
73
73
 
74
- f.write File.read(gemfile_extras_path) if File.exist?(gemfile_extras_path)
75
- f.write "gem '#{EngineCart.current_engine_name}', path: '#{File.expand_path('.')}'"
74
+ gemfile_extras_path = File.expand_path("Gemfile.extra", EngineCart.templates_path)
75
+ f.puts "eval_gemfile File.expand_path('#{gemfile_extras_path}', File.dirname(__FILE__)) if File.exist?('#{gemfile_extras_path}')"
76
76
  end
77
77
  end
78
78
 
@@ -126,11 +126,11 @@ namespace :engine_cart do
126
126
  end
127
127
 
128
128
  def within_test_app
129
- puts "travis_fold:start:enginecart-bundler-cleanenv\r" if ENV['TRAVIS'] == 'true'
129
+ puts "\rtravis_fold:start:enginecart-bundler-cleanenv\r" if ENV['TRAVIS'] == 'true'
130
130
  Dir.chdir(EngineCart.destination) do
131
131
  Bundler.with_clean_env do
132
132
  yield
133
133
  end
134
134
  end
135
- puts "travis_fold:end:enginecart-bundler-cleanenv\r" if ENV['TRAVIS'] == 'true'
135
+ puts "\rtravis_fold:end:enginecart-bundler-cleanenv\r" if ENV['TRAVIS'] == 'true'
136
136
  end
@@ -1,3 +1,3 @@
1
1
  module EngineCart
2
- VERSION = '0.10.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -24,7 +24,7 @@ module EngineCart
24
24
  # after setting up the application
25
25
 
26
26
  def install_engine
27
- generate '#{EngineCart.current_engine_name}:install'
27
+ generate '#{EngineCart.engine_name}:install'
28
28
  end
29
29
  end
30
30
 
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "EngineCart powered application" do
4
- EngineCart.destination = File.expand_path("../../.internal_test_gem", File.dirname(__FILE__))
5
-
6
4
  it "should have the test_app_templates pre-generated" do
7
5
  expect(File).to exist File.expand_path("spec/test_app_templates", EngineCart.destination)
8
6
  end
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.10.0
4
+ version: 1.0.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: 2016-07-06 00:00:00.000000000 Z
11
+ date: 2016-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -73,6 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".engine_cart.yml"
76
77
  - ".gitignore"
77
78
  - ".travis.yml"
78
79
  - Gemfile
@@ -81,9 +82,9 @@ files:
81
82
  - Rakefile
82
83
  - engine_cart.gemspec
83
84
  - lib/engine_cart.rb
85
+ - lib/engine_cart/configuration.rb
84
86
  - lib/engine_cart/engine.rb
85
87
  - lib/engine_cart/gemfile_stanza.rb
86
- - lib/engine_cart/params.rb
87
88
  - lib/engine_cart/rake_task.rb
88
89
  - lib/engine_cart/tasks/engine_cart.rake
89
90
  - lib/engine_cart/version.rb
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  version: '0'
111
112
  requirements: []
112
113
  rubyforge_project:
113
- rubygems_version: 2.6.4
114
+ rubygems_version: 2.5.1
114
115
  signing_key:
115
116
  specification_version: 4
116
117
  summary: Helper for testing Rails Engines sanely
@@ -1,38 +0,0 @@
1
- module EngineCart
2
- class << self
3
-
4
- ##
5
- # Name of the engine we're testing
6
- attr_accessor :engine_name
7
-
8
- ##
9
- # Destination to generate the test app into
10
- attr_accessor :destination
11
-
12
- ##
13
- # Path to a Rails application template
14
- attr_accessor :template
15
-
16
- ##
17
- # Path to test app templates to make available to
18
- # the test app generator
19
- attr_accessor :templates_path
20
-
21
-
22
- ##
23
- # Additional options when generating a test rails application
24
- attr_accessor :rails_options
25
-
26
- end
27
-
28
- self.engine_name = ENV["CURRENT_ENGINE_NAME"]
29
-
30
- def self.default_destination
31
- ('.internal_test_app' if File.exist? '.internal_test_app') || ('spec/internal' if File.exist? 'spec/internal') || '.internal_test_app'
32
- end
33
-
34
- self.destination = ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || default_destination
35
- self.template = ENV["ENGINE_CART_TEMPLATE"]
36
- self.templates_path = ENV['ENGINE_CART_TEMPLATES_PATH'] || "./spec/test_app_templates"
37
- self.rails_options = ENV['ENGINE_CART_RAILS_OPTIONS']
38
- end