potassium 1.3.4 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6bc7c7e4daf4fbcae5761bb994cfabc9db7d8d64
4
- data.tar.gz: 919510d523b761b9c74a6d1bbdb23be36fd563e3
3
+ metadata.gz: 0bc9e2e96b1fa0d0f800bc2bf23617765c9c5b68
4
+ data.tar.gz: a844e31692d312c32791da3c08d1e95fb5ea661b
5
5
  SHA512:
6
- metadata.gz: 6ef25b0c7d589ee4afd3819beb04ecbf043c0cdb99d1dfe37fc728e3739eb3f37deae49a8e87b4207cdc28e2be24699062dc9171a3f3d3b086944f4eaa44605b
7
- data.tar.gz: 8a69de0aee82d9192eb69e18529c97256672ee873bb8708f486d784da47a81315754ea2323c4a7fad653aff696928d974409c106dbf9824e66f06445c6ab113d
6
+ metadata.gz: 6f67bdf66ad59d474cd4d9d29e38ccfc9780a5a56087baaf8b9c80c3121c49e391daf5830775a2e698e13ab238e75a7bcdc5a9d4750e979b1989c8ba5aef265a
7
+ data.tar.gz: 66a2c03ebbca40f554992b4a7cb596da2e8b876242164dfdd58b360caaa468b7376a0e679a2a6e87c61362d5302db72b23e28abedbe1ff7e71169e277d6fa18f
data/CHANGELOG.md CHANGED
@@ -68,8 +68,3 @@ Features:
68
68
 
69
69
  Bugfixes:
70
70
  - Removed `default_command` call to fix --version usage.
