potassium 5.1.4 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -1
  3. data/CHANGELOG.md +17 -0
  4. data/README.md +1 -1
  5. data/circle.yml +1 -1
  6. data/lib/potassium/assets/.circleci/config.yml +20 -0
  7. data/lib/potassium/assets/Dockerfile.ci +1 -1
  8. data/lib/potassium/assets/README.yml +3 -0
  9. data/lib/potassium/assets/aws.rb +1 -0
  10. data/lib/potassium/assets/config/mailer.rb.erb +10 -0
  11. data/lib/potassium/assets/config/storage.yml +12 -0
  12. data/lib/potassium/assets/docker-compose.ci.yml +11 -9
  13. data/lib/potassium/assets/seeds/admin_data_loader.rb +3 -3
  14. data/lib/potassium/assets/seeds/fake_data_loader.rb +3 -3
  15. data/lib/potassium/assets/testing/paperclip.rb +1 -1
  16. data/lib/potassium/assets/testing/rails_helper.rb +1 -1
  17. data/lib/potassium/cli_options.rb +8 -0
  18. data/lib/potassium/helpers/docker-helpers.rb +3 -3
  19. data/lib/potassium/helpers/readme-helpers.rb +8 -8
  20. data/lib/potassium/recipes/active_storage.rb +40 -0
  21. data/lib/potassium/recipes/admin.rb +19 -19
  22. data/lib/potassium/recipes/aws_sdk.rb +3 -1
  23. data/lib/potassium/recipes/ci.rb +28 -29
  24. data/lib/potassium/recipes/database.rb +2 -1
  25. data/lib/potassium/recipes/draper.rb +1 -1
  26. data/lib/potassium/recipes/env.rb +6 -6
  27. data/lib/potassium/recipes/i18n.rb +2 -3
  28. data/lib/potassium/recipes/paperclip.rb +11 -11
  29. data/lib/potassium/recipes/puma.rb +1 -6
  30. data/lib/potassium/recipes/rack_cors.rb +17 -12
  31. data/lib/potassium/recipes/rails.rb +13 -0
  32. data/lib/potassium/recipes/ruby.rb +1 -1
  33. data/lib/potassium/recipes/testing.rb +1 -1
  34. data/lib/potassium/templates/application.rb +2 -0
  35. data/lib/potassium/version.rb +3 -3
  36. data/spec/features/active_storage_spec.rb +30 -0
  37. data/spec/features/database_spec.rb +14 -0
  38. data/spec/features/new_project_spec.rb +9 -1
  39. metadata +13 -6
  40. data/lib/potassium/assets/circle.yml +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8e3229a27d5e3432c237879deb06753f6d6eba7f
4
- data.tar.gz: 8b2ee90efb39056ecbdafd7f3e5acfbce40502a9
2
+ SHA256:
3
+ metadata.gz: 586c6642ed62cba7a9a9aadba36fc53ea14f3dda6bd182c1e4e66e5818a4c19f
4
+ data.tar.gz: 8d12fa2fbf200d8664945c8187c4d257e3a5b5285057032a95eacb03ad088be4
5
5
  SHA512:
6
- metadata.gz: 420d0c10911f3c4fa6da1be9e67e9bfb894a6a16431a1fc482b9781bc943013cea3a319dac589e3721af45c770a50edb6196205b96e7555fc3158f09cd1c49d1
7
- data.tar.gz: d4759c06b04f116e0ff83df017df9c3f03426597e50127049658a50d851bb4bacea7c46b4c7e6c1dec15f5ce7655e8e4ca8eb2fcd64887e1639e11615dbd8016
6
+ metadata.gz: 60726b985ce4c24e7be3f92ecb9f8f9532b171b995768eef00e3afc8aa4ab6480d7f39a48efcb4a2b4da0d48154caa2f66a5f4eea5cf9269569c5955a7155fa3
7
+ data.tar.gz: 8bb3ee2bac542101adc27bc41a5ea6823cbb6a94a0a76bbcff731a3139c8d050f6b7d3d8ca8ba7b1715bb64b269999c0e393d5d712e278f745ccbbadfad24479
@@ -1 +1 @@
1
- 2.4
1
+ 2.5
@@ -2,6 +2,23 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.2.0
6
+
7
+ Features:
8
+ - Add Active Storage recipe
9
+
10
+ Changes:
11
+ - Update AWS to 3
12
+ - Update Rails to 5.2.1
13
+ - Update `ActiveAdmin` to 1.3.0
14
+ - Update ruby to 2.5
15
+ - Update to circleci 2
16
+
17
+ Fix:
18
+ - Update `draper` to 3.0.1
19
+ - `FactoryGirl` update to `FactoryBot`
20
+ - `pg` gem has now explicit version: `~> 0.21`
21
+
5
22
  ## 5.1.4
