potassium 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +0 -5
- data/README.md +2 -4
- data/Rakefile +0 -1
- data/lib/potassium/cli/commands/create.rb +1 -1
- data/lib/potassium/cli/commands/install.rb +3 -2
- data/lib/potassium/templates/application/assets/api/api_error_concern.rb +9 -17
- data/lib/potassium/templates/application/assets/api/responder.rb +10 -10
- data/lib/potassium/templates/application/helpers/callback-helpers.rb +2 -2
- data/lib/potassium/templates/application/helpers/gem-helpers.rb +3 -11
- data/lib/potassium/templates/application/helpers/template-helpers.rb +8 -3
- data/lib/potassium/templates/application/recipe_template.rb +6 -6
- data/lib/potassium/templates/application/recipes/admin.rb +4 -8
- data/lib/potassium/templates/application/recipes/angular_admin.rb +5 -2
- data/lib/potassium/templates/application/recipes/devise.rb +8 -8
- data/lib/potassium/templates/application/recipes/git.rb +1 -1
- data/lib/potassium/templates/application/recipes/paperclip.rb +2 -2
- data/lib/potassium/templates/application/recipes/production.rb +1 -1
- data/lib/potassium/templates/application/recipes/pundit.rb +9 -6
- data/lib/potassium/templates/application/recipes/testing.rb +2 -1
- data/lib/potassium/templates/application/template.rb +3 -3
- data/lib/potassium/text_spinner.rb +3 -3
- data/lib/potassium/version.rb +2 -1
- data/potassium.gemspec +3 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bc9e2e96b1fa0d0f800bc2bf23617765c9c5b68
|
4
|
+
data.tar.gz: a844e31692d312c32791da3c08d1e95fb5ea661b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f67bdf66ad59d474cd4d9d29e38ccfc9780a5a56087baaf8b9c80c3121c49e391daf5830775a2e698e13ab238e75a7bcdc5a9d4750e979b1989c8ba5aef265a
|
7
|
+
data.tar.gz: 66a2c03ebbca40f554992b4a7cb596da2e8b876242164dfdd58b360caaa468b7376a0e679a2a6e87c61362d5302db72b23e28abedbe1ff7e71169e277d6fa18f
|
data/CHANGELOG.md
CHANGED
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
|
-
|
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
@@ -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 |
|
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
|
-
|
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
|
-
|
10
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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, :
|
6
|
+
display resource, status_code: status_code
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
|
-
def display(
|
12
|
-
controller.render options.merge(given_options).merge(
|
13
|
-
:
|
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
|
-
|
28
|
+
:ok
|
29
29
|
end
|
30
30
|
|
31
31
|
def display_errors
|
32
|
-
controller.render(
|
33
|
-
:
|
34
|
-
:
|
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
|
-
|
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 |
|
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
|
-
|
5
|
-
|
6
|
-
|
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?(
|
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 |
|
17
|
-
|
18
|
+
get(:callbacks).each do |_name, callbacks|
|
18
19
|
puts "Processing #{name} callbacks"
|
19
|
-
|
20
|
-
|
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, :
|
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 |
|
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 =
|
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 |
|
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',
|
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',
|
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
|
10
|
+
generate "devise #{auth_model}"
|
11
11
|
end
|
12
12
|
|
13
|
-
gsub_file "config/initializers/devise.rb", /(\# config.secret_key.+)/i do |
|
14
|
-
|
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 |
|
18
|
-
|
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
|
@@ -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 |
|
5
|
-
|
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
|
-
|
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",
|
21
|
-
|
22
|
-
template "assets/active_admin/
|
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
|
-
|
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' =>
|
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
|
-
|
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#{
|
48
|
+
print "\r#{' ' * (base_message.size * 2)}\r"
|
49
49
|
end
|
50
50
|
|
51
51
|
def already_started_message
|
data/lib/potassium/version.rb
CHANGED
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 =
|
12
|
-
spec.description =
|
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
|
+
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.
|
231
|
+
rubygems_version: 2.5.1
|
218
232
|
signing_key:
|
219
233
|
specification_version: 4
|
220
234
|
summary: An application generator from Platanus
|