71
-
72
- ## 1.3.4
73
-
74
- Bugfixes:
75
- - Removed `rails` from the runtime dependencies due to terrible performance.
data/README.md CHANGED
@@ -4,9 +4,7 @@ A Rails application generator from [Platanus](https://github.com/platanus), insp
4
4
 
5
5
  ## Installation
6
6
 
7
- First, be sure to have Rails 4.2+ installed on your system.
8
-
9
- Then, install Potassium globally:
7
+ You have to install Potassium globally:
10
8
 
11
9
  $ gem install potassium
12
10
 
@@ -18,7 +16,7 @@ Use the `potassium create` command to create a new project:
18
16
 
19
17
  $ potassium create project-name
20
18
 
21
- It's important to note that it will perform a version check before running to ensure that you're using the latest potassium.
19
+ It's important to note that it will perform a version check before running to ensure that you're using the latest potassium. Also, if you feel that it's too slow, you may need to update rubygems: `gem update --system`.
22
20
 
23
21
  ### Adding recipes to an existing project
24
22
 
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
1
  require "bundler/gem_tasks"
2
-
@@ -7,7 +7,7 @@ module Potassium::CLI
7
7
  desc: "Performs a version check before running.",
8
8
  negatable: true
9
9
 
10
- c.action do |global_options, options, args|
10
+ c.action do |_global_options, options, _args|
11
11
  require "potassium/newest_version_ensurer"
12
12
 
13
13
  begin_creation = -> do
@@ -5,7 +5,7 @@ require "potassium/templates/application/recipe_generator"
5
5
  module Potassium::CLI
6
6
  desc "Installs a new feature or library"
7
7
  command :install do |c|
8
- c.action do |global_options, options, args|
8
+ c.action do |_global_options, _options, args|
9
9
  if args.first.nil?
10
10
  index = Ask.list('Select a recipe to install', recipe_name_list)
11
11
  ARGV << recipe_name_list[index]
@@ -14,7 +14,8 @@ module Potassium::CLI
14
14
  if recipe_exists?(args)
15
15
  Potassium::RecipeGenerator.start
16
16
  else
17
- puts "Oops! Sorry, that recipe doesn't exist. Were you looking for this?: #{guess_recipe_name(args)}"
17
+ guess = guess_recipe_name(args)
18
+ puts "Oops! Sorry, that recipe doesn't exist. Were you looking for this?: #{guess}"
18
19
  end
19
20
  end
20
21
  end
@@ -5,32 +5,24 @@ module ApiErrorConcern
5
5
  rescue_from "Exception" do |exception|
6
6
  logger.error exception.message
7
7
  logger.error exception.backtrace.join("\n")
8
- respond_api_error(:internal_server_error, {
9
- message: "server_error",
10
- type: exception.class.to_s,
11
- detail: exception.message
12
- })
8
+ respond_api_error(:internal_server_error, message: "server_error",
9
+ type: exception.class.to_s,
10
+ detail: exception.message)
13
11
  end
14
12
 
15
13
  rescue_from "ActiveRecord::RecordNotFound" do |exception|
16
- respond_api_error(:not_found, {
17
- message: "record_not_found",
18
- detail: exception.message
19
- })
14
+ respond_api_error(:not_found, message: "record_not_found",
15
+ detail: exception.message)
20
16
  end
21
17
 
22
18
  rescue_from "ActiveModel::ForbiddenAttributesError" do |exception|
23
- respond_api_error(:bad_request, {
24
- message: "protected_attributes",
25
- detail: exception.message
26
- })
19
+ respond_api_error(:bad_request, message: "protected_attributes",
20
+ detail: exception.message)
27
21
  end
28
22
 
29
23
  rescue_from "ActiveRecord::RecordInvalid" do |exception|
30
- respond_api_error(:bad_request, {
31
- message: "invalid_attributes",
32
- errors: exception.record.errors
33
- })
24
+ respond_api_error(:bad_request, message: "invalid_attributes",
25
+ errors: exception.record.errors)
34
26
  end
35
27
  end
36
28
 
@@ -3,15 +3,15 @@ class ApiResponder < ActionController::Responder
3
3
  return display_errors if has_errors?
4
4
  return head :no_content if delete?
5
5
 
6
- display resource, :status_code => status_code
6
+ display resource, status_code: status_code
7
7
  end
8
8
 
9
9
  private
10
10
 
11
- def display(resource, given_options = {})
12
- controller.render options.merge(given_options).merge({
13
- :json => serializer.as_json
14
- })
11
+ def display(_resource, given_options = {})
12
+ controller.render options.merge(given_options).merge(
13
+ json: serializer.as_json
14
+ )
15
15
  end
16
16
 
17
17
  def serializer
@@ -25,14 +25,14 @@ class ApiResponder < ActionController::Responder
25
25
 
26
26
  def status_code
27
27
  return :created if post?
28
- return :ok
28
+ :ok
29
29
  end
30
30
 
31
31
  def display_errors
32
- controller.render({
33
- :status => :unprocessable_entity,
34
- :json => { msg: "invalid_attributes", errors: format_errors }
35
- })
32
+ controller.render(
33
+ status: :unprocessable_entity,
34
+ json: { msg: "invalid_attributes", errors: format_errors }
35
+ )
36
36
  end
37
37
 
38
38
  def format_errors
@@ -11,7 +11,7 @@ module CallbackHelpers
11
11
 
12
12
  def before(action_name, wrap_in_action: false, &action)
13
13
  ensure_callbacks_variables_for_action(action_name)
14
- add_callback(action_name, :before, action)
14
+ add_callback(action_name, :before, wrap_action(action, wrap_in_action))
15
15
  end
16
16
 
17
17
  def run_action(action_name, &action)
@@ -32,7 +32,7 @@ module CallbackHelpers
32
32
 
33
33
  def wrap_action(action, wrap_in_action)
34
34
  return action unless wrap_in_action
35
- ->{ run_action(wrap_in_action, &action) }
35
+ -> { run_action(wrap_in_action, &action) }
36
36
  end
37
37
 
38
38
  def ensure_callbacks_variables_for_action(action_name)
@@ -1,14 +1,6 @@
1
1
  module GemHelpers
2
-
3
- def gem_exists?(regex)
4
- exists = false
5
- File.open("Gemfile").each_line do |line|
6
- if line =~ regex
7
- exists = true
8
- return
9
- end
10
- end
11
- exists
2
+ def gem_exists?(regexp)
3
+ File.open("Gemfile").each_line.any? { |line| line =~ regexp }
12
4
  end
13
5
 
14
6
  def gather_gem(name, *attributes)
@@ -20,7 +12,7 @@ module GemHelpers
20
12
  end
21
13
 
22
14
  def discard_gem(name)
23
- get(:gems).each do |environments, gems|
15
+ get(:gems).each do |_environments, gems|
24
16
  gems.delete_if do |gem_entry|
25
17
  gem_entry[:name] == name
26
18
  end
@@ -1,12 +1,17 @@
1
1
  module TemplateHelpers
2
2
  def load_recipe(recipe)
3
3
  return if exists?(recipe)
4
- eval_file "recipes/checks/#{recipe}.rb" rescue Exception
5
- eval_file "recipes/dependencies/#{recipe}.rb" rescue Exception
6
- eval_file "recipes/asks/#{recipe}.rb" rescue Exception
4
+ eval_file_with_rescue "recipes/checks/#{recipe}.rb"
5
+ eval_file_with_rescue "recipes/dependencies/#{recipe}.rb"
6
+ eval_file_with_rescue "recipes/asks/#{recipe}.rb"
7
7
  eval_file "recipes/#{recipe}.rb"
8
8
  end
9
9
 
10
+ def eval_file_with_rescue(source)
11
+ eval_file(source)
12
+ rescue StandardError
13
+ end
14
+
10
15
  def eval_file(source)
11
16
  location = File.expand_path(find_in_source_paths(source))
12
17
  unique_name = SecureRandom.hex
@@ -1,7 +1,9 @@
1
1
  recipe = ARGV.first
2
2
 
3
3
  # Consider all the recipe's questions as true
4
- def selected?(key, val = nil); true; end
4
+ def selected?(_key, _val = nil)
5
+ true
6
+ end
5
7
 
6
8
  run_action(:recipe_loading) do
7
9
  load_recipe(recipe)
@@ -13,11 +15,9 @@ run_action(:gem_install) do
13
15
  end
14
16
 
15
17
  # Ensure all the recipe's callbacks are executed
16
- get(:callbacks).each do |name, cbs|
17
-
18
+ get(:callbacks).each do |_name, callbacks|
18
19
  puts "Processing #{name} callbacks"
19
- cbs.each do |event, cb|
20
- cb.each {|callback| instance_exec(&callback) }
20
+ callbacks.each do |_event, event_callbacks|
21
+ event_callbacks.each { |callback| instance_exec(&callback) }
21
22
  end
22
-
23
23
  end
@@ -4,12 +4,12 @@ if selected?(:admin_mode)
4
4
  gather_gem 'activeadmin_addons'
5
5
  gather_gem 'active_skin'
6
6
 
7
- after(:gem_install, :wrap_in_action => :admin_install) do
7
+ after(:gem_install, wrap_in_action: :admin_install) do
8
8
  generate "active_admin:install"
9
9
 
10
10
  line = "ActiveAdmin.setup do |config|"
11
11
  initializer = "config/initializers/active_admin.rb"
12
- gsub_file initializer, /(#{Regexp.escape(line)})/mi do |match|
12
+ gsub_file initializer, /(#{Regexp.escape(line)})/mi do |_match|
13
13
  <<-HERE.gsub(/^ {11}/, '')
14
14
  class CustomFooter < ActiveAdmin::Component
15
15
  def build
@@ -25,13 +25,9 @@ if selected?(:admin_mode)
25
25
  line = "@import \"active_admin/base\";"
26
26
  style = "app/assets/stylesheets/active_admin.css.scss"
27
27
 
28
- style = if File.exist?(style)
29
- style
30
- else
31
- "app/assets/stylesheets/active_admin.scss"
32
- end
28
+ style = File.exist?(style) ? style : "app/assets/stylesheets/active_admin.scss"
33
29
 
34
- gsub_file style, /(#{Regexp.escape(line)})/mi do |match|
30
+ gsub_file style, /(#{Regexp.escape(line)})/mi do |_match|
35
31
  <<-HERE.gsub(/^ {11}/, '')
36
32
  #{line}
37
33
  $skinActiveColor: #001CEE;
@@ -1,11 +1,14 @@
1
1
  if selected?(:angular_admin)
2
2
 
3
3
  after(:admin_install) do
4
- copy_file 'assets/active_admin/init_activeadmin_angular.rb', 'config/initializers/init_activeadmin_angular.rb'
4
+ copy_file 'assets/active_admin/init_activeadmin_angular.rb',
5
+ 'config/initializers/init_activeadmin_angular.rb'
5
6
 
6
7
  create_file 'app/assets/javascripts/admin_app.js', "angular.module('ActiveAdmin', []);"
7
8
 
8
- copy_file 'assets/active_admin/active_admin.js.coffee', 'app/assets/javascripts/active_admin.js.coffee', force: true
9
+ copy_file 'assets/active_admin/active_admin.js.coffee',
10
+ 'app/assets/javascripts/active_admin.js.coffee',
11
+ force: true
9
12
 
10
13
  empty_directory 'app/assets/javascripts/admin'
11
14
  empty_directory 'app/assets/javascripts/admin/controllers'
@@ -1,5 +1,5 @@
1
1
  authentication_framework = {
2
- devise: ->{
2
+ devise: -> do
3
3
  gather_gem 'devise'
4
4
  gather_gem 'devise-i18n'
5
5
 
@@ -7,22 +7,22 @@ authentication_framework = {
7
7
  generate "devise:install"
8
8
 
9
9
  if auth_model = get(:authentication_model)
10
- generate "devise #{auth_model.to_s}"
10
+ generate "devise #{auth_model}"
11
11
  end
12
12
 
13
- gsub_file "config/initializers/devise.rb", /(\# config.secret_key.+)/i do |match|
14
- match = "config.secret_key = ENV['DEVISE_SECRET_KEY']"
13
+ gsub_file "config/initializers/devise.rb", /(\# config.secret_key.+)/i do |_match|
14
+ "config.secret_key = ENV['DEVISE_SECRET_KEY']"
15
15
  end
16
16
 
17
- gsub_file "config/initializers/devise.rb", /(config.mailer_sender.+)/i do |match|
18
- match = "config.mailer_sender = ENV['DEFAULT_EMAIL_ADDRESS']"
17
+ gsub_file "config/initializers/devise.rb", /(config.mailer_sender.+)/i do |_match|
18
+ "config.mailer_sender = ENV['DEFAULT_EMAIL_ADDRESS']"
19
19
  end
20
20
 
21
21
  append_to_file '.rbenv-vars.example', 'DEVISE_SECRET_KEY='
22
22
  end
23
- }
23
+ end
24
24
  }
25
25
 
26
26
  if get(:authentication)
27
- instance_exec(&(authentication_framework[get(:authentication)] || ->{ }))
27
+ instance_exec(&(authentication_framework[get(:authentication)] || -> {}))
28
28
  end
@@ -5,5 +5,5 @@ after(:database_creation) do
5
5
 
6
6
  git :init
7
7
  git add: "."
8
- git commit: %Q{ -m 'Initial commit' }
8
+ git commit: %{ -m 'Initial commit' }
9
9
  end
@@ -1,8 +1,8 @@
1
1
  if selected?(:paperclip)
2
2
  gather_gem('paperclip', '~> 4.3')
3
3
 
4
- gsub_file "config/environments/production.rb", /^end$/o do |match|
5
- match = %q{
4
+ gsub_file "config/environments/production.rb", /^end$/o do |_match|
5
+ %{
6
6
 
7
7
  # Paperclip support for S3
8
8
  config.paperclip_defaults = {
@@ -1,3 +1,3 @@
1
1
  gsub_file "config/environments/production.rb", /(\# config.action_mailer.+)/i do |match|
2
- match = "#{match}\n config.action_mailer.default_options = {from: ENV['DEFAULT_EMAIL_ADDRESS']}\n"
2
+ "#{match}\n config.action_mailer.default_options = {from: ENV['DEFAULT_EMAIL_ADDRESS']}\n"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  authorization_framework = {
2
- pundit: ->{
2
+ pundit: -> do
3
3
  gather_gem 'pundit'
4
4
 
5
5
  after(:gem_install) do
@@ -17,14 +17,17 @@ authorization_framework = {
17
17
  "config.authorization_adapter = ActiveAdmin::PunditAdapter\n"
18
18
  end
19
19
 
20
- template "assets/active_admin/pundit_page_policy.rb", "app/policies/active_admin/page_policy.rb"
21
- template "assets/active_admin/comment_policy.rb", "app/policies/active_admin/comment_policy.rb"
22
- template "assets/active_admin/admin_user_policy.rb", "app/policies/admin_user_policy.rb"
20
+ template "assets/active_admin/pundit_page_policy.rb",
21
+ "app/policies/active_admin/page_policy.rb"
22
+ template "assets/active_admin/comment_policy.rb",
23
+ "app/policies/active_admin/comment_policy.rb"
24
+ template "assets/active_admin/admin_user_policy.rb",
25
+ "app/policies/admin_user_policy.rb"
23
26
  end
24
27
  end
25
- }
28
+ end
26
29
  }
27
30
 
28
31
  if get(:authorization)
29
- instance_exec(&(authorization_framework[get(:authorization)] || ->{ }))
32
+ instance_exec(&(authorization_framework[get(:authorization)] || -> {}))
30
33
  end
@@ -26,6 +26,7 @@ after(:gem_install) do
26
26
  run "guard init"
27
27
  end
28
28
 
29
- gsub_file 'config/environments/development.rb', /config.action_mailer.raise_delivery_errors = false\n/ do
29
+ raise_delivery_errors_regexp = /config.action_mailer.raise_delivery_errors = false\n/
30
+ gsub_file 'config/environments/development.rb', raise_delivery_errors_regexp do
30
31
  "config.action_mailer.raise_delivery_errors = true"
31
32
  end
@@ -2,11 +2,11 @@ set :app_name, @app_name
2
2
  set :titleized_app_name, get(:app_name).titleize
3
3
  set :underscorized_app_name, get(:app_name).underscore
4
4
 
5
- default_env({
6
- 'DB_NAME' => "#{get(:underscorized_app_name)}",
5
+ default_env(
6
+ 'DB_NAME' => get(:underscorized_app_name).to_s,
7
7
  'DB_USER' => "root",
8
8
  'DB_PASSWORD' => ''
9
- })
9
+ )
10
10
 
11
11
  run_action(:cleaning) do
12
12
  clean_gemfile
@@ -5,7 +5,7 @@ module Potassium
5
5
  :counter, :started
6
6
 
7
7
  DEFAULT_ATTRIBUTES = {
8
- wait_condition: -> { },
8
+ wait_condition: -> {},
9
9
  base_message: "",
10
10
  interval: 0.4,
11
11
  message_continuations: ["", ".", "..", "..."]
@@ -13,7 +13,7 @@ module Potassium
13
13
 
14
14
  def initialize(attributes = {})
15
15
  DEFAULT_ATTRIBUTES.merge(attributes).each do |key, value|
16
- self.public_send("#{key}=", value)
16
+ public_send("#{key}=", value)
17
17
  end
18
18
  self.started = false
19
19
  self.counter = 0
@@ -45,7 +45,7 @@ module Potassium
45
45
  end
46
46
 
47
47
  def clear_message
48
- print "\r#{" " * (base_message.size * 2)}\r"
48
+ print "\r#{' ' * (base_message.size * 2)}\r"
49
49
  end
50
50
 
51
51
  def already_started_message
@@ -1,3 +1,4 @@
1
1
  module Potassium
2
- VERSION = "1.3.4"
2
+ VERSION = "1.3.5"
3
+ RAILS_VERSION = "~> 4.2.0"
3
4
  end
data/potassium.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Potassium::VERSION
9
9
  spec.authors = ["juliogarciag"]
10
10
  spec.email = ["julioggonz@gmail.com"]
11
- spec.summary = %q{An application generator from Platanus}
12
- spec.description = %q{An application generator from Platanus}
11
+ spec.summary = "An application generator from Platanus"
12
+ spec.description = "An application generator from Platanus"
13
13
  spec.homepage = "https://github.com/platanus/potassium"
14
14
  spec.license = "MIT"
15
15
 
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_runtime_dependency "rails", Potassium::RAILS_VERSION
23
24
  spec.add_runtime_dependency "gli", "~> 2.12.2"
24
25
  spec.add_runtime_dependency "inquirer", "~> 0.2"
25
26
  spec.add_runtime_dependency "gems", "~> 0.8"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: potassium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - juliogarciag
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 4.2.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.2.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: gli
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -214,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
228
  version: '0'
215
229
  requirements: []
216
230
  rubyforge_project:
217
- rubygems_version: 2.4.5.1
231
+ rubygems_version: 2.5.1
218
232
  signing_key:
219
233
  specification_version: 4
220
234
  summary: An application generator from Platanus