potassium 3.0.0 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +6 -4
  4. data/lib/potassium/assets/README.yml +9 -3
  5. data/lib/potassium/assets/bin/cibuild.erb +9 -1
  6. data/lib/potassium/assets/bin/setup.erb +2 -2
  7. data/lib/potassium/assets/bin/update.erb +32 -0
  8. data/lib/potassium/assets/circle.yml +1 -0
  9. data/lib/potassium/assets/config/{mailer.rb → mailer.rb.erb} +1 -1
  10. data/lib/potassium/assets/config/sentry.rb.erb +3 -1
  11. data/lib/potassium/assets/package.json +3 -0
  12. data/lib/potassium/assets/redis.yml +9 -0
  13. data/lib/potassium/assets/sidekiq.rb +17 -0
  14. data/lib/potassium/assets/sidekiq.yml +4 -0
  15. data/lib/potassium/assets/sidekiq_scheduler.yml +9 -0
  16. data/lib/potassium/cli_options.rb +12 -8
  17. data/lib/potassium/generators/application.rb +6 -0
  18. data/lib/potassium/recipes/admin.rb +1 -1
  19. data/lib/potassium/recipes/angular_admin.rb +1 -1
  20. data/lib/potassium/recipes/api.rb +1 -1
  21. data/lib/potassium/recipes/background_processor.rb +55 -0
  22. data/lib/potassium/recipes/ci.rb +3 -0
  23. data/lib/potassium/recipes/draper.rb +1 -2
  24. data/lib/potassium/recipes/front_end.rb +61 -0
  25. data/lib/potassium/recipes/heroku.rb +1 -2
  26. data/lib/potassium/recipes/mailer.rb +3 -5
  27. data/lib/potassium/recipes/power_types.rb +28 -0
  28. data/lib/potassium/recipes/schedule.rb +10 -18
  29. data/lib/potassium/recipes/yarn.rb +14 -0
  30. data/lib/potassium/templates/application.rb +12 -6
  31. data/lib/potassium/version.rb +3 -3
  32. data/spec/features/background_processor_spec.rb +66 -0
  33. data/spec/features/front_end.rb +30 -0
  34. data/spec/features/heroku_spec.rb +2 -2
  35. data/spec/features/power_types_spec.rb +37 -0
  36. data/spec/features/schedule_spec.rb +19 -0
  37. metadata +26 -16
  38. data/lib/potassium/assets/.bowerrc +0 -3
  39. data/lib/potassium/assets/bower.json +0 -4
  40. data/lib/potassium/assets/config/clock.rb.erb +0 -16
  41. data/lib/potassium/recipes/bower.rb +0 -13
  42. data/lib/potassium/recipes/delayed_job.rb +0 -38
  43. data/lib/potassium/recipes/git.rb +0 -9
  44. data/spec/features/clockwork_spec.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c4a19d0503fea30781bf341b2b73f8356e9ad07
4
- data.tar.gz: 9de9d7b253c62e7d3c5486204c7a408f4375bc5f
3
+ metadata.gz: 479102f8435587025fd50c9c83bdc108773ceb61
4
+ data.tar.gz: 9e5e03778e9218dd0fe9efa1ea1dc4899e7aad96
5
5
  SHA512:
6
- metadata.gz: d09d2f6e7342f589e44d54981dd093cd89a3998ef39007e326be9653509fe637cce0e255ffeffea5b6229a7b7416e948b52de17d6888d96125ef507c22a4ba19
7
- data.tar.gz: db39d009346a0d435f9d6f316205ef9d5e0670637188a92695e2dc33bc0c78ce232236e8e24fa50f9ed52d854e9dc2af32db0b8c45b9cb287dda85d3f1a642fd
6
+ metadata.gz: cc9c99c8da67c66bb18bb8f6ae214093e36eb42524349578403cfcccaa783642cc65a73e6f9257e899b7cf23f6124150544ab6eb3886a8979eec911df1e8f939
7
+ data.tar.gz: 1dfb6a5abbf465972f2ea326c2faa718e9117107efadb065c512cebb54ee5dfde3727e3c532ddd79763b0360ff8a316690ae18b5e6ad9f7bc37a3f29f4aaea78
data/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.1.1
6
+
7
+ Features:
8
+ - Rails 5.1.1 (`potassium` version will follow `Rails` version from now on) #136
9
+ - Adds front_end option to include Vue.js and Angular 2 (using `webpacker`)
10
+ - Replaces `bower` by `yarn`
11
+ - Add sidekiq as background processor alternative
12
+
13
+ Bugfixes:
14
+ - Force `DelayedJobs` migration to use 4.2 `ActiveRecord` class
15
+ - Fix custom `ActiveAdmin` footer
16
+ - Remove heroku dependency from mailer recipe, #124
17
+ - Sentry environment was not being overriden, #123
18
+ - Support for Draper gem
19
+
5
20
  ## 3.0.0
6
21
 
7
22
  Features:
data/README.md CHANGED
@@ -38,7 +38,7 @@ Potassium Rails apps includes the following gems and technologies:
38
38
 