6
23
 
7
24
  Changes:
data/README.md CHANGED
@@ -42,7 +42,7 @@ Potassium Rails apps includes the following gems and technologies:
42
42
  - [EditorConfig](http://editorconfig.org) for keeping all our editor configurations the same.
43
43
  - [pry](http://pryrepl.org) and [pry-byebug](https://github.com/deivid-rodriguez/pry-byebug) for a less painful debugging experience.
44
44
  - [RSpec](http://rspec.info) for unit and integration testing.
45
- - [FactoryGirl](https://github.com/thoughtbot/factory_girl) for test factories.
45
+ - [FactoryBot](https://github.com/thoughtbot/factory_bot] for test factories.
46
46
  - [Guard](http://guardgem.org) for continuous testing and other watch-related tasks.
47
47
  - [AWS-SDK](https://github.com/aws/aws-sdk-ruby) for file uploads, sdks, etc and because we use AWS.
48
48
  - [Puma](https://github.com/puma/puma) to serve HTTP requests
data/circle.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  machine:
2
2
  ruby:
3
- version: 2.4.1
3
+ version: 2.5.1
4
4
  services:
5
5
  - docker
6
6
  post:
@@ -0,0 +1,20 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ working_directory: ~/app
5
+
6
+ docker:
7
+ - image: platanus/compose:1.22.0
8
+
9
+ steps:
10
+ - checkout
11
+ - setup_remote_docker
12
+
13
+ - run: docker info
14
+ - run: docker-compose -f docker-compose.ci.yml pull
15
+ - run: docker-compose -f docker-compose.ci.yml build test
16
+ - run: bin/cibuild services
17
+ - run: bin/cibuild deps
18
+
19
+ - run: bin/cibuild db
20
+ - run: bin/cibuild tests
@@ -1,4 +1,4 @@
1
- FROM platanus/ruby:2.4
1
+ FROM platanus/ruby:2.5
2
2
 
3
3
  RUN mkdir /app
4
4
  WORKDIR /app
@@ -86,6 +86,9 @@ readme:
86
86
  paperclip:
87
87
  title: "Uploads"
88
88
  body: "For managing uploads, this project uses [Paperclip](https://github.com/thoughtbot/paperclip), a gem made by the awesome [Thoughbot](https://thoughtbot.com/) team."
89
+ storage:
90
+ title: "Active Storage"
91
+ body: "For managing uploads, this project uses [Active Storage](https://github.com/rails/rails/tree/master/activestorage)."
89
92
  pundit:
90
93
  title: "Authorization"
91
94
  body: "For defining which parts of the system each user has access to, we have chosen to include the [Pundit](https://github.com/elabs/pundit) gem, by [Elabs](http://elabs.se/)."
@@ -0,0 +1 @@
1
+ Aws::VERSION = Gem.loaded_specs["aws-sdk"].version
@@ -16,3 +16,13 @@ if ENV["EMAIL_RECIPIENTS"].present?
16
16
  subject_prefix: "[<%= get(:heroku) ? '#{Heroku.stage.upcase}' : '#{Rails.env}' %>]"
17
17
  )
18
18
  end
19
+ <% if get(:mailer_delivery_method) == :aws_sdk -%>
20
+ creds = Aws::Credentials.new(
21
+ ENV['AWS_ACCESS_KEY_ID'],
22
+ ENV['AWS_SECRET_ACCESS_KEY']
23
+ )
24
+
25
+ Aws::Rails.add_action_mailer_delivery_method(
26
+ :aws_sdk, credentials: creds, region: ENV.fetch('AWS_REGION', 'us-east-1')
27
+ )
28
+ <% end -%>
@@ -0,0 +1,12 @@
1
+ local:
2
+ service: Disk
3
+ root: <%= Rails.root.join("storage") %>
4
+
5
+ test:
6
+ service: Disk
7
+ root: <%= Rails.root.join("tmp/storage") %>
8
+
9
+ amazon:
10
+ service: S3
11
+ region: <%= ENV['AWS_REGION'] %>
12
+ bucket: <%= ENV['S3_BUCKET'] %>
@@ -1,9 +1,11 @@
1
- test:
2
- build: .
3
- dockerfile: Dockerfile.ci
4
- working_dir: '/app'
5
- volumes:
6
- - ./vendor/bundle:/usr/local/bundle
7
- - $CIRCLE_TEST_REPORTS/rspec:$HOME/.rspec_reports
8
- environment:
9
- RACK_ENV: test
1
+ version: '3.4'
2
+
3
+ services:
4
+ test:
5
+ build:
6
+ context: "."
7
+ dockerfile: Dockerfile.ci
8
+ volumes:
9
+ - "./vendor/bundle:/usr/local/bundle"
10
+ environment:
11
+ RACK_ENV: test
@@ -1,11 +1,11 @@
1
1
  # Put, inside the load method, the necessary code to generate data with DEVELOPMENT PURPOSES.
2
- # Whenever you can, use FactoryGirl's methods to keep this code "self updated".
2
+ # Whenever you can, use FactoryBot's methods to keep this code "self updated".
3
3
  #
4
4
  # For Example:
5
5
  #
6
6
  # Having a country factory in /spec/factories/countries.rb
7
7
  #
8
- # FactoryGirl.define do
8
+ # FactoryBot.define do
9
9
  # factory :country do
10
10
  # name "Chile"
11
11
  # locale "es-CL"
@@ -25,7 +25,7 @@
25
25
  Faker::Config.locale = I18n.locale
26
26
 
27
27
  module FakeDataLoader
28
- extend FactoryGirl::Syntax::Methods
28
+ extend FactoryBot::Syntax::Methods
29
29
 
30
30
  def self.load
31
31
  load_admin
@@ -1,11 +1,11 @@
1
1
  # Put, inside the load method, the necessary code to generate data with DEVELOPMENT PURPOSES.
2
- # Whenever you can, use FactoryGirl's methods to keep this code "self updated".
2
+ # Whenever you can, use FactoryBot's methods to keep this code "self updated".
3
3
  #
4
4
  # For Example:
5
5
  #
6
6
  # Having a country factory in /spec/factories/countries.rb
7
7
  #
8
- # FactoryGirl.define do
8
+ # FactoryBot.define do
9
9
  # factory :country do
10
10
  # name "Chile"
11
11
  # locale "es-CL"
@@ -25,7 +25,7 @@
25
25
  Faker::Config.locale = I18n.locale
26
26
 
27
27
  module FakeDataLoader
28
- extend FactoryGirl::Syntax::Methods
28
+ extend FactoryBot::Syntax::Methods
29
29
 
30
30
  def self.load
31
31
  # Put here the code to generate data with DEVELOPMENT PURPOSES.
@@ -46,7 +46,7 @@ end
46
46
  #
47
47
  # From your factories:
48
48
  #
49
- # FactoryGirl.define do
49
+ # FactoryBot.define do
50
50
  # factory :ticket do
51
51
  # attachment { fixture_asset("platanus.png", "image/png") }
52
52
  # end
@@ -47,7 +47,7 @@ RSpec.configure do |config|
47
47
  # https://relishapp.com/rspec/rspec-rails/docs
48
48
  config.infer_spec_type_from_file_location!
49
49
 
50
- config.include FactoryGirl::Syntax::Methods
50
+ config.include FactoryBot::Syntax::Methods
51
51
  end
52
52
 
53
53
  Shoulda::Matchers.configure do |config|
@@ -74,6 +74,14 @@ module Potassium::CliOptions # rubocop:disable Metrics/ModuleLength
74
74
  default_value: "none",
75
75
  default_test_value: false
76
76
  },
77
+ {
78
+ type: :switch,
79
+ name: "active_storage",
80
+ desc: "Whether to include Active Storage as dependency",
81
+ negatable: true,
82
+ default_value: "none",
83
+ default_test_value: false
84
+ },
77
85
  {
78
86
  type: :switch,
79
87
  name: "heroku",
@@ -5,7 +5,7 @@ class DockerHelpers
5
5
  end
6
6
 
7
7
  def add_link(target_service, linked_service)
8
- service = @compose[target_service]
8
+ service = @compose['services'][target_service]
9
9
  unless service['links'].is_a? Array
10
10
  service['links'] = []
11
11
  end
@@ -14,7 +14,7 @@ class DockerHelpers
14
14
  end
15
15
 
16
16
  def add_env(target_service, variable_key, variable_value)
17
- service = @compose[target_service]
17
+ service = @compose['services'][target_service]
18
18
  unless service['environment'].is_a? Hash
19
19
  service['environment'] = {}
20
20
  end
@@ -25,7 +25,7 @@ class DockerHelpers
25
25
  def add_service(name, definition)
26
26
  service = {}
27
27
  service[name] = YAML.load(definition)
28
- @compose.merge!(service)
28
+ @compose['services'].merge!(service)
29
29
  save
30
30
  end
31
31
 
@@ -4,11 +4,11 @@ module ReadmeHelpers
4
4
  add_readme_header(header, iterpolation_values)
5
5
 
6
6
  insert_into_readme(section_data[:header_title]) do
7
- <<-HERE.gsub(/^ {6}/, '')
7
+ <<~HERE
8
8
 
9
- ### #{section_data[:title]}
9
+ ### #{section_data[:title]}
10
10
 
11
- #{section_data[:body]}
11
+ #{section_data[:body]}
12
12
  HERE
13
13
  end
14
14
  end
@@ -19,18 +19,18 @@ module ReadmeHelpers
19
19
 
20
20
  if header_data[:body]
21
21
  insert_into_readme do
22
- <<-HERE.gsub(/^ {8}/, '')
22
+ <<~HERE
23
23
 
24
- ## #{header_data[:title]}
24
+ ## #{header_data[:title]}
25
25
 
26
- #{header_data[:body]}
26
+ #{header_data[:body]}
27
27
  HERE
28
28
  end
29
29
  else
30
30
  insert_into_readme do
31
- <<-HERE.gsub(/^ {8}/, '')
31
+ <<~HERE
32
32
 
33
- ## #{header_data[:title]}
33
+ ## #{header_data[:title]}
34
34
  HERE
35
35
  end
36
36
  end
@@ -0,0 +1,40 @@
1
+ class Recipes::ActiveStorage < Rails::AppBuilder
2
+ def ask
3
+ active_storage = answer(:active_storage) do
4
+ Ask.confirm("Do you want to use ActiveStorage for uploads?")
5
+ end
6
+
7
+ set(:active_storage, active_storage)
8
+ end
9
+
10
+ def create
11
+ return unless selected?(:active_storage)
12
+ add_active_storage
13
+ end
14
+
15
+ def install
16
+ add_active_storage
17
+ end
18
+
19
+ def installed?
20
+ file_exist?('config/storage.yml')
21
+ end
22
+
23
+ private
24
+
25
+ def add_active_storage
26
+ after(:gem_install) { run("bundle exec rails active_storage:install") }
27
+
28
+ add_readme_section :internal_dependencies, :storage
29
+
30
+ copy_file("../assets/config/storage.yml", "config/storage.yml", force: true)
31
+
32
+ append_to_file '.env.development', "AWS_REGION=\n"
33
+ append_to_file '.env.development', "S3_BUCKET=\n"
34
+
35
+ raise_delivery_errors_regexp = /config.active_storage.service = :local\n/
36
+ gsub_file 'config/environments/production.rb', raise_delivery_errors_regexp do
37
+ "config.active_storage.service = :amazon"
38
+ end
39
+ end
40
+ end
@@ -32,7 +32,7 @@ class Recipes::Admin < Rails::AppBuilder
32
32
  private
33
33
 
34
34
  def add_active_admin
35
- gather_gem 'activeadmin', github: 'activeadmin'
35
+ gather_gem 'activeadmin', '~> 1.3.0'
36
36
  gather_gem 'activeadmin_addons'
37
37
  gather_gem 'active_skin'
38
38
 
@@ -41,16 +41,16 @@ class Recipes::Admin < Rails::AppBuilder
41
41
  line = "ActiveAdmin.setup do |config|"
42
42
  initializer = "config/initializers/active_admin.rb"
43
43
  gsub_file initializer, /(#{Regexp.escape(line)})/mi do |_match|
44
- <<-HERE.gsub(/^ {11}/, '')
45
- class CustomFooter < ActiveAdmin::Component
46
- def build _arg
47
- super(id: "footer")
48
- para "Powered by Platanus"
49
- end
50
- end\n
51
- ActiveAdmin.setup do |config|
52
- config.view_factory.footer = CustomFooter
53
- HERE
44
+ <<~HERE
45
+ class CustomFooter < ActiveAdmin::Component
46
+ def build _arg
47
+ super(id: "footer")
48
+ para "Powered by Platanus"
49
+ end
50
+ end\n
51
+ ActiveAdmin.setup do |config|
52
+ config.view_factory.footer = CustomFooter
53
+ HERE
54
54
  end
55
55
 
56
56
  line = "@import \"active_admin/base\";"
@@ -58,15 +58,15 @@ class Recipes::Admin < Rails::AppBuilder
58
58
  style = File.exist?(style) ? style : "app/assets/stylesheets/active_admin.scss"
59
59
 
60
60
  gsub_file style, /(#{Regexp.escape(line)})/mi do |_match|
61
- <<-HERE.gsub(/^ {11}/, '')
62
- #{line}
63
- $skinActiveColor: #001CEE;
64
- $skinHeaderBck: #002744;
65
- $panelHeaderBck: #002744;
66
- //$skinLogo: $skinHeaderBck image-url("logo_admin.png") no-repeat center center;
61
+ <<~HERE
62
+ #{line}
63
+ $skinActiveColor: #001CEE;
64
+ $skinHeaderBck: #002744;
65
+ $panelHeaderBck: #002744;
66
+ //$skinLogo: $skinHeaderBck image-url("logo_admin.png") no-repeat center center;
67
67
 
68
- @import "active_skin";
69
- HERE
68
+ @import "active_skin";
69
+ HERE
70
70
  end
71
71
 
72
72
  generate "activeadmin_addons:install"
@@ -1,5 +1,7 @@
1
1
  class Recipes::AwsSdk < Rails::AppBuilder
2
2
  def create
3
- gather_gem('aws-sdk', '~> 2.5')
3
+ gather_gem('aws-sdk', '~> 3')
4
+
5
+ template("../assets/aws.rb", "config/initializers/aws.rb", force: true)
4
6
  end
5
7
  end
@@ -1,49 +1,48 @@
1
1
  class Recipes::Ci < Rails::AppBuilder
2
2
  def create
3
- if get(:heroku)
4
- copy_file '../assets/Dockerfile.ci', 'Dockerfile.ci'
5
- copy_file '../assets/circle.yml', 'circle.yml'
3
+ copy_file '../assets/Dockerfile.ci', 'Dockerfile.ci'
4
+ copy_file '../assets/.circleci/config.yml', '.circleci/config.yml'
6
5
 
7
- template '../assets/bin/cibuild.erb', 'bin/cibuild'
8
- run "chmod a+x bin/cibuild"
6
+ template '../assets/bin/cibuild.erb', 'bin/cibuild'
7
+ run "chmod a+x bin/cibuild"
9
8
 
10
- copy_file '../assets/docker-compose.ci.yml', 'docker-compose.ci.yml'
9
+ copy_file '../assets/docker-compose.ci.yml', 'docker-compose.ci.yml'
11
10
 
12
- gather_gems(:test) do
13
- gather_gem 'rspec_junit_formatter', '0.2.2'
14
- end
11
+ gather_gems(:test) do
12
+ gather_gem 'rspec_junit_formatter', '0.2.2'
13
+ end
15
14
 
16
- compose = DockerHelpers.new('docker-compose.ci.yml')
15
+ compose = DockerHelpers.new('docker-compose.ci.yml')
17
16
 
18
- if selected?(:database, :mysql)
19
- service = <<-YAML
17
+ if selected?(:database, :mysql)
18
+ srv =
19
+ <<~YAML
20
20
  image: "mysql:5.6.23"
21
21
  environment:
22
22
  MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
23
23
  YAML
24
- compose.add_service("mysql", service)
25
- compose.add_link('test', 'mysql')
26
- compose.add_env('test', 'MYSQL_HOST', 'mysql')
27
- compose.add_env('test', 'MYSQL_PORT', '3306')
28
-
29
- elsif selected?(:database, :postgresql)
30
- service = <<-YAML
24
+ compose.add_service("mysql", srv)
25
+ compose.add_link('test', 'mysql')
26
+ compose.add_env('test', 'MYSQL_HOST', 'mysql')
27
+ compose.add_env('test', 'MYSQL_PORT', '3306')
28
+
29
+ elsif selected?(:database, :postgresql)
30
+ srv =
31
+ <<~YAML
31
32
  image: "postgres:9.4.5"
32
33
  environment:
33
34
  POSTGRES_USER: postgres
34
35
  POSTGRES_PASSWORD: ''
35
36
  YAML
36
- compose.add_service("postgresql", service)
37
- compose.add_link('test', 'postgresql')
38
- compose.add_env('test', 'POSTGRESQL_USER', 'postgres')
39
- compose.add_env('test', 'POSTGRESQL_HOST', 'postgresql')
40
- compose.add_env('test', 'POSTGRESQL_PORT', '5432')
41
- end
42
-
43
- add_readme_header :ci
37
+ compose.add_service("postgresql", srv)
38
+ compose.add_link('test', 'postgresql')
39
+ compose.add_env('test', 'POSTGRESQL_USER', 'postgres')
40
+ compose.add_env('test', 'POSTGRESQL_HOST', 'postgresql')
41
+ compose.add_env('test', 'POSTGRESQL_PORT', '5432')
44
42
  end
45
43
 
46
- uglifier = " config.assets.js_compressor = :uglifier\n"
47
- insert_into_file 'config/environments/test.rb', uglifier, after: "configure do\n"
44
+ add_readme_header :ci
45
+
46
+ application 'config.assets.js_compressor = :uglifier', env: 'test'
48
47
  end
49
48
  end
@@ -30,7 +30,7 @@ class Recipes::Database < Rails::AppBuilder
30
30
 
31
31
  def databases(database)
32
32
  databases = {
33
- postgresql: { name: 'postgresql', gem_name: 'pg', relational: true },
33
+ postgresql: { name: 'postgresql', gem_name: 'pg', version: '~> 0.21', relational: true },
34
34
  mysql: { name: 'mysql', gem_name: 'mysql2', version: '~> 0.3.18', relational: true }
35
35
  }
36
36
  databases[database]
@@ -40,6 +40,7 @@ class Recipes::Database < Rails::AppBuilder
40
40
  remove_file 'config/database.yml'
41
41
  template "../assets/config/database_#{db[:name]}.yml.erb", 'config/database.yml'
42
42
  discard_gem 'sqlite3'
43
+ gather_gem 'strong_migrations'
43
44
  if db[:version]
44
45
  gather_gem db[:gem_name], db[:version]
45
46
  else
@@ -21,7 +21,7 @@ class Recipes::Draper < Rails::AppBuilder
21
21
  end
22
22
 
23
23
  def add_draper
24
- gather_gem 'draper', '3.0.0.pre1'
24
+ gather_gem 'draper', '3.0.1'
25
25
  add_readme_section :internal_dependencies, :draper
26
26
  create_file 'app/decorators/.keep'
27
27
  end
@@ -9,11 +9,11 @@ class Recipes::Env < Rails::AppBuilder
9
9
  append_to_file '.gitignore', ".env\n"
10
10
 
11
11
  env_config =
12
- <<-RUBY.gsub(/^ {7}/, '')
13
- config.before_configuration do
14
- Dotenv.load(Dotenv::Railtie.root.join('.env.development'))
15
- end
16
- RUBY
17
- application env_config.strip, env: 'test'
12
+ <<~RUBY
13
+ config.before_configuration do
14
+ Dotenv.load(Dotenv::Railtie.root.join('.env.development'))
15
+ end
16
+ RUBY
17
+ application env_config, env: 'test'
18
18
  end
19
19
  end
@@ -19,8 +19,7 @@ class Recipes::I18n < Rails::AppBuilder
19
19
  template('../assets/es-CL.yml', 'config/locales/es-CL.yml')
20
20
  end
21
21
 
22
- gsub_file 'config/application.rb', /< Rails::Application/ do
23
- "< Rails::Application\n config.i18n.default_locale = '#{get(:lang)}'\n config.i18n.fallbacks = [:es, :en]\n"
24
- end
22
+ application("config.i18n.default_locale = '#{get(:lang)}'")
23
+ application("config.i18n.fallbacks = [:es, :en]")
25
24
  end
26
25
  end
@@ -24,17 +24,17 @@ class Recipes::Paperclip < Rails::AppBuilder
24
24
  def add_paperclip
25
25
  gather_gem 'paperclip', '~> 5.0'
26
26
  paperclip_config =
27
- <<-RUBY.gsub(/^ {7}/, '')
28
- config.paperclip_defaults = {
29
- storage: :s3,
30
- s3_protocol: 'https'
31
- s3_region: ENV.fetch('AWS_REGION', 'us-east-1'),
32
- s3_credentials: {
33
- bucket: ENV['S3_BUCKET']
34
- }
35
- }
36
- RUBY
37
- application paperclip_config.strip, env: 'production'
27
+ <<~RUBY
28
+ config.paperclip_defaults = {
29
+ storage: :s3,
30
+ s3_protocol: 'https',
31
+ s3_region: ENV.fetch('AWS_REGION', 'us-east-1'),
32
+ s3_credentials: {
33
+ bucket: ENV['S3_BUCKET']
34
+ }
35
+ }
36
+ RUBY
37
+ application paperclip_config, env: 'production'
38
38
  append_to_file '.env.development', "S3_BUCKET=\n"
39
39
  append_to_file '.gitignore', "/public/system/*\n"
40
40
  add_readme_section :internal_dependencies, :paperclip
@@ -7,11 +7,6 @@ class Recipes::Puma < Rails::AppBuilder
7
7
  copy_file '../assets/config/puma.rb', 'config/puma.rb', force: true
8
8
 
9
9
  # Configure rack-timout
10
- rack_timeout_config =
11
- <<-RUBY.gsub(/^ {9}/, '')
12
- Rack::Timeout.timeout = (ENV["RACK_TIMEOUT"] || 10).to_i
13
- RUBY
14
-
15
- append_file "config/environments/production.rb", rack_timeout_config
10
+ application "Rack::Timeout.timeout = (ENV[\"RACK_TIMEOUT\"] || 10).to_i", env: "production"
16
11
  end
17
12
  end
@@ -1,21 +1,26 @@
1
1
  class Recipes::RackCors < Rails::AppBuilder
2
+ def install
3
+ create
4
+ end
5
+
2
6
  def create
3
7
  gather_gem('rack-cors', '~> 0.4.0')
4
8
  after(:gem_install) do
5
9
  rack_cors_config =
6
- <<-RUBY.gsub(/^ {7}/, '')
7
- config.middleware.insert_before 0, Rack::Cors do
8
- allow do
9
- origins '*'
10
- resource '*',
11
- headers: :any,
12
- expose: ['X-Page', 'X-PageTotal'],
13
- methods: [:get, :post, :delete, :put, :options]
14
- end
15
- end
16
- RUBY
10
+ <<~RUBY
11
+ config.middleware.insert_before 0, Rack::Cors do
12
+ allow do
13
+ origins '*'
14
+ resource '*',
15
+ headers: :any,
16
+ expose: ['X-Page', 'X-PageTotal'],
17
+ methods: [:get, :post, :delete, :put, :options]
18
+ end
19
+ end
20
+
21
+ RUBY
17
22
 
18
- application rack_cors_config.strip
23
+ application rack_cors_config
19
24
  end
20
25
  end
21
26
  end
@@ -1,5 +1,18 @@
1
1
  class Recipes::Rails < Rails::AppBuilder
2
2
  def create
3
+ gather_gem("bootsnap", require: false)
4
+
3
5
  environment 'config.force_ssl = true', env: 'production'
6
+
7
+ line = "Rails.application.config.content_security_policy_nonce_generator = \
8
+ -> request { SecureRandom.base64(16) }"
9
+ initializer = "config/initializers/content_security_policy.rb"
10
+ gsub_file initializer, /(#{Regexp.escape(line)})/mi do |_match|
11
+ <<~HERE.chomp
12
+ # Rails.application.config.content_security_policy_nonce_generator = -> request do
13
+ # SecureRandom.base64(16)
14
+ # end
15
+ HERE
16
+ end
4
17
  end
5
18
  end
@@ -4,7 +4,7 @@ require 'semantic'
4
4
  class Recipes::Ruby < Rails::AppBuilder
5
5
  def create
6
6
  info "Using ruby version #{version_alias}"
7
- create_file '.ruby-version', version_alias
7
+ create_file '.ruby-version', version_alias, force: true
8
8
  end
9
9
 
10
10
  private
@@ -2,7 +2,7 @@ class Recipes::Testing < Rails::AppBuilder
2
2
  def create
3
3
  gather_gems(:development, :test) do
4
4
  gather_gem('rspec-rails')
5
- gather_gem('factory_girl_rails')
5
+ gather_gem('factory_bot_rails')
6
6
  gather_gem('faker')
7
7
  gather_gem('guard-rspec', require: false)
8
8
  gather_gem('rspec-nc', require: false)
@@ -30,6 +30,7 @@ run_action(:asking) do
30
30
  ask :i18n
31
31
  ask :api
32
32
  ask :draper
33
+ ask :active_storage
33
34
  ask :paperclip
34
35
  ask :heroku
35
36
  ask :github
@@ -67,6 +68,7 @@ run_action(:recipe_loading) do
67
68
  create :draper
68
69
  create :power_types
69
70
  create :rack_cors
71
+ create :active_storage
70
72
  create :paperclip
71
73
  create :tzinfo
72
74
  create :script
@@ -1,6 +1,6 @@
1
1
  module Potassium
2
- VERSION = "5.1.4"
3
- RUBY_VERSION = "2.4.1"
4
- RAILS_VERSION = "~> 5.1.3"
2
+ VERSION = "5.2.0"
3
+ RUBY_VERSION = "2.5.1"
4
+ RAILS_VERSION = "~> 5.2.1"
5
5
  RUBOCOP_VERSION = "~> 0.49.1"
6
6
  end
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Active Storage" do
4
+ before :all do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ create_dummy_project("active_storage" => true)
8
+ end
9
+
10
+ it "customizes config file" do
11
+ content = IO.read("#{project_path}/config/storage.yml")
12
+ expect(content).to include("bucket: <%= ENV['S3_BUCKET'] %>")
13
+ end
14
+
15
+ it "adds brief to README file" do
16
+ content = IO.read("#{project_path}/README.md")
17
+ expect(content).to include("Active Storage")
18
+ end
19
+
20
+ it "uses amazon on production env" do
21
+ content = IO.read("#{project_path}/config/environments/production.rb")
22
+ expect(content).to include("config.active_storage.service = :amazon")
23
+ end
24
+
25
+ it "adds amazon ENV vars" do
26
+ content = IO.read("#{project_path}/.env.development")
27
+ expect(content).to include("AWS_REGION=")
28
+ expect(content).to include("S3_BUCKET=")
29
+ end
30
+ end
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Database" do
4
+ before :all do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ create_dummy_project
8
+ end
9
+
10
+ it "adds the Strong Migrations gem to Gemfile" do
11
+ gemfile_content = IO.read("#{project_path}/Gemfile")
12
+ expect(gemfile_content).to include("gem 'strong_migrations'")
13
+ end
14
+ end
@@ -26,10 +26,18 @@ RSpec.describe "A new project" do
26
26
  expect(gemfile).to include %{gem 'pg'}
27
27
  end
28
28
 
29
+ it "configures aws" do
30
+ gemfile_content = IO.read("#{project_path}/Gemfile")
31
+ expect(gemfile_content).to include("'aws-sdk', '~> 3'")
32
+
33
+ initializer = IO.read("#{project_path}/config/initializers/aws.rb")
34
+ expect(initializer).to include("Aws::VERSION")
35
+ end
36
+
29
37
  it "configures the correct ruby version" do
30
38
  ruby_version_file = IO.read("#{project_path}/.ruby-version")
31
39
 
32
- expect(ruby_version_file).to eq("2.4")
40
+ expect(ruby_version_file).to eq("2.5")
33
41
  end
34
42
 
35
43
  it "setup ssl" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: potassium
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.4
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - juliogarciag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-20 00:00:00.000000000 Z
11
+ date: 2018-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 5.1.3
89
+ version: 5.2.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 5.1.3
96
+ version: 5.2.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: gli
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +189,7 @@ files:
189
189
  - docs/DSL.md
190
190
  - lib/potassium.rb
191
191
  - lib/potassium/assets/.buildpacks
192
+ - lib/potassium/assets/.circleci/config.yml
192
193
  - lib/potassium/assets/.dockerignore
193
194
  - lib/potassium/assets/.editorconfig
194
195
  - lib/potassium/assets/.env.development.erb
@@ -207,17 +208,18 @@ files:
207
208
  - lib/potassium/assets/api/draper_responder.rb
208
209
  - lib/potassium/assets/api/responder.rb
209
210
  - lib/potassium/assets/app/mailers/application_mailer.rb
211
+ - lib/potassium/assets/aws.rb
210
212
  - lib/potassium/assets/bin/cibuild.erb
211
213
  - lib/potassium/assets/bin/setup.erb
212
214
  - lib/potassium/assets/bin/setup_heroku.erb
213
215
  - lib/potassium/assets/bin/update.erb
214
- - lib/potassium/assets/circle.yml
215
216
  - lib/potassium/assets/config/database_mysql.yml.erb
216
217
  - lib/potassium/assets/config/database_postgresql.yml.erb
217
218
  - lib/potassium/assets/config/mailer.rb.erb
218
219
  - lib/potassium/assets/config/puma.rb
219
220
  - lib/potassium/assets/config/secrets.yml.erb
220
221
  - lib/potassium/assets/config/sentry.rb.erb
222
+ - lib/potassium/assets/config/storage.yml
221
223
  - lib/potassium/assets/docker-compose.ci.yml
222
224
  - lib/potassium/assets/es-CL.yml
223
225
  - lib/potassium/assets/lib/tasks/auto_annotate_models.rake
@@ -253,6 +255,7 @@ files:
253
255
  - lib/potassium/helpers/variable-helpers.rb
254
256
  - lib/potassium/newest_version_ensurer.rb
255
257
  - lib/potassium/recipe.rb
258
+ - lib/potassium/recipes/active_storage.rb
256
259
  - lib/potassium/recipes/admin.rb
257
260
  - lib/potassium/recipes/angular_admin.rb
258
261
  - lib/potassium/recipes/annotate.rb
@@ -299,8 +302,10 @@ files:
299
302
  - potassium.gemspec
300
303
  - spec/fakes/bin/heroku
301
304
  - spec/fakes/bin/hub
305
+ - spec/features/active_storage_spec.rb
302
306
  - spec/features/background_processor_spec.rb
303
307
  - spec/features/ci_spec.rb
308
+ - spec/features/database_spec.rb
304
309
  - spec/features/draper_spec.rb
305
310
  - spec/features/error_reporting_spec.rb
306
311
  - spec/features/front_end.rb
@@ -334,15 +339,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
334
339
  version: '0'
335
340
  requirements: []
336
341
  rubyforge_project:
337
- rubygems_version: 2.6.11
342
+ rubygems_version: 2.7.6
338
343
  signing_key:
339
344
  specification_version: 4
340
345
  summary: An application generator from Platanus
341
346
  test_files:
342
347
  - spec/fakes/bin/heroku
343
348
  - spec/fakes/bin/hub
349
+ - spec/features/active_storage_spec.rb
344
350
  - spec/features/background_processor_spec.rb
345
351
  - spec/features/ci_spec.rb
352
+ - spec/features/database_spec.rb
346
353
  - spec/features/draper_spec.rb
347
354
  - spec/features/error_reporting_spec.rb
348
355
  - spec/features/front_end.rb
@@ -1,19 +0,0 @@
1
- machine:
2
- services:
3
- - docker
4
-
5
- dependencies:
6
- override:
7
- - docker-compose -f docker-compose.ci.yml pull
8
- - docker-compose -f docker-compose.ci.yml build test
9
- - bin/cibuild services
10
- - bin/cibuild deps
11
- - bin/cibuild assets
12
-
13
- database:
14
- override:
15
- - bin/cibuild db
16
-
17
- test:
18
- override:
19
- - bin/cibuild tests