combustion 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -1
  3. data/.rubocop.yml +31 -0
  4. data/.travis.yml +5 -5
  5. data/Appraisals +13 -0
  6. data/Gemfile +2 -0
  7. data/HISTORY +5 -0
  8. data/README.md +2 -2
  9. data/Rakefile +11 -1
  10. data/combustion.gemspec +26 -22
  11. data/exe/combust +3 -2
  12. data/gemfiles/rails_5.0.gemfile +1 -0
  13. data/gemfiles/rails_5.1.gemfile +1 -0
  14. data/gemfiles/rails_5.2.gemfile +7 -0
  15. data/lib/combustion.rb +35 -22
  16. data/lib/combustion/application.rb +23 -27
  17. data/lib/combustion/configurations/action_controller.rb +11 -0
  18. data/lib/combustion/configurations/action_mailer.rb +10 -0
  19. data/lib/combustion/configurations/active_record.rb +13 -0
  20. data/lib/combustion/database.rb +23 -13
  21. data/lib/combustion/database/load_schema.rb +14 -4
  22. data/lib/combustion/database/migrate.rb +29 -12
  23. data/lib/combustion/database/reset.rb +26 -21
  24. data/lib/combustion/databases/base.rb +3 -1
  25. data/lib/combustion/databases/firebird.rb +2 -0
  26. data/lib/combustion/databases/mysql.rb +55 -26
  27. data/lib/combustion/databases/oracle.rb +2 -0
  28. data/lib/combustion/databases/postgresql.rb +11 -10
  29. data/lib/combustion/databases/sql_server.rb +4 -2
  30. data/lib/combustion/databases/sqlite.rb +8 -6
  31. data/lib/combustion/generator.rb +16 -14
  32. data/spec/database_spec.rb +16 -12
  33. data/spec/dummy/db/migrate/20150717075542_create_dummy_test_table.rb +3 -1
  34. data/spec/dummy/db/migrate/20150717075543_create_dummy_test_table_in_another_db.rb +3 -1
  35. data/spec/dummy/lib/engine.rb +3 -1
  36. data/spec/dummy/spec/internal/app/models/model.rb +3 -1
  37. data/spec/dummy/spec/internal/app/models/model_in_another_db.rb +3 -1
  38. data/spec/dummy/spec/internal/config/routes.rb +2 -0
  39. data/spec/dummy/spec/internal/db/schema.rb +2 -0
  40. data/spec/spec_helper.rb +6 -5
  41. data/templates/config.ru +4 -2
  42. data/templates/routes.rb +2 -0
  43. data/templates/schema.rb +2 -0
  44. metadata +22 -4
  45. data/bin/literals +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4eecc61f64900b28416b12bdf1a10732233c945a
4
- data.tar.gz: c273b82455f6e3c05d08de860ecdaa32d4302990
2
+ SHA256:
3
+ metadata.gz: 6fe7aab6e68f602f2b368bc8fa1b0bdeadc34a72eacd4b9d3c30ce6f6dfd6d9c
4
+ data.tar.gz: 7342be839ec93b552be92ba789f8dc1d102b8ceeb301fe9e0ad820724dfd4ebf
5
5
  SHA512:
6
- metadata.gz: f2ba1f8bcd5c49c1f3424fa8107b27df888c681e13e155b16ec5b8a918752cd0da972ea9f86e960a86efff4fe67d36c2dd333f89a77a5424c98457c1e4f25327
7
- data.tar.gz: 63145f149be8fae43c84fd0c6af4f706e07a74bf8dae2e76e0cc813eaa6bfa16a479093caef8fbf58fa57f6607b42edbfa1fbfd9f024e29d0a380c007c46f30c
6
+ metadata.gz: 04bba0ac0ac7d86e114549ff9e59e9f35098238b2dc1774254bcfab367938467c9b88790d3a45f17ff50d8c0865d7b9691da25b1b8fdcf6489bebd260880b241
7
+ data.tar.gz: 8bce1e790cd64eb3c9fc24cfa83d53c1a2627b7fcf82b6ea8759bc856247b92c22a18cd3820b8b41d9f37cc957c6816875991d80c2681baf59bd1a7709cea2ca
data/.gitignore CHANGED
@@ -3,8 +3,9 @@
3
3
  Gemfile.lock