39
39
  - [Ruby](https://www.ruby-lang.org) Set the project ruby version based on http://ruby.platan.us/latest
40
40
  - [dotenv](https://github.com/bkeepers/dotenv) load environmental variables in development
41
- - [Bower](http://bower.io) for frontend assets packages.
41
+ - [Yarn](https://yarnpkg.com) for frontend assets packages.
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.
@@ -59,10 +59,12 @@ The following optional integrations are added too:
59
59
  - [ActiveAdminAddons](https://github.com/platanus/activeadmin_addons) for some help with ActiveAdmin.
60
60
  - [Pundit](https://github.com/elabs/pundit) for role-based authorization.
61
61
  - [DelayedJob](https://github.com/collectiveidea/delayed_job) to execute longer tasks in the background.]
62
+ - [Sidekiq](https://github.com/mperham/sidekiq) a simple, efficient background processing for Ruby.
63
+ - [Sidekiq-scheduler](https://github.com/moove-it/sidekiq-scheduler) to run scheduled processes
62
64
  - Mailing configuration for [AWS SES](https://github.com/aws/aws-sdk-rails)
63
65
  and [Sendgrid](https://github.com/platanus/send_grid_mailer) with recipient interceptor support
64
- - [Clockwork](https://github.com/Rykian/clockwork) to run scheduled processes
65
66
  - [Sentry](https://sentry.io) to monitor exceptions and errors
67
+ - [Vue.js](https://vuejs.org) or [Angular 2](https://angular.io/) for frontend development
66
68
 
67
69
  A few more things are added to the project:
68
70
 
@@ -99,7 +101,7 @@ When you choose to deploy to heroku a few extra things are added for the project
99
101
 
100
102
  | index | buildpack | description |
101
103
  |-------|-----------|-------------|
102
- | 1. | [bower][heroku-buildpack-bower] | to make sure `bower install` run before the assets precompilation task |
104
+ | 1. | [nodejs][heroku-buildpack-nodejs] | to support javascript package management with `yarn` and `webpack` based asset compiling |
103
105
  | 2. | [ruby-version][heroku-buildpack-ruby-version] | to support the use of `.ruby-version` file to instruct heroku which ruby version to use |
104
106
  | 3. | [ruby][heroku-buildpack-ruby] | the base buildpack to run ruby applications |
105
107
  | 4. | [ruby-deploy-tasks][buildpack-deploy-tasks] | to run rake task after the deployment is complete, for example `db:migrate` |
@@ -135,7 +137,7 @@ Go to https://monkeyci.platan.us, choose the repository from the list and hit
135
137
  [heroku-logging]: https://devcenter.heroku.com/articles/logging#writing-to-your-log
136
138
  [procfile]: https://devcenter.heroku.com/articles/procfile
137
139
  [heroku-buildpack-ruby-version]: http://github.com/platanus/heroku-buildpack-ruby-version
138
- [heroku-buildpack-bower]: http://github.com/platanus/heroku-buildpack-bower
140
+ [heroku-buildpack-nodejs]: https://github.com/heroku/heroku-buildpack-nodejs
139
141
  [heroku-buildpack-ruby]: http://github.com/heroku/heroku-buildpack-ruby
140
142
  [heroku-buildpack-multi]: http://github.com/heroku/heroku-buildpack-multi
141
143
  [buildpack-deploy-tasks]: http://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks
@@ -72,7 +72,7 @@ readme:
72
72
  The emails can be send through the gem `<%= get(:mailer_gem_name) %>` using the `<%= get(:mailer_delivery_method) %>` delivery method.
73
73
  All the `action_mailer` configuration can be found at `config/mailer.rb`, which is loaded only on production environments.
74
74
 
75
- All emails should be sent using background jobs, by default we install `delayed_job` for that purpuse.
75
+ All emails should be sent using background jobs, by default we install `sidekiq` for that purpuse.
76
76
 
77
77
  #### Testing in staging
78
78
 
@@ -92,15 +92,21 @@ readme:
92
92
  delayed_job:
93
93
  title: "Queue System"
94
94
  body: "For managing tasks in the background, this project uses [DelayedJob](https://github.com/collectiveidea/delayed_job)"
95
- clockwork:
95
+ sidekiq:
96
+ title: "Queue System"
97
+ body: "For managing tasks in the background, this project uses [Sidekiq](https://github.com/mperham/sidekiq)"
98
+ sidekiq_scheduler:
96
99
  title: "Scheduled Tasks"
97
- body: "To schedule recurring work at particular times or dates, this project uses [Clockwork](https://github.com/Rykian/clockwork)"
100
+ body: "To schedule recurring work at particular times or dates, this project uses [Sidekiq Scheduler](https://github.com/moove-it/sidekiq-scheduler)"
98
101
  sentry:
99
102
  title: "Error Reporting"
100
103
  body: "To report our errors we use [Sentry](https://github.com/getsentry/raven-ruby)"
101
104
  draper:
102
105
  title: "Presentation Layer"
103
106
  body: "This project uses [Draper](https://github.com/drapergem/draper) to add an object-oriented layer of presentation logic"
107
+ power_types:
108
+ title: "Rails pattern enforcing types"
109
+ body: "This projects uses [Power-Types](https://github.com/platanus/power-types) to generate Services, Commands, Utils and Values."
104
110
  seeds:
105
111
  title: "Seeds"
106
112
  body: |
@@ -44,6 +44,10 @@ dependencies(){
44
44
  docker-compose $DOCKER_COMPOSE_ARGS run test bundle install
45
45
  }
46
46
 
47
+ assets() {
48
+ docker-compose $DOCKER_COMPOSE_ARGS run test /bin/bash -c "bin/setup && bundle exec rake assets:precompile"
49
+ }
50
+
47
51
  # Prepare database
48
52
  database(){
49
53
  docker-compose $DOCKER_COMPOSE_ARGS run test bundle exec rake db:create db:schema:load
@@ -63,6 +67,7 @@ no_ci(){
63
67
  build
64
68
  wait_services
65
69
  dependencies
70
+ assets
66
71
  database
67
72
  tests
68
73
  }
@@ -77,6 +82,9 @@ case "$1" in
77
82
  "deps"|"dependencies")
78
83
  dependencies
79
84
  ;;
85
+ "assets")
86
+ assets
87
+ ;;
80
88
  "db"|"database")
81
89
  database
82
90
  ;;
@@ -87,6 +95,6 @@ case "$1" in
87
95
  build
88
96
  ;;
89
97
  *)
90
- echo "Usage: cibuild [services|deps|db|specs|build]"
98
+ echo "Usage: cibuild [services|deps|assets|db|specs|build]"
91
99
  ;;
92
100
  esac
@@ -10,8 +10,8 @@ set -e
10
10
  gem install bundler --conservative
11
11
  bundle check || bundle install
12
12
 
13
- # Install bower dependencies
14
- bower install
13
+ # Install javascript dependencies
14
+ bin/yarn install
15
15
 
16
16
  # Set up database
17
17
  bin/rails db:setup
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a way to update your development environment automatically.
15
+ # Add necessary update steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+
20
+ puts '== Installing YARN stuff =='
21
+ system! 'bin/yarn install'
22
+
23
+ system('bundle check') || system!('bundle install')
24
+ puts "\n== Updating database =="
25
+ system! 'bin/rails db:migrate'
26
+
27
+ puts "\n== Removing old logs and tempfiles =="
28
+ system! 'bin/rails log:clear tmp:clear'
29
+
30
+ puts "\n== Restarting application server =="
31
+ system! 'bin/rails restart'
32
+ end
@@ -8,6 +8,7 @@ dependencies:
8
8
  - docker-compose -f docker-compose.ci.yml build test
9
9
  - bin/cibuild services
10
10
  - bin/cibuild deps
11
+ - bin/cibuild assets
11
12
 
12
13
  database:
13
14
  override:
@@ -13,6 +13,6 @@ Rails.application.config.action_mailer.asset_host = ASSET_HOST
13
13
  if ENV["EMAIL_RECIPIENTS"].present?
14
14
  Mail.register_interceptor RecipientInterceptor.new(
15
15
  ENV["EMAIL_RECIPIENTS"],
16
- subject_prefix: "[#{Heroku.stage.upcase}]"
16
+ subject_prefix: "[<%= get(:heroku) ? '#{Heroku.stage.upcase}' : '#{Rails.env}' %>]"
17
17
  )
18
18
  end
@@ -1,7 +1,9 @@
1
1
  if Rails.env.production?
2
2
  Raven.configure do |config|
3
3
  config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
4
- config.tags = { environment: <%= get(:heroku) ? "Heroku.stage" : "Rails.env" %> }
4
+ <% if get(:heroku) %>
5
+ config.current_environment = Heroku.stage
6
+ <% end %>
5
7
  end
6
8
 
7
9
  # In case you want to group the events with different ids in the
@@ -0,0 +1,3 @@
1
+ {
2
+ "name": "<%= @app_name.camelcase %>"
3
+ }
@@ -0,0 +1,9 @@
1
+ development: &default
2
+ host: <%= ENV["BOXEN_REDIS_HOST"] || ENV["REDIS_HOST"] || "127.0.0.1" %>
3
+ port: <%= ENV["BOXEN_REDIS_PORT"] || ENV["REDIS_PORT"] || 6379 %>
4
+
5
+ test:
6
+ <<: *default
7
+
8
+ production: &deploy
9
+ url: <%= ENV.fetch("REDIS_URL", "") %>
@@ -0,0 +1,17 @@
1
+ require 'sidekiq'
2
+ require 'sidekiq/web'
3
+
4
+ redis_config = Rails.application.config_for(:redis)
5
+
6
+ Sidekiq.configure_client do |config|
7
+ config.redis = redis_config
8
+ end
9
+ Sidekiq.configure_server do |config|
10
+ config.redis = redis_config
11
+ end
12
+
13
+ if !Rails.env.development?
14
+ Sidekiq::Web.use Rack::Auth::Basic do |username, password|
15
+ username == 'admin' && password == ENV["SIDEKIQ_ADMIN_PASSWORD"]
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ production:
2
+ :concurrency: 5
3
+ :queues:
4
+ - default
@@ -0,0 +1,9 @@
1
+ production:
2
+ :concurrency: 5
3
+ :queues:
4
+ - default
5
+ :schedule:
6
+ # an_scheduled_task:
7
+ # cron: '0 * * * * *' # Runs once per minute
8
+ # class: ExampleJob
9
+ # args: ['a', 'b']
@@ -83,12 +83,10 @@ module Potassium::CliOptions # rubocop:disable Metrics/ModuleLength
83
83
  default_test_value: false
84
84
  },
85
85
  {
86
- type: :switch,
87
- name: "delayed-job",
88
- desc: "Whether to use DelayedJob or not",
89
- negatable: true,
90
- default_value: "none",
91
- default_test_value: false
86
+ type: :flag,
87
+ name: "background_processor",
88
+ desc: "Decides which background processor to use. Available: sidekiq, delayed_job, none",
89
+ default_test_value: "sidekiq"
92
90
  },
93
91
  {
94
92
  type: :switch,
@@ -116,8 +114,8 @@ module Potassium::CliOptions # rubocop:disable Metrics/ModuleLength
116
114
  },
117
115
  {
118
116
  type: :switch,
119
- name: "clockwork",
120
- desc: "Whether to use clockwork as job scheduler",
117
+ name: "schedule",
118
+ desc: "Whether to use sidekiq-scheduler as job scheduler",
121
119
  negatable: true,
122
120
  default_value: "none",
123
121
  default_test_value: false
@@ -129,6 +127,12 @@ module Potassium::CliOptions # rubocop:disable Metrics/ModuleLength
129
127
  negatable: true,
130
128
  default_value: "none",
131
129
  default_test_value: false
130
+ },
131
+ {
132
+ type: :flag,
133
+ name: :front_end,
134
+ desc: "Decides which front-end framework to use. Available: Vue, Angular 2, None",
135
+ default_test_value: "None"
132
136
  }
133
137
  ]
134
138
 
@@ -15,6 +15,12 @@ module Potassium
15
15
  template_location = File.expand_path('../templates/application.rb', File.dirname(__FILE__))
16
16
  instance_eval File.read(template_location), template_location
17
17
  super
18
+
19
+ after_bundle do
20
+ git :init
21
+ git add: "."
22
+ git commit: %{ -m 'Initial commit' -q }
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -43,7 +43,7 @@ class Recipes::Admin < Rails::AppBuilder
43
43
  gsub_file initializer, /(#{Regexp.escape(line)})/mi do |_match|
44
44
  <<-HERE.gsub(/^ {11}/, '')
45
45
  class CustomFooter < ActiveAdmin::Component
46
- def build
46
+ def build _arg
47
47
  super(id: "footer")
48
48
  para "Powered by Platanus"
49
49
  end
@@ -50,7 +50,7 @@ class Recipes::AngularAdmin < Rails::AppBuilder
50
50
  create_file 'app/assets/javascripts/admin/directives/.keep'
51
51
 
52
52
  inside('.') do
53
- run('bower install angular --save')
53
+ run('bin/yarn add angular --save')
54
54
  end
55
55
  end
56
56
  end
@@ -29,7 +29,7 @@ class Recipes::Api < Rails::AppBuilder
29
29
  insert_into_file "config/routes.rb", after: line do
30
30
  <<-HERE.gsub(/^ {8}/, '')
31
31
  scope path: '/api' do
32
- api_version(module: "Api::V1", path: { value: "v1" }) do
32
+ api_version(module: "Api::V1", path: { value: "v1" }, defaults: { format: 'json' }) do
33
33
  end
34
34
  end
35
35
  HERE
@@ -0,0 +1,55 @@
1
+ class Recipes::BackgroundProcessor < Rails::AppBuilder
2
+ def ask
3
+ response = if selected?(:email_service, :none)
4
+ answer(:background_processor) do
5
+ Ask.confirm("Do you want to use Sidekiq for background job processing?")
6
+ end
7
+ else
8
+ info "Note: Emails should be sent on background jobs. We'll install sidekiq"
9
+ true
10
+ end
11
+ set(:background_processor, response)
12
+ end
13
+
14
+ def create
15
+ add_sidekiq if get(:background_processor)
16
+ end
17
+
18
+ def install
19
+ ask
20
+ heroku = load_recipe(:heroku)
21
+ set(:heroku, heroku.installed?)
22
+ create
23
+ end
24
+
25
+ def installed?
26
+ gem_exists?(/sidekiq/)
27
+ end
28
+
29
+ def add_sidekiq
30
+ gather_gem("sidekiq")
31
+ add_adapters("sidekiq")
32
+ add_readme_section :internal_dependencies, :sidekiq
33
+ edit_procfile("bundle exec sidekiq")
34
+ append_to_file(".env.development", "DB_POOL=25\n")
35
+ copy_file("../assets/sidekiq.rb", "config/initializers/sidekiq.rb", force: true)
36
+ copy_file("../assets/sidekiq.yml", "config/sidekiq.yml", force: true)
37
+ copy_file("../assets/redis.yml", "config/redis.yml", force: true)
38
+
39
+ insert_into_file "config/routes.rb", after: "Rails.application.routes.draw do\n" do
40
+ <<-HERE.gsub(/^ {6}/, '')
41
+ mount Sidekiq::Web => '/queue'
42
+ HERE
43
+ end
44
+ end
45
+
46
+ def edit_procfile(cmd)
47
+ gsub_file("Procfile", /^.*$/m) { |match| "#{match}worker: #{cmd}" } if selected?(:heroku)
48
+ end
49
+
50
+ def add_adapters(name)
51
+ application("config.active_job.queue_adapter = :#{name}")
52
+ application "config.active_job.queue_adapter = :inline", env: "development"
53
+ application "config.active_job.queue_adapter = :test", env: "test"
54
+ end
55
+ end
@@ -42,5 +42,8 @@ class Recipes::Ci < Rails::AppBuilder
42
42
 
43
43
  add_readme_header :ci
44
44
  end
45
+
46
+ uglifier = " config.assets.js_compressor = :uglifier\n"
47
+ insert_into_file 'config/environments/test.rb', uglifier, after: "configure do\n"
45
48
  end
46
49
  end
@@ -21,8 +21,7 @@ class Recipes::Draper < Rails::AppBuilder
21
21
  end
22
22
 
23
23
  def add_draper
24
- gather_gem 'activemodel-serializers-xml', github: 'rails/activemodel-serializers-xml'
25
- gather_gem 'draper'
24
+ gather_gem 'draper', '3.0.0.pre1'
26
25
  add_readme_section :internal_dependencies, :draper
27
26
  create_file 'app/decorators/.keep'
28
27
  end
@@ -0,0 +1,61 @@
1
+ class Recipes::FrontEnd < Rails::AppBuilder
2
+ def ask
3
+ frameworks = {
4
+ vue: "Vue",
5
+ angular: "Angular 2",
6
+ none: "None"
7
+ }
8
+
9
+ framework = answer(:front_end) do
10
+ frameworks.keys[
11
+ Ask.list("Which front-end framework are you going to use?", frameworks.values)
12
+ ]
13
+ end
14
+ set :front_end, framework.to_sym
15
+ end
16
+
17
+ def create
18
+ return if [:none, :None].include? get(:front_end).to_sym
19
+
20
+ gather_gem 'webpacker', github: 'rails/webpacker'
21
+
22
+ after(:gem_install) do
23
+ value = get(:front_end)
24
+ run "rails webpacker:install"
25
+ run "rails webpacker:install:#{value}" if value
26
+
27
+ if value == :vue
28
+ application_js_file = "app/javascript/packs/application.js"
29
+ FileUtils.move "app/javascript/packs/hello_vue.js", application_js_file
30
+ gsub_file application_js_file, %r{\/\/.*\n}, ""
31
+
32
+ js_pack_tag = "\n <%= javascript_pack_tag 'application' %>\n"
33
+ layout_file = "app/views/layouts/application.html.erb"
34
+ insert_into_file layout_file, js_pack_tag, after: "<%= csrf_meta_tags %>"
35
+ end
36
+ end
37
+ end
38
+
39
+ def install
40
+ ask
41
+ create
42
+ end
43
+
44
+ def installed?
45
+ package_file = 'package.json'
46
+ return false unless file_exist?(package_file)
47
+ package_content = read_file(package_file)
48
+ package_content.include?("\"@angular/core\"") || package_content.include?("\"vue\"")
49
+ end
50
+
51
+ private
52
+
53
+ def frameworks(framework)
54
+ frameworks = {
55
+ vue: "vue",
56
+ angular: "angular",
57
+ none: nil
58
+ }
59
+ frameworks[framework]
60
+ end
61
+ end
@@ -36,10 +36,9 @@ class Recipes::Heroku < Rails::AppBuilder
36
36
  def add_heroku
37
37
  gather_gems(:production) do
38
38
  gather_gem('rails_stdout_logging')
39
+ gather_gem('heroku-stage')
39
40
  end
40
41
 
41
- gather_gem 'heroku-stage'
42
-
43
42
  copy_file '../assets/Procfile', 'Procfile'
44
43
  copy_file '../assets/.buildpacks', '.buildpacks'
45
44
 
@@ -1,6 +1,5 @@
1
1
  class Recipes::Mailer < Rails::AppBuilder
2
2
  def ask
3
- info "Note: Emails should be sent on background jobs. We'll install delayed_jobs recipe"
4
3
  email_services = {
5
4
  aws_ses: "Amazon SES",
6
5
  sendgrid: "Sendgrid (beta)",
@@ -25,8 +24,8 @@ class Recipes::Mailer < Rails::AppBuilder
25
24
  dependencies(email_service)
26
25
  config(email_service)
27
26
 
28
- delayed_job = load_recipe(:delayed_job)
29
- delayed_job.add_delayed_job unless delayed_job.installed?
27
+ background_processor = load_recipe(:background_processor)
28
+ background_processor.add_sidekiq unless background_processor.installed?
30
29
  end
31
30
 
32
31
  def install
@@ -58,12 +57,11 @@ class Recipes::Mailer < Rails::AppBuilder
58
57
  else
59
58
  gather_gem service[:gem_name]
60
59
  end
61
- gather_gem 'heroku-stage'
62
60
  gather_gem 'recipient_interceptor'
63
61
  end
64
62
 
65
63
  def config(service)
66
- template "../assets/config/mailer.rb", 'config/mailer.rb'
64
+ template "../assets/config/mailer.rb.erb", 'config/mailer.rb'
67
65
  gsub_file 'config/environments/production.rb', /$\s*config.action_mailer.*/, ''
68
66
  append_to_file '.env.development', "APPLICATION_HOST=localhost:3000\n"
69
67
  append_to_file '.env.development', "EMAIL_RECIPIENTS=\n"
@@ -0,0 +1,28 @@
1
+ class Recipes::PowerTypes < Rails::AppBuilder
2
+ def create
3
+ add_power_types
4
+ generate_folders
5
+ end
6
+
7
+ def install
8
+ add_power_types
9
+ generate_folders
10
+ end
11
+
12
+ def installed?
13
+ gem_exists?(/power-types/)
14
+ end
15
+
16
+ private
17
+
18
+ def add_power_types
19
+ gather_gem 'power-types'
20
+ add_readme_section :internal_dependencies, :power_types
21
+ end
22
+
23
+ def generate_folders
24
+ after(:gem_install) do
25
+ generate "power_types:init"
26
+ end
27
+ end
28
+ end
@@ -1,33 +1,25 @@
1
1
  class Recipes::Schedule < Rails::AppBuilder
2
2
  def ask
3
- use_schedule = answer(:clockwork) { Ask.confirm("Do you need to schedule processes or tasks?") }
4
- set(:scheduled, use_schedule)
3
+ if selected?(:background_processor)
4
+ response = answer(:schedule) { Ask.confirm("Do you need to schedule jobs?") }
5
+ end
6
+ set(:schedule, response)
5
7
  end
6
8
 
7
9
  def create
8
- if selected?(:scheduled)
9
- gather_gem 'clockwork'
10
- template '../assets/config/clock.rb.erb', 'config/clock.rb'
11
- add_readme_section :internal_dependencies, :clockwork
12
-
13
- if selected?(:heroku)
14
- procfile('scheduler', 'bundle exec clockwork config/clock.rb')
15
- end
10
+ if selected?(:schedule)
11
+ gather_gem 'sidekiq-scheduler'
12
+ add_readme_section :internal_dependencies, :sidekiq_scheduler
16
13
  end
14
+ template '../assets/sidekiq_scheduler.yml', 'config/sidekiq.yml', force: true
17
15
  end
18
16
 
19
17
  def install
20
- heroku = load_recipe(:heroku)
21
- set(:heroku, heroku.installed?)
22
-
23
- error_reporting = load_recipe(:error_reporting)
24
- set(:report_error, error_reporting.installed?)
25
-
26
- set(:scheduled, true)
18
+ set(:schedule, true)
27
19
  create
28
20
  end
29
21
 
30
22
  def installed?
31
- gem_exists?(/clock/) && file_exist?('config/clock.rb')
23
+ gem_exists?("sidekiq-scheduler") && file_exist?('config/sidekiq.yml')
32
24
  end
33
25
  end
@@ -0,0 +1,14 @@
1
+ class Recipes::Yarn < Rails::AppBuilder
2
+ def create
3
+ template '../assets/package.json', 'package.json' unless get(:front_end)
4
+ template '../assets/bin/update.erb', 'bin/update', force: true
5
+ application "config.assets.paths << Rails.root.join('node_modules')"
6
+ append_to_file ".gitignore", "node_modules/\n"
7
+
8
+ if get(:heroku)
9
+ node_buildpack_url = 'https://github.com/heroku/heroku-buildpack-nodejs'
10
+ insert_point = 'https://github.com/platanus/heroku-buildpack-ruby-version.git'
11
+ inject_into_file '.buildpacks', "#{node_buildpack_url}\n", before: insert_point
12
+ end
13
+ end
14
+ end
@@ -12,12 +12,18 @@ run_action(:cleaning) do
12
12
  gather_gem("spring")
13
13
  end
14
14
 
15
+ run_action(:add_utils) do
16
+ gather_gem("enumerize")
17
+ end
18
+
15
19
  run_action(:asking) do
16
20
  ask :database
17
21
  ask :devise
18
22
  ask :admin
23
+ ask :front_end
19
24
  ask :angular_admin
20
- ask :delayed_job
25
+ ask :mailer
26
+ ask :background_processor
21
27
  ask :schedule
22
28
  ask :error_reporting
23
29
  ask :pundit
@@ -25,7 +31,6 @@ run_action(:asking) do
25
31
  ask :api
26
32
  ask :draper
27
33
  ask :paperclip
28
- ask :mailer
29
34
  ask :heroku
30
35
  ask :github
31
36
  end
@@ -40,11 +45,12 @@ run_action(:recipe_loading) do
40
45
  create :annotate
41
46
  create :ruby
42
47
  create :env
43
- create :bower
48
+ create :yarn
44
49
  create :editorconfig
45
50
  create :aws_sdk
46
- create :schedule
47
51
  create :mailer
52
+ create :background_processor
53
+ create :schedule
48
54
  create :i18n
49
55
  create :pry
50
56
  create :better_errors
@@ -53,19 +59,19 @@ run_action(:recipe_loading) do
53
59
  create :angular_admin
54
60
  create :seeds
55
61
  create :error_reporting
56
- create :delayed_job
57
62
  create :pundit
58
63
  create :testing
59
64
  create :secrets
60
- create :git
61
65
  create :api
62
66
  create :draper
67
+ create :power_types
63
68
  create :rack_cors
64
69
  create :paperclip
65
70
  create :tzinfo
66
71
  create :script
67
72
  create :github
68
73
  create :cleanup
74
+ create :front_end
69
75
  end
70
76
 
71
77
  info "Gathered enough information. Applying the template. Wait a minute."
@@ -1,6 +1,6 @@
1
1
  module Potassium
2
- VERSION = "3.0.0"
2
+ VERSION = "5.1.1"
3
3
  RUBY_VERSION = "2.3.1"
4
- RAILS_VERSION = "~> 5.0.2"
5
- RUBOCOP_VERSION = "~> 0.46.0"
4
+ RAILS_VERSION = "~> 5.1.1"
5
+ RUBOCOP_VERSION = "~> 0.49.1"
6
6
  end
@@ -0,0 +1,66 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "BackgroundProcessor" do
4
+ context "working with sidekiq" do
5
+ before :all do
6
+ drop_dummy_database
7
+ remove_project_directory
8
+ create_dummy_project("background_processor" => "sidekiq", "heroku" => true)
9
+ end
10
+
11
+ it "adds sidekiq gem to Gemfile" do
12
+ gemfile_content = IO.read("#{project_path}/Gemfile")
13
+ expect(gemfile_content).to include("gem 'sidekiq'")
14
+ end
15
+
16
+ it "adds queue_adapter to application.rb" do
17
+ content = IO.read("#{project_path}/config/application.rb")
18
+ expect(content).to include("config.active_job.queue_adapter = :sidekiq")
19
+ end
20
+
21
+ it "adds inline queue_adapter to development.rb" do
22
+ content = IO.read("#{project_path}/config/environments/development.rb")
23
+ expect(content).to include("config.active_job.queue_adapter = :inline")
24
+ end
25
+
26
+ it "adds test queue_adapter to test.rb" do
27
+ content = IO.read("#{project_path}/config/environments/test.rb")
28
+ expect(content).to include("config.active_job.queue_adapter = :test")
29
+ end
30
+
31
+ it "modifies Procfile" do
32
+ content = IO.read("#{project_path}/Procfile")
33
+ expect(content).to include("worker: bundle exec sidekiq")
34
+ end
35
+
36
+ it "modifies README" do
37
+ content = IO.read("#{project_path}/README.md")
38
+ expect(content).to include("this project uses [Sidekiq]")
39
+ end
40
+
41
+ it "adds ENV vars" do
42
+ content = IO.read("#{project_path}/.env.development")
43
+ expect(content).to include("DB_POOL=25")
44
+ end
45
+
46
+ it "adds sidekiq.rb file" do
47
+ content = IO.read("#{project_path}/config/initializers/sidekiq.rb")
48
+ expect(content).to include("require 'sidekiq'")
49
+ end
50
+
51
+ it "adds sidekiq.yml file" do
52
+ content = IO.read("#{project_path}/config/sidekiq.yml")
53
+ expect(content).to include("concurrency: 5")
54
+ end
55
+
56
+ it "adds redis.yml file" do
57
+ content = IO.read("#{project_path}/config/redis.yml")
58
+ expect(content).to include("REDIS_HOST")
59
+ end
60
+
61
+ it "mounts sidekiq app" do
62
+ content = IO.read("#{project_path}/config/routes.rb")
63
+ expect(content).to include("mount Sidekiq::Web => '/queue'")
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Front end" do
4
+ before(:all) { drop_dummy_database }
5
+ before(:each) { remove_project_directory }
6
+
7
+ it "creates a project wihtout a front end framework" do
8
+ create_dummy_project("front_end" => "None")
9
+ gemfile = IO.read("#{project_path}/Gemfile")
10
+ expect(gemfile).not_to include('webpacker')
11
+ end
12
+
13
+ it "creates a project wihtout vue as front end framework" do
14
+ create_dummy_project("front_end" => "angular")
15
+ gemfile = IO.read("#{project_path}/Gemfile")
16
+ node_modules_file = IO.read("#{project_path}/package.json")
17
+
18
+ expect(gemfile).to include('webpacker')
19
+ expect(node_modules_file).to include("\"@angular/core\"")
20
+ end
21
+
22
+ it "creates a project wihtout vue as front end framework" do
23
+ create_dummy_project("front_end" => "vue")
24
+ gemfile = IO.read("#{project_path}/Gemfile")
25
+ node_modules_file = IO.read("#{project_path}/package.json")
26
+
27
+ expect(gemfile).to include('webpacker')
28
+ expect(node_modules_file).to include("\"vue\"")
29
+ end
30
+ end
@@ -6,7 +6,7 @@ RSpec.describe "Heroku" do
6
6
  remove_project_directory
7
7
  end
8
8
 
9
- fit "creates a project for Heroku" do
9
+ it "creates a project for Heroku" do
10
10
  create_dummy_project("heroku" => true)
11
11
  app_name = PotassiumTestHelpers::APP_NAME.dasherize
12
12
 
@@ -22,7 +22,7 @@ RSpec.describe "Heroku" do
22
22
  buildpacks_path = "#{project_path}/.buildpacks"
23
23
  buildpacks = IO.read(buildpacks_path)
24
24
 
25
- expect(buildpacks).to include("https://github.com/platanus/heroku-buildpack-bower.git")
25
+ expect(buildpacks).to include("https://github.com/heroku/heroku-buildpack-nodejs")
26
26
  expect(buildpacks).to include("https://github.com/platanus/heroku-buildpack-ruby-version.git")
27
27
  expect(buildpacks).to include("https://github.com/heroku/heroku-buildpack-ruby.git")
28
28
  expect(buildpacks).to(
@@ -0,0 +1,37 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "PowerTypes" do
4
+ before :all do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ create_dummy_project
8
+ end
9
+
10
+ it "adds the PowerTypes gem to Gemfile" do
11
+ gemfile_content = IO.read("#{project_path}/Gemfile")
12
+ expect(gemfile_content).to include("gem 'power-types'")
13
+ end
14
+
15
+ it "adds the PowerTypes brief to README file" do
16
+ readme = IO.read("#{project_path}/README.md")
17
+ expect(readme).to include("Power-Types")
18
+ end
19
+
20
+ it "adds commands directory" do
21
+ commands_directory = "#{project_path}/app/commands"
22
+ expect(File.directory?(commands_directory)).to eq(true)
23
+ end
24
+
25
+ it "adds services directory" do
26
+ services_directory = "#{project_path}/app/services"
27
+ expect(File.directory?(services_directory)).to eq(true)
28
+ end
29
+ it "adds utils directory" do
30
+ utils_directory = "#{project_path}/app/utils"
31
+ expect(File.directory?(utils_directory)).to eq(true)
32
+ end
33
+ it "adds values directory" do
34
+ values_directory = "#{project_path}/app/values"
35
+ expect(File.directory?(values_directory)).to eq(true)
36
+ end
37
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "schedule" do
4
+ before :all do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ create_dummy_project("schedule" => true)
8
+ end
9
+
10
+ it "adds the sidekiq-scheduler gem to Gemfile" do
11
+ gemfile_content = IO.read("#{project_path}/Gemfile")
12
+ expect(gemfile_content).to include("gem 'sidekiq-scheduler'")
13
+ end
14
+
15
+ it "creates the config with schedule" do
16
+ initializer_content = IO.read("#{project_path}/config/sidekiq.yml")
17
+ expect(initializer_content).to include(":schedule:")
18
+ end
19
+ end
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: 3.0.0
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - juliogarciag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-03 00:00:00.000000000 Z
11
+ date: 2017-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.46.0
75
+ version: 0.49.1
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.46.0
82
+ version: 0.49.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rails
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 5.0.2
89
+ version: 5.1.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.0.2
96
+ version: 5.1.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: gli
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -188,7 +188,6 @@ files:
188
188
  - docs/CONTRIBUTING.md
189
189
  - docs/DSL.md
190
190
  - lib/potassium.rb
191
- - lib/potassium/assets/.bowerrc
192
191
  - lib/potassium/assets/.buildpacks
193
192
  - lib/potassium/assets/.dockerignore
194
193
  - lib/potassium/assets/.editorconfig
@@ -211,22 +210,26 @@ files:
211
210
  - lib/potassium/assets/bin/cibuild.erb
212
211
  - lib/potassium/assets/bin/setup.erb
213
212
  - lib/potassium/assets/bin/setup_heroku.erb
214
- - lib/potassium/assets/bower.json
213
+ - lib/potassium/assets/bin/update.erb
215
214
  - lib/potassium/assets/circle.yml
216
- - lib/potassium/assets/config/clock.rb.erb
217
215
  - lib/potassium/assets/config/database_mysql.yml.erb
218
216
  - lib/potassium/assets/config/database_postgresql.yml.erb
219
- - lib/potassium/assets/config/mailer.rb
217
+ - lib/potassium/assets/config/mailer.rb.erb
220
218
  - lib/potassium/assets/config/puma.rb
221
219
  - lib/potassium/assets/config/secrets.yml.erb
222
220
  - lib/potassium/assets/config/sentry.rb.erb
223
221
  - lib/potassium/assets/docker-compose.ci.yml
224
222
  - lib/potassium/assets/es-CL.yml
225
223
  - lib/potassium/assets/lib/tasks/auto_annotate_models.rake
224
+ - lib/potassium/assets/package.json
225
+ - lib/potassium/assets/redis.yml
226
226
  - lib/potassium/assets/seeds/admin_data_loader.rb
227
227
  - lib/potassium/assets/seeds/fake_data_loader.rake
228
228
  - lib/potassium/assets/seeds/fake_data_loader.rb
229
229
  - lib/potassium/assets/seeds/seeds.rb
230
+ - lib/potassium/assets/sidekiq.rb
231
+ - lib/potassium/assets/sidekiq.yml
232
+ - lib/potassium/assets/sidekiq_scheduler.yml
230
233
  - lib/potassium/assets/testing/.rspec
231
234
  - lib/potassium/assets/testing/paperclip.rb
232
235
  - lib/potassium/assets/testing/platanus.png
@@ -255,23 +258,23 @@ files:
255
258
  - lib/potassium/recipes/annotate.rb
256
259
  - lib/potassium/recipes/api.rb
257
260
  - lib/potassium/recipes/aws_sdk.rb
261
+ - lib/potassium/recipes/background_processor.rb
258
262
  - lib/potassium/recipes/better_errors.rb
259
- - lib/potassium/recipes/bower.rb
260
263
  - lib/potassium/recipes/ci.rb
261
264
  - lib/potassium/recipes/cleanup.rb
262
265
  - lib/potassium/recipes/database.rb
263
- - lib/potassium/recipes/delayed_job.rb
264
266
  - lib/potassium/recipes/devise.rb
265
267
  - lib/potassium/recipes/draper.rb
266
268
  - lib/potassium/recipes/editorconfig.rb
267
269
  - lib/potassium/recipes/env.rb
268
270
  - lib/potassium/recipes/error_reporting.rb
269
- - lib/potassium/recipes/git.rb
271
+ - lib/potassium/recipes/front_end.rb
270
272
  - lib/potassium/recipes/github.rb
271
273
  - lib/potassium/recipes/heroku.rb
272
274
  - lib/potassium/recipes/i18n.rb
273
275
  - lib/potassium/recipes/mailer.rb
274
276
  - lib/potassium/recipes/paperclip.rb
277
+ - lib/potassium/recipes/power_types.rb
275
278
  - lib/potassium/recipes/pry.rb
276
279
  - lib/potassium/recipes/puma.rb
277
280
  - lib/potassium/recipes/pundit.rb
@@ -285,6 +288,7 @@ files:
285
288
  - lib/potassium/recipes/style.rb
286
289
  - lib/potassium/recipes/testing.rb
287
290
  - lib/potassium/recipes/tzinfo.rb
291
+ - lib/potassium/recipes/yarn.rb
288
292
  - lib/potassium/template_finder.rb
289
293
  - lib/potassium/templates/application.rb
290
294
  - lib/potassium/templates/recipe.rb
@@ -294,14 +298,17 @@ files:
294
298
  - potassium.gemspec
295
299
  - spec/fakes/bin/heroku
296
300
  - spec/fakes/bin/hub
301
+ - spec/features/background_processor_spec.rb
297
302
  - spec/features/ci_spec.rb
298
- - spec/features/clockwork_spec.rb
299
303
  - spec/features/draper_spec.rb
300
304
  - spec/features/error_reporting_spec.rb
305
+ - spec/features/front_end.rb
301
306
  - spec/features/github_spec.rb
302
307
  - spec/features/heroku_spec.rb
303
308
  - spec/features/i18n_spec.rb
304
309
  - spec/features/new_project_spec.rb
310
+ - spec/features/power_types_spec.rb
311
+ - spec/features/schedule_spec.rb
305
312
  - spec/spec_helper.rb
306
313
  - spec/support/fake_github.rb
307
314
  - spec/support/fake_heroku.rb
@@ -326,21 +333,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
326
333
  version: '0'
327
334
  requirements: []
328
335
  rubyforge_project:
329
- rubygems_version: 2.5.2
336
+ rubygems_version: 2.6.12
330
337
  signing_key:
331
338
  specification_version: 4
332
339
  summary: An application generator from Platanus
333
340
  test_files:
334
341
  - spec/fakes/bin/heroku
335
342
  - spec/fakes/bin/hub
343
+ - spec/features/background_processor_spec.rb
336
344
  - spec/features/ci_spec.rb
337
- - spec/features/clockwork_spec.rb
338
345
  - spec/features/draper_spec.rb
339
346
  - spec/features/error_reporting_spec.rb
347
+ - spec/features/front_end.rb
340
348
  - spec/features/github_spec.rb
341
349
  - spec/features/heroku_spec.rb
342
350
  - spec/features/i18n_spec.rb
343
351
  - spec/features/new_project_spec.rb
352
+ - spec/features/power_types_spec.rb
353
+ - spec/features/schedule_spec.rb
344
354
  - spec/spec_helper.rb
345
355
  - spec/support/fake_github.rb
346
356
  - spec/support/fake_heroku.rb
@@ -1,3 +0,0 @@
1
- {
2
- "directory": "vendor/assets/bower_components"
3
- }
@@ -1,4 +0,0 @@
1
- {
2
- "name": "<%= @app_name.camelcase %>",
3
- "version": "1.0.0"
4
- }
@@ -1,16 +0,0 @@
1
- require 'clockwork'
2
- require_relative './boot'
3
- require_relative './environment'
4
-
5
- module Clockwork
6
- <% if selected?(:report_error) -%>
7
- error_handler do |error|
8
- Raven.capture_exception(error)
9
- end
10
- <% end -%>
11
- # Example
12
- #
13
- # every(5.minutes, 'ScheduledJob') do
14
- # ScheduledJob.perform_later
15
- # end
16
- end
@@ -1,13 +0,0 @@
1
- class Recipes::Bower < Rails::AppBuilder
2
- def create
3
- copy_file '../assets/.bowerrc', '.bowerrc'
4
- template '../assets/bower.json', 'bower.json'
5
- application "config.assets.paths << Rails.root.join('vendor', 'assets', 'bower_components')"
6
-
7
- if get(:heroku)
8
- bower_buildpack_url = 'https://github.com/platanus/heroku-buildpack-bower.git'
9
- insert_point = 'https://github.com/platanus/heroku-buildpack-ruby-version.git'
10
- inject_into_file '.buildpacks', "#{bower_buildpack_url}\n", before: insert_point
11
- end
12
- end
13
- end
@@ -1,38 +0,0 @@
1
- class Recipes::DelayedJob < Rails::AppBuilder
2
- def ask
3
- use_delayed_job = answer(:"delayed-job") { Ask.confirm("Do you want to use delayed jobs?") }
4
- set(:delayed_job, use_delayed_job)
5
- end
6
-
7
- def create
8
- add_delayed_job if selected?(:delayed_job)
9
- end
10
-
11
- def install
12
- heroku = load_recipe(:heroku)
13
- set(:heroku, heroku.installed?)
14
- add_delayed_job
15
- end
16
-
17
- def installed?
18
- gem_exists?(/delayed_job_active_record/)
19
- end
20
-
21
- def add_delayed_job
22
- gather_gem "delayed_job_active_record"
23
-
24
- general_config = "config.active_job.queue_adapter = :delayed_job"
25
- application(general_config)
26
- dev_config = "config.active_job.queue_adapter = :inline"
27
- application dev_config, env: "development"
28
-
29
- after(:gem_install) do
30
- generate "delayed_job:active_record"
31
- add_readme_section :internal_dependencies, :delayed_job
32
-
33
- if selected?(:heroku)
34
- gsub_file("Procfile", /^.*$/m) { |match| "#{match}worker: bundle exec rails jobs:work" }
35
- end
36
- end
37
- end
38
- end
@@ -1,9 +0,0 @@
1
- class Recipes::Git < Rails::AppBuilder
2
- def create
3
- git :init
4
- after(:database_creation) do
5
- git add: "."
6
- git commit: %{ -m 'Initial commit' }
7
- end
8
- end
9
- end
@@ -1,21 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe "Clockwork" do
4
- before :all do
5
- drop_dummy_database
6
- remove_project_directory
7
- create_dummy_project("clockwork" => true)
8
- end
9
-
10
- it "adds the Clockwork gem to Gemfile" do
11
- gemfile_content = IO.read("#{project_path}/Gemfile")
12
-
13
- expect(gemfile_content).to include("gem 'clockwork'")
14
- end
15
-
16
- it "creates the config for clockwork scheduler" do
17
- initializer_content = IO.read("#{project_path}/config/clock.rb")
18
-
19
- expect(initializer_content).to include("module Clockwork")
20
- end
21
- end