4
4
  gemfiles/*.lock
5
5
  pkg/*
6
- .rvmrc
6
+ .rubocop-*-yml
7
7
  .ruby-version
8
+ .rvmrc
8
9
  spec/dummy/spec/internal/db/*.sqlite
9
10
  spec/dummy/spec/internal/test
10
11
  spec/dummy/spec/internal/test_another
@@ -0,0 +1,31 @@
1
+ inherit_from:
2
+ - https://gist.githubusercontent.com/pat/ba3b8ffb1901bfe5439b460943b6b019/raw/.rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.2
6
+
7
+ Layout/DotPosition:
8
+ EnforcedStyle: trailing
9
+
10
+ Layout/CaseIndentation:
11
+ EnforcedStyle: end
12
+
13
+ Layout/IndentHeredoc:
14
+ Enabled: false
15
+
16
+ Lint/EndAlignment:
17
+ EnforcedStyleAlignWith: variable
18
+
19
+ Metrics/BlockLength:
20
+ Exclude:
21
+ - 'combustion.gemspec'
22
+
23
+ Style/ClassAndModuleChildren:
24
+ Enabled: false
25
+
26
+ Style/Documentation:
27
+ Enabled: false
28
+
29
+ Style/MultilineTernaryOperator:
30
+ Exclude:
31
+ - 'spec/dummy/db/migrate/*.rb'
@@ -5,16 +5,16 @@ env:
5
5
  - "DB_ADAPTER=postgresql"
6
6
  - "DB_ADAPTER=mysql2"
7
7
  rvm:
8
- - 2.2.6
9
- - 2.3.4
10
- - 2.4.1
8
+ - 2.2.9
9
+ - 2.3.6
10
+ - 2.4.3
11
+ - 2.5.0
11
12
  before_install:
12
13
  - gem update --system
13
14
  - gem install bundler
14
15
  before_script:
15
- - ./bin/literals
16
16
  - bundle exec appraisal install
17
- script: 'bundle exec appraisal rspec'
17
+ script: 'bundle exec appraisal rake'
18
18
  services:
19
19
  - mysql
20
20
  - postgresql
data/Appraisals CHANGED
@@ -1,33 +1,46 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if RUBY_VERSION.to_f <= 2.3
2
4
  appraise "rails-3.1" do
3
5
  gem "rails", "~> 3.1.12"
4
6
  gem "mysql2", "~> 0.3.10"
7
+ gem "pg", "< 1.0"
5
8
  end
6
9
 
7
10
  appraise "rails-3.2" do
8
11
  gem "rails", "~> 3.2.22.5"
9
12
  gem "mysql2", "~> 0.3.10"
13
+ gem "pg", "< 1.0"
10
14
  end
11
15
 
12
16
  appraise "rails-4.0" do
13
17
  gem "rails", "~> 4.0.13"
14
18
  gem "mysql2", "~> 0.3.10"
19
+ gem "pg", "< 1.0"
15
20
  end
16
21
 
17
22
  appraise "rails-4.1" do
18
23
  gem "rails", "~> 4.1.16"
19
24
  gem "mysql2", "~> 0.3.13"
25
+ gem "pg", "< 1.0"
20
26
  end
21
27
 
22
28
  appraise "rails-4.2" do
23
29
  gem "rails", "~> 4.2.8"
30
+ gem "pg", "< 1.0"
24
31
  end
25
32
  end
26
33
 
27
34
  appraise "rails-5.0" do
28
35
  gem "rails", "~> 5.0.2"
36
+ gem "pg", "< 1.0"
29
37
  end
30
38
 
31
39
  appraise "rails-5.1" do
32
40
  gem "rails", "~> 5.1.0"
41
+ gem "pg", "< 1.0"
42
+ end
43
+
44
+ appraise "rails-5.2" do
45
+ gem "rails", "~> 5.2.0.rc1"
33
46
  end
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "http://rubygems.org"
2
4
 
3
5
  gemspec
data/HISTORY CHANGED
@@ -1,3 +1,8 @@
1
+ 0.8.0 - February 1st 2018
2
+ * Rails 5.2.0 support.
3
+ * Requiring digest from std-lib directly.
4
+ * Refactoring for cleaner code.
5
+
1
6
  0.7.0 - June 20th 2017
2
7
  * Confirm support for MRI frozen string literals.
3
8
  * Hide migration output (Michael Grosser).
data/README.md CHANGED
@@ -10,10 +10,10 @@ Get the gem into either your gemspec or your Gemfile, depending on how you manag
10
10
 
11
11
  ```ruby
12
12
  # gemspec
13
- gem.add_development_dependency 'combustion', '~> 0.7.0'
13
+ gem.add_development_dependency 'combustion', '~> 0.8.0'
14
14
 
15
15
  # Gemfile
16
- gem 'combustion', '~> 0.7.0', :group => :test
16
+ gem 'combustion', '~> 0.8.0', :group => :test
17
17
  ```
18
18
 
19
19
  In your `spec_helper.rb`, get Combustion to set itself up - which has to happen before you introduce `rspec/rails` and - if being used - `capybara/rails`. Here's an example within context:
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
- require 'bundler/gem_tasks'
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new(:rubocop)
9
+
10
+ Rake::Task["default"].clear if Rake::Task.task_defined?("default")
11
+ task :default => %i[ rubocop spec ]
@@ -1,30 +1,34 @@
1
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
+
2
3
  Gem::Specification.new do |s|
3
- s.name = 'combustion'
4
- s.version = '0.7.0'
5
- s.authors = ['Pat Allan']
6
- s.email = ['pat@freelancing-gods.com']
7
- s.homepage = 'https://github.com/pat/combustion'
8
- s.summary = 'Elegant Rails Engine Testing'
9
- s.description = 'Test your Rails Engines without needing a full Rails app'
10
- s.license = 'MIT'
4
+ s.name = "combustion"
5
+ s.version = "0.8.0"
6
+ s.authors = ["Pat Allan"]
7
+ s.email = ["pat@freelancing-gods.com"]
8
+ s.homepage = "https://github.com/pat/combustion"
9
+ s.summary = "Elegant Rails Engine Testing"
10
+ s.description = "Test your Rails Engines without needing a full Rails app"
11
+ s.license = "MIT"
11
12
 
12
- s.rubyforge_project = 'combustion'
13
+ s.rubyforge_project = "combustion"
13
14
 
14
15
  s.files = `git ls-files`.split("\n")
15
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
- s.executables = `git ls-files -- exe/*`.split("\n").map{ |f| File.basename(f) }
17
- s.bindir = 'exe'
18
- s.require_paths = ['lib']
17
+ s.executables = `git ls-files -- exe/*`.split("\n").map do |file|
18
+ File.basename(file)
19
+ end
20
+ s.bindir = "exe"
21
+ s.require_paths = ["lib"]
19
22
 
20
- s.add_runtime_dependency 'activesupport', '>= 3.0.0'
21
- s.add_runtime_dependency 'railties', '>= 3.0.0'
22
- s.add_runtime_dependency 'thor', '>= 0.14.6'
23
+ s.add_runtime_dependency "activesupport", ">= 3.0.0"
24
+ s.add_runtime_dependency "railties", ">= 3.0.0"
25
+ s.add_runtime_dependency "thor", ">= 0.14.6"
23
26
 
24
- s.add_development_dependency 'appraisal', '~> 2.1.0'
25
- s.add_development_dependency 'mysql2'
26
- s.add_development_dependency 'pg'
27
- s.add_development_dependency 'rails'
28
- s.add_development_dependency 'rspec'
29
- s.add_development_dependency 'sqlite3'
27
+ s.add_development_dependency "appraisal", "~> 2.1.0"
28
+ s.add_development_dependency "mysql2"
29
+ s.add_development_dependency "pg"
30
+ s.add_development_dependency "rails"
31
+ s.add_development_dependency "rspec"
32
+ s.add_development_dependency "rubocop", "~> 0.50.0"
33
+ s.add_development_dependency "sqlite3"
30
34
  end
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- mode: ruby -*-
3
+ # frozen_string_literal: true
3
4
 
4
- require 'combustion'
5
- require 'combustion/generator'
5
+ require "combustion"
6
+ require "combustion/generator"
6
7
 
7
8
  Combustion::Generator.start
@@ -3,5 +3,6 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.0.2"
6
+ gem "pg", "< 1.0"
6
7
 
7
8
  gemspec :path => "../"
@@ -3,5 +3,6 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.1.0"
6
+ gem "pg", "< 1.0"
6
7
 
7
8
  gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "~> 5.2.0.rc1"
6
+
7
+ gemspec :path => "../"
@@ -1,38 +1,49 @@
1
- require 'rails'
2
- require 'active_support/dependencies'
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+ require "active_support/dependencies"
3
5
 
4
6
  module Combustion
5
- mattr_accessor :path, :schema_format
6
- mattr_reader :setup_environment
7
+ module Configurations
8
+ #
9
+ end
10
+
11
+ mattr_accessor :path, :schema_format, :setup_environment
7
12
 
8
- self.path = '/spec/internal'
13
+ self.path = "/spec/internal"
9
14
  self.schema_format = :ruby
10
15
 
11
- if Rails.version.to_s > '3.1'
12
- Modules = %w( active_record action_controller action_view action_mailer
13
- sprockets )
16
+ MODULES = if Rails.version.to_f >= 3.1
17
+ %w[ active_record action_controller action_view action_mailer sprockets ]
14
18
  else
15
- Modules = %w( active_record action_controller action_view action_mailer )
19
+ %w[ active_record action_controller action_view action_mailer ]
16
20
  end
17
21
 
18
22
  def self.initialize!(*modules, &block)
19
- @@setup_environment = block if block_given?
23
+ self.setup_environment = block if block_given?
20
24
 
21
25
  options = modules.extract_options!
22
- modules = Modules if modules == [:all]
26
+ modules = MODULES if modules == [:all]
23
27
  modules.each { |mod| require "#{mod}/railtie" }
24
28
 
25
29
  Bundler.require :default, Rails.env
26
30
 
27
31
  Combustion::Application.configure_for_combustion
32
+ include_database modules, options
33
+ Combustion::Application.initialize!
34
+ include_rspec
35
+ end
28
36
 
29
- if modules.map(&:to_s).include? 'active_record'
30
- Combustion::Application.config.to_prepare do
31
- Combustion::Database.setup(options)
32
- end
37
+ def self.include_database(modules, options)
38
+ return unless modules.map(&:to_s).include? "active_record"
39
+
40
+ Combustion::Application.config.to_prepare do
41
+ Combustion::Database.setup(options)
33
42
  end
43
+ end
34
44
 
35
- Combustion::Application.initialize!
45
+ def self.include_rspec
46
+ return unless defined?(RSpec) && RSpec.respond_to?(:configure)
36
47
 
37
48
  RSpec.configure do |config|
38
49
  include_capybara_into config
@@ -41,7 +52,7 @@ module Combustion
41
52
  if Combustion::Application.routes.respond_to?(:mounted_helpers)
42
53
  config.include Combustion::Application.routes.mounted_helpers
43
54
  end
44
- end if defined?(RSpec) && RSpec.respond_to?(:configure)
55
+ end
45
56
  end
46
57
 
47
58
  def self.include_capybara_into(config)
@@ -49,12 +60,14 @@ module Combustion
49
60
 
50
61
  config.include Capybara::RSpecMatchers if defined?(Capybara::RSpecMatchers)
51
62
  config.include Capybara::DSL if defined?(Capybara::DSL)
63
+ return if defined?(Capybara::RSpecMatchers) || defined?(Capybara::DSL)
52
64
 
53
- unless defined?(Capybara::RSpecMatchers) || defined?(Capybara::DSL)
54
- config.include Capybara
55
- end
65
+ config.include Capybara
56
66
  end
57
67
  end
58
68
 
59
- require 'combustion/application'
60
- require 'combustion/database'
69
+ require "combustion/application"
70
+ require "combustion/configurations/action_controller"
71
+ require "combustion/configurations/action_mailer"
72
+ require "combustion/configurations/active_record"
73
+ require "combustion/database"
@@ -1,15 +1,22 @@
1
- require 'securerandom'
2
- Rails.env = ENV['RAILS_ENV'] || 'test'
1
+ # frozen_string_literal: true
2
+
3
+ require "securerandom"
4
+ require "digest"
5
+ Rails.env = ENV["RAILS_ENV"] || "test"
3
6
 
4
7
  module Combustion
5
8
  class Application < Rails::Application
6
9
  # Core Settings
7
10
  config.cache_classes = true
8
- config.whiny_nils = true if Rails.version.to_s < '4.0.0'
9
11
  config.consider_all_requests_local = true
10
12
  config.secret_token = Digest::SHA1.hexdigest Time.now.to_s
11
13
  config.eager_load = Rails.env.production?
12
- config.secret_key_base = SecureRandom.hex if Rails.version.to_s >= '4.0.0'
14
+
15
+ if Rails.version.to_f >= 4.0
16
+ config.secret_key_base = SecureRandom.hex
17
+ else
18
+ config.whiny_nils = true
19
+ end
13
20
 
14
21
  # ActiveSupport Settings
15
22
  config.active_support.deprecation = :stderr
@@ -20,31 +27,20 @@ module Combustion
20
27
  def self.configure_for_combustion
21
28
  config.root = File.expand_path File.join(Dir.pwd, Combustion.path)
22
29
 
23
- if defined?(ActiveRecord::Railtie) && ::ActiveRecord.constants.include?(:MassAssignmentSecurity)
24
- # Turn on ActiveRecord attribute whitelisting
25
- # This way the dummy app matches new rails apps re: this setting
26
- config.active_record.whitelist_attributes = true
27
- config.active_record.mass_assignment_sanitizer = :strict
28
- end
29
-
30
- if defined?(ActionController::Railtie)
31
- config.action_dispatch.show_exceptions = false
32
- config.action_controller.perform_caching = false
33
- config.action_controller.allow_forgery_protection = false
34
- end
35
-
36
- if defined?(ActionMailer::Railtie)
37
- config.action_mailer.delivery_method = :test
38
- config.action_mailer.default_url_options = {:host => 'www.example.com'}
39
- end
40
-
41
- if defined?(Sprockets)
42
- config.assets.enabled = true
43
- end
30
+ Combustion::Configurations::ActiveRecord.call config
31
+ Combustion::Configurations::ActionController.call config
32
+ Combustion::Configurations::ActionMailer.call config
33
+
34
+ config.assets.enabled = true if defined?(Sprockets)
44
35
  end
45
36
 
46
- initializer :load_customized_environment_for_combustion, :before => :load_environment_config, :group => :all do
47
- Combustion::Application.class_eval(&Combustion.setup_environment) if Combustion.setup_environment
37
+ initializer(
38
+ :load_customized_environment_for_combustion,
39
+ :before => :load_environment_config,
40
+ :group => :all
41
+ ) do
42
+ next unless Combustion.setup_environment
43
+ Combustion::Application.class_eval(&Combustion.setup_environment)
48
44
  end
49
45
  end
50
46
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Combustion::Configurations::ActionController
4
+ def self.call(config)
5
+ return unless defined?(ActionController::Railtie)
6
+
7
+ config.action_dispatch.show_exceptions = false
8
+ config.action_controller.perform_caching = false
9
+ config.action_controller.allow_forgery_protection = false
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Combustion::Configurations::ActionMailer
4
+ def self.call(config)
5
+ return unless defined?(ActionMailer::Railtie)
6
+
7
+ config.action_mailer.delivery_method = :test
8
+ config.action_mailer.default_url_options = {:host => "www.example.com"}
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Combustion::Configurations::ActiveRecord
4
+ def self.call(config)
5
+ return unless defined?(ActiveRecord::Railtie)
6
+ return unless ::ActiveRecord.constants.include?(:MassAssignmentSecurity)
7
+
8
+ # Turn on ActiveRecord attribute whitelisting
9
+ # This way the dummy app matches new rails apps re: this setting
10
+ config.active_record.whitelist_attributes = true
11
+ config.active_record.mass_assignment_sanitizer = :strict
12
+ end
13
+ end
@@ -1,25 +1,35 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Combustion
2
4
  module Databases
3
5
  #
4
6
  end
5
7
 
6
8
  class Database
9
+ DEFAULT_OPTIONS = {
10
+ :database_reset => true,
11
+ :load_schema => true,
12
+ :database_migrate => true
13
+ }.freeze
14
+
7
15
  def self.setup(options = {})
8
- Combustion::Database::Reset.call if options.fetch(:database_reset, true)
9
- Combustion::Database::LoadSchema.call if options.fetch(:load_schema, true)
10
- Combustion::Database::Migrate.call if options.fetch(:database_migrate, true)
16
+ options = DEFAULT_OPTIONS.merge options
17
+
18
+ Combustion::Database::Reset.call if options[:database_reset]
19
+ Combustion::Database::LoadSchema.call if options[:load_schema]
20
+ Combustion::Database::Migrate.call if options[:database_migrate]
11
21
  end
12
22
  end
13
23
  end
14
24
 
15
- require 'combustion/database/load_schema'
16
- require 'combustion/database/migrate'
17
- require 'combustion/database/reset'
25
+ require "combustion/databases/base"
26
+ require "combustion/databases/firebird"
27
+ require "combustion/databases/mysql"
28
+ require "combustion/databases/oracle"
29
+ require "combustion/databases/postgresql"
30
+ require "combustion/databases/sql_server"
31
+ require "combustion/databases/sqlite"
18
32
 
19
- require 'combustion/databases/base'
20
- require 'combustion/databases/firebird'
21
- require 'combustion/databases/mysql'
22
- require 'combustion/databases/oracle'
23
- require 'combustion/databases/postgresql'
24
- require 'combustion/databases/sql_server'
25
- require 'combustion/databases/sqlite'
33
+ require "combustion/database/load_schema"
34
+ require "combustion/database/migrate"
35
+ require "combustion/database/reset"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Combustion::Database::LoadSchema
2
4
  UnknownSchemaFormat = Class.new StandardError
3
5
 
@@ -10,11 +12,9 @@ class Combustion::Database::LoadSchema
10
12
 
11
13
  case schema_format
12
14
  when :ruby
13
- load Rails.root.join('db', 'schema.rb')
15
+ load_ruby_schema
14
16
  when :sql
15
- ActiveRecord::Base.connection.execute(
16
- File.read(Rails.root.join('db', 'structure.sql'))
17
- )
17
+ load_sql_schema
18
18
  else
19
19
  raise UnknownSchemaFormat, "Unknown schema format: #{schema_format}"
20
20
  end
@@ -22,6 +22,16 @@ class Combustion::Database::LoadSchema
22
22
 
23
23
  private
24
24
 
25
+ def load_ruby_schema
26
+ load Rails.root.join("db", "schema.rb")
27
+ end
28
+
29
+ def load_sql_schema
30
+ ActiveRecord::Base.connection.execute(
31
+ File.read(Rails.root.join("db", "structure.sql"))
32
+ )
33
+ end
34
+
25
35
  def schema_format
26
36
  Combustion.schema_format
27
37
  end
@@ -1,10 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Combustion::Database::Migrate
2
4
  def self.call
3
5
  new.call
4
6
  end
5
7
 
6
8
  def call
7
- if ActiveRecord::VERSION::STRING >= '3.1.0'
9
+ if ActiveRecord::VERSION::STRING.to_f >= 5.2
10
+ migration_context.migrate
11
+ elsif ActiveRecord::VERSION::STRING.to_f >= 3.1
8
12
  migrator.migrate paths, nil
9
13
  else
10
14
  paths.each { |path| migrator.migrate path, nil }
@@ -17,24 +21,37 @@ class Combustion::Database::Migrate
17
21
  if migrator.respond_to?(:migrations_paths)
18
22
  migrator.migrations_paths
19
23
  else
20
- Array('db/migrate/')
24
+ Array("db/migrate/")
25
+ end
26
+ end
27
+
28
+ def engine_migration_paths
29
+ migration_paths = Rails.application.paths["db/migrate"].to_a
30
+
31
+ if engine_paths_exist_in?(migration_paths)
32
+ migration_paths
33
+ else
34
+ base_migration_paths + migration_paths
21
35
  end
22
36
  end
23
37
 
38
+ def engine_path
39
+ Rails.application.root.sub(::Combustion.path, "")
40
+ end
41
+
42
+ def engine_paths_exist_in?(paths)
43
+ paths.include?(engine_path.join("db/migrate").to_s)
44
+ end
45
+
46
+ def migration_context
47
+ ActiveRecord::MigrationContext.new paths
48
+ end
49
+
24
50
  def migrator
25
51
  @migrator ||= ActiveRecord::Migrator
26
52
  end
27
53
 
28
54
  def paths
29
- engine_path = Rails.application.root.sub(::Combustion.path, '')
30
- migration_paths = Rails.application.paths['db/migrate'].to_a
31
-
32
- if migration_paths.include?(engine_path.join('db/migrate').to_s)
33
- paths = []
34
- else
35
- paths = base_migration_paths
36
- end
37
-
38
- (paths + migration_paths + [File.join(Rails.root, 'db/migrate')]).uniq
55
+ (engine_migration_paths + [File.join(Rails.root, "db/migrate")]).uniq
39
56
  end
40
57
  end
@@ -1,20 +1,31 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Combustion::Database::Reset
2
4
  UnsupportedDatabase = Class.new StandardError
3
5
 
6
+ OPERATOR_PATTERNS = {
7
+ Combustion::Databases::MySQL => [/mysql/],
8
+ Combustion::Databases::PostgreSQL => [/postgres/, /postgis/],
9
+ Combustion::Databases::SQLite => [/sqlite/],
10
+ Combustion::Databases::SQLServer => [/sqlserver/],
11
+ Combustion::Databases::Oracle => %w[ oci oracle ],
12
+ Combustion::Databases::Firebird => %w[ firebird ]
13
+ }.freeze
14
+
4
15
  def self.call
5
16
  new.call
6
17
  end
7
18
 
8
19
  def initialize
9
- ActiveRecord::Base.configurations = YAML.load(
10
- ERB.new(File.read("#{Rails.root}/config/database.yml")).result
20
+ ActiveRecord::Base.configurations = YAML.safe_load(
21
+ ERB.new(database_yaml).result, [], [], true
11
22
  )
12
23
  end
13
24
 
14
25
  def call
15
- ActiveRecord::Base.configurations.values.each do |configuration|
16
- adapter = configuration['adapter'] ||
17
- configuration['url'].split('://').first
26
+ ActiveRecord::Base.configurations.each_value do |configuration|
27
+ adapter = configuration["adapter"] ||
28
+ configuration["url"].split("://").first
18
29
 
19
30
  operator_class(adapter).new(configuration).reset
20
31
  end
@@ -22,23 +33,17 @@ class Combustion::Database::Reset
22
33
 
23
34
  private
24
35
 
36
+ def database_yaml
37
+ File.read "#{Rails.root}/config/database.yml"
38
+ end
39
+
25
40
  def operator_class(adapter)
26
- @operator ||= case adapter
27
- when /mysql/
28
- Combustion::Databases::MySQL
29
- when /postgres/, /postgis/
30
- Combustion::Databases::PostgreSQL
31
- when /sqlite/
32
- Combustion::Databases::SQLite
33
- when /sqlserver/
34
- Combustion::Databases::SQLServer
35
- when 'oci', 'oracle'
36
- Combustion::Databases::Oracle
37
- when 'firebird'
38
- Combustion::Databases::Firebird
39
- else
40
- raise UnsupportedDatabase,
41
- "Unsupported database type: #{adapter}"
41
+ klass = nil
42
+ OPERATOR_PATTERNS.each do |operator, keys|
43
+ klass = operator if keys.any? { |key| adapter[key] }
42
44
  end
45
+ return klass if klass
46
+
47
+ raise UnsupportedDatabase, "Unsupported database type: #{adapter}"
43
48
  end
44
49
  end
@@ -1,4 +1,6 @@
1
- require 'active_support/core_ext/module/delegation'
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/module/delegation"
2
4
 
3
5
  class Combustion::Databases::Base
4
6
  def initialize(configuration)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Combustion::Databases::Firebird < Combustion::Databases::Base
2
4
  def reset
3
5
  establish_connection :test
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Combustion::Databases::MySQL < Combustion::Databases::Base
2
- ACCESS_DENIED_ERROR = 10145
4
+ ACCESS_DENIED_ERROR = 10_145
3
5
 
4
6
  def reset
5
- establish_connection(configuration.merge('database' => nil))
7
+ establish_connection(configuration.merge("database" => nil))
6
8
 
7
9
  super
8
10
  end
@@ -10,34 +12,36 @@ class Combustion::Databases::MySQL < Combustion::Databases::Base
10
12
  private
11
13
 
12
14
  def charset
13
- configuration['charset'] || ENV['CHARSET'] || 'utf8'
15
+ configuration["charset"] || ENV["CHARSET"] || "utf8"
16
+ end
17
+
18
+ def charset_error
19
+ return "" unless config["charset"]
20
+
21
+ "(if you set the charset manually, make sure you have a matching collation)"
14
22
  end
15
23
 
16
24
  def collation
17
- configuration['collation'] || ENV['COLLATION'] || 'utf8_unicode_ci'
25
+ configuration["collation"] || ENV["COLLATION"] || "utf8_unicode_ci"
18
26
  end
19
27
 
20
28
  def create
21
- connection.create_database configuration['database'], creation_options
29
+ connection.create_database configuration["database"], creation_options
22
30
  establish_connection configuration
23
31
  rescue error_class => error
24
- if error.errno == ACCESS_DENIED_ERROR
25
- create_as_root
26
- else
27
- $stderr.puts error.error
28
- $stderr.puts "Couldn't create database for #{config.inspect}, charset: #{charset}, collation: #{collation}"
29
- $stderr.puts "(if you set the charset manually, make sure you have a matching collation)" if config['charset']
30
- end
32
+ rescue_create_from error
31
33
  end
32
34
 
33
- def create_as_root
34
- print "#{sqlerr.error}. \nPlease provide the root password for your mysql installation\n>"
35
- root_password = $stdin.gets.strip
35
+ def create_as_root(error)
36
36
  establish_connection configuration.merge(
37
- 'database' => nil, 'username' => 'root', 'password' => root_password
37
+ "database" => nil,
38
+ "username" => "root",
39
+ "password" => request_password(error)
38
40
  )
39
- connection.create_database config['database'], creation_options
41
+
42
+ connection.create_database config["database"], creation_options
40
43
  connection.execute grant_statement
44
+
41
45
  establish_connection configuration
42
46
  end
43
47
 
@@ -46,24 +50,49 @@ class Combustion::Databases::MySQL < Combustion::Databases::Base
46
50
  end
47
51
 
48
52
  def drop
49
- connection.drop_database configuration['database']
53
+ connection.drop_database configuration["database"]
50
54
  end
51
55
 
52
56
  def error_class
53
- if configuration['adapter'] =~ /jdbc/
54
- #FIXME After Jdbcmysql gives this class
55
- require 'active_record/railties/jdbcmysql_error'
56
- error_class = ArJdbcMySQL::Error
57
+ if configuration["adapter"][/jdbc/]
58
+ # FIXME: After Jdbcmysql gives this class
59
+ require "active_record/railties/jdbcmysql_error"
60
+ ArJdbcMySQL::Error
61
+ elsif config["adapter"][/mysql2/] && defined?(Mysql2)
62
+ Mysql2::Error
57
63
  else
58
- error_class = config['adapter'] =~ /mysql2/ && defined?(Mysql2) ? Mysql2::Error : Mysql::Error
64
+ Mysql::Error
59
65
  end
60
66
  end
61
67
 
62
68
  def grant_statement
63
69
  <<-SQL
64
- GRANT ALL PRIVILEGES ON #{configuration['database']}.*
65
- TO '#{configuration['username']}'@'localhost'
66
- IDENTIFIED BY '#{configuration['password']}' WITH GRANT OPTION;
70
+ GRANT ALL PRIVILEGES ON #{configuration["database"]}.*
71
+ TO '#{configuration["username"]}'@'localhost'
72
+ IDENTIFIED BY '#{configuration["password"]}' WITH GRANT OPTION;
67
73
  SQL
68
74
  end
75
+
76
+ def request_password(error)
77
+ print <<-TXT.strip
78
+ #{error.error}.
79
+ Please provide the root password for your mysql installation
80
+ >
81
+ TXT
82
+
83
+ $stdin.gets.strip
84
+ end
85
+
86
+ def rescue_create_from(error)
87
+ if error.errno == ACCESS_DENIED_ERROR
88
+ create_as_root(error)
89
+ return
90
+ end
91
+
92
+ $stderr.puts <<-TXT
93
+ #{error.error}
94
+ Couldn't create database for #{config.inspect}, charset: #{charset}, collation: #{collation}
95
+ #{charset_error}
96
+ TXT
97
+ end
69
98
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Combustion::Databases::Oracle < Combustion::Databases::Base
2
4
  def reset
3
5
  establish_connection :test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Combustion::Databases::PostgreSQL < Combustion::Databases::Base
2
4
  def reset
3
5
  base.clear_active_connections!
@@ -10,31 +12,30 @@ class Combustion::Databases::PostgreSQL < Combustion::Databases::Base
10
12
 
11
13
  def create
12
14
  connection.create_database(
13
- configuration['database'],
14
- configuration.merge('encoding' => encoding)
15
+ configuration["database"],
16
+ configuration.merge("encoding" => encoding)
15
17
  )
16
-
17
- rescue Exception => error
18
- $stderr.puts error, *(error.backtrace)
18
+ rescue StandardError => error
19
+ $stderr.puts error, *error.backtrace
19
20
  $stderr.puts "Couldn't create database for #{configuration.inspect}"
20
21
  end
21
22
 
22
23
  def drop
23
- connection.drop_database(configuration['database'])
24
+ connection.drop_database(configuration["database"])
24
25
  end
25
26
 
26
27
  def encoding
27
- configuration['encoding'] || ENV['CHARSET'] || 'utf8'
28
+ configuration["encoding"] || ENV["CHARSET"] || "utf8"
28
29
  end
29
30
 
30
31
  def postgres_configuration
31
32
  configuration.merge(
32
- 'database' => 'postgres',
33
- 'schema_search_path' => schema_search_path
33
+ "database" => "postgres",
34
+ "schema_search_path" => schema_search_path
34
35
  )
35
36
  end
36
37
 
37
38
  def schema_search_path
38
- configuration['adapter'][/postgis/] ? 'public, postgis' : 'public'
39
+ configuration["adapter"][/postgis/] ? "public, postgis" : "public"
39
40
  end
40
41
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Combustion::Databases::SQLServer < Combustion::Databases::Base
2
4
  def reset
3
- establish_connection configuration.merge('database' => 'master')
4
- connection.recreate_database! configuration['database']
5
+ establish_connection configuration.merge("database" => "master")
6
+ connection.recreate_database! configuration["database"]
5
7
  end
6
8
  end
@@ -1,19 +1,21 @@
1
- require 'fileutils'
2
- require 'pathname'
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "pathname"
3
5
 
4
6
  class Combustion::Databases::SQLite < Combustion::Databases::Base
5
7
  private
6
8
 
7
9
  def create
8
10
  if exists?
9
- $stderr.puts "#{config['database']} already exists"
11
+ $stderr.puts "#{config["database"]} already exists"
10
12
  return
11
13
  end
12
14
 
13
15
  establish_connection configuration
14
16
  connection
15
- rescue Exception => error
16
- $stderr.puts error, *(error.backtrace)
17
+ rescue StandardError => error
18
+ $stderr.puts error, *error.backtrace
17
19
  $stderr.puts "Couldn't create database for #{configuration.inspect}"
18
20
  end
19
21
 
@@ -30,6 +32,6 @@ class Combustion::Databases::SQLite < Combustion::Databases::Base
30
32
  end
31
33
 
32
34
  def path
33
- @path ||= Pathname.new configuration['database']
35
+ @path ||= Pathname.new configuration["database"]
34
36
  end
35
37
  end
@@ -1,29 +1,31 @@
1
- require 'thor/group'
1
+ # frozen_string_literal: true
2
+
3
+ require "thor/group"
2
4
 
3
5
  module Combustion
4
6
  class Generator < Thor::Group
5
7
  include Thor::Actions
6
8
 
7
9
  def self.source_root
8
- File.expand_path File.join(File.dirname(__FILE__), '..', '..')
10
+ File.expand_path File.join(File.dirname(__FILE__), "..", "..")
9
11
  end
10
12
 
11
13
  def create_directories
12
- empty_directory 'spec/internal'
13
- empty_directory 'spec/internal/config'
14
- empty_directory 'spec/internal/db'
15
- empty_directory 'spec/internal/log'
16
- empty_directory 'spec/internal/public'
14
+ empty_directory "spec/internal"
15
+ empty_directory "spec/internal/config"
16
+ empty_directory "spec/internal/db"
17
+ empty_directory "spec/internal/log"
18
+ empty_directory "spec/internal/public"
17
19
  end
18
20
 
19
21
  def create_files
20
- template 'templates/routes.rb', 'spec/internal/config/routes.rb'
21
- template 'templates/database.yml', 'spec/internal/config/database.yml'
22
- template 'templates/schema.rb', 'spec/internal/db/schema.rb'
23
- template 'templates/config.ru', 'config.ru'
24
- create_file 'spec/internal/public/favicon.ico'
25
- create_file 'spec/internal/log/.gitignore' do
26
- '*.log'
22
+ template "templates/routes.rb", "spec/internal/config/routes.rb"
23
+ template "templates/database.yml", "spec/internal/config/database.yml"
24
+ template "templates/schema.rb", "spec/internal/db/schema.rb"
25
+ template "templates/config.ru", "config.ru"
26
+ create_file "spec/internal/public/favicon.ico"
27
+ create_file "spec/internal/log/.gitignore" do
28
+ "*.log"
27
29
  end
28
30
  end
29
31
  end
@@ -1,28 +1,32 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Combustion
2
4
  describe Database do
3
5
  before(:all) do
4
- Dir.chdir(File.expand_path('../dummy', __FILE__)) do
6
+ Dir.chdir(File.expand_path("../dummy", __FILE__)) do
5
7
  Combustion.initialize! :active_record
6
8
  end
7
9
  end
8
10
 
9
- it 'creates dummy table from migration in base database' do
10
- expect(Model.connection.table_exists?('dummy_table')).to eq true
11
- expect(Model.connection.table_exists?('dummy_in_another_db')).to eq false
11
+ it "creates dummy table from migration in base database" do
12
+ expect(Model.connection.table_exists?("dummy_table")).to eq true
13
+ expect(Model.connection.table_exists?("dummy_in_another_db")).to eq false
12
14
  end
13
15
 
14
- it 'creates another dummy table from another database' do
15
- expect(ModelInAnotherDb.connection.table_exists?('dummy_table')).to eq false
16
- expect(ModelInAnotherDb.connection.table_exists?('dummy_in_another_db')).to eq true
17
-
16
+ it "creates another dummy table from another database" do
17
+ expect(ModelInAnotherDb.connection.table_exists?("dummy_table")).
18
+ to eq false
19
+ expect(ModelInAnotherDb.connection.table_exists?("dummy_in_another_db")).
20
+ to eq true
18
21
  end
19
22
 
20
- it 'returns test databse for model with default connection' do
21
- expect(Model.connection_config[:database]).to match /test/
23
+ it "returns test databse for model with default connection" do
24
+ expect(Model.connection_config[:database]).to match(/test/)
22
25
  end
23
26
 
24
- it 'returns test_another databse for model with connection to second database' do
25
- expect(ModelInAnotherDb.connection_config[:database]).to match /test_another/
27
+ it "returns test_another for model with connection to second database" do
28
+ expect(ModelInAnotherDb.connection_config[:database]).
29
+ to match(/test_another/)
26
30
  end
27
31
  end
28
32
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  superclass = ActiveRecord::VERSION::MAJOR < 5 ?
2
4
  ActiveRecord::Migration : ActiveRecord::Migration[4.2]
3
5
  class CreateDummyTestTable < superclass
4
6
  def change
5
- create_table 'dummy_table'
7
+ create_table "dummy_table"
6
8
  end
7
9
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  superclass = ActiveRecord::VERSION::MAJOR < 5 ?
2
4
  ActiveRecord::Migration : ActiveRecord::Migration[4.2]
3
5
  class CreateDummyTestTableInAnotherDb < superclass
4
6
  def change
5
- create_table 'dummy_in_another_db'
7
+ create_table "dummy_in_another_db"
6
8
  end
7
9
 
8
10
  def connection
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dummy
2
4
  class Engine < ::Rails::Engine
3
- initializer :dummy, before: :load_init_rb do |app|
5
+ initializer :dummy, :before => :load_init_rb do |app|
4
6
  app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded)
5
7
  end
6
8
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Model < ActiveRecord::Base
2
- self.table_name = 'dummy_table'
4
+ self.table_name = "dummy_table"
3
5
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ModelInAnotherDb < ActiveRecord::Base
2
- self.table_name = 'dummy_in_another_db'
4
+ self.table_name = "dummy_in_another_db"
3
5
 
4
6
  establish_connection :test_another
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.routes.draw do
2
4
  #
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ActiveRecord::Schema.define do
2
4
  #
3
5
  end
@@ -1,10 +1,11 @@
1
- # coding: utf-8
2
- require 'bundler/setup'
3
- require 'combustion'
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "combustion"
4
5
 
5
6
  if Rails::VERSION::STRING.to_f < 4.1
6
- require 'active_record'
7
- require 'active_record/connection_adapters/mysql2_adapter'
7
+ require "active_record"
8
+ require "active_record/connection_adapters/mysql2_adapter"
8
9
 
9
10
  class ActiveRecord::ConnectionAdapters::Mysql2Adapter
10
11
  NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
@@ -1,5 +1,7 @@
1
- require 'rubygems'
2
- require 'bundler'
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "bundler"
3
5
 
4
6
  Bundler.require :default, :development
5
7
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.routes.draw do
2
4
  #
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ActiveRecord::Schema.define do
2
4
  #
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: combustion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-20 00:00:00.000000000 Z
11
+ date: 2018-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.50.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.50.0
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: sqlite3
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -146,6 +160,7 @@ extra_rdoc_files: []
146
160
  files:
147
161
  - ".gitignore"
148
162
  - ".rspec"
163
+ - ".rubocop.yml"
149
164
  - ".travis.yml"
150
165
  - Appraisals
151
166
  - Gemfile
@@ -153,7 +168,6 @@ files:
153
168
  - LICENCE
154
169
  - README.md
155
170
  - Rakefile
156
- - bin/literals
157
171
  - combustion.gemspec
158
172
  - exe/combust
159
173
  - gemfiles/rails_3.1.gemfile
@@ -163,9 +177,13 @@ files:
163
177
  - gemfiles/rails_4.2.gemfile
164
178
  - gemfiles/rails_5.0.gemfile
165
179
  - gemfiles/rails_5.1.gemfile
180
+ - gemfiles/rails_5.2.gemfile
166
181
  - gemfiles/rails_5_0.gemfile
167
182
  - lib/combustion.rb
168
183
  - lib/combustion/application.rb
184
+ - lib/combustion/configurations/action_controller.rb
185
+ - lib/combustion/configurations/action_mailer.rb
186
+ - lib/combustion/configurations/active_record.rb
169
187
  - lib/combustion/database.rb
170
188
  - lib/combustion/database/load_schema.rb
171
189
  - lib/combustion/database/migrate.rb
@@ -213,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
231
  version: '0'
214
232
  requirements: []
215
233
  rubyforge_project: combustion
216
- rubygems_version: 2.6.11
234
+ rubygems_version: 2.7.3
217
235
  signing_key:
218
236
  specification_version: 4
219
237
  summary: Elegant Rails Engine Testing
@@ -1,9 +0,0 @@
1
- if (ruby -e "exit RUBY_VERSION.to_f >= 2.4")
2
- then
3
- echo "Automatic frozen string literals are supported"
4
- gem install pragmater -v 4.0.0
5
- pragmater --add lib --comments "# frozen_string_literal: true" --whitelist "**/*.rb"
6
- pragmater --add spec --comments "# frozen_string_literal: true" --whitelist "**/*.rb"
7
- else
8
- echo "Automatic frozen string literals are not supported."
9
- fi