potassium 1.2.3 → 1.2.4
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 +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +23 -2
- data/lib/potassium/cli.rb +2 -0
- data/lib/potassium/cli/commands/create.rb +3 -0
- data/lib/potassium/templates/application/assets/active_admin/admin_user_policy.rb +2 -0
- data/lib/potassium/templates/application/assets/active_admin/comment_policy.rb +2 -0
- data/lib/potassium/templates/application/assets/api/api_error_concern.rb +21 -21
- data/lib/potassium/templates/application/assets/api/base_controller.rb +4 -1
- data/lib/potassium/templates/application/recipes/admin.rb +15 -0
- data/lib/potassium/templates/application/recipes/pundit.rb +2 -0
- data/lib/potassium/templates/application/recipes/rack-cors.rb +13 -0
- data/lib/potassium/templates/application/recipes/rbenv.rb +1 -1
- data/lib/potassium/templates/application/template.rb +1 -0
- data/lib/potassium/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b04a7870f2d5f9ea1f6d44317fb454f055936c6a
|
4
|
+
data.tar.gz: cf7db9e1b9697fa5fef3ef7c16349268c7c98744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 435f4c6bbcaa355f066da5fc7c3c39eb4d77214959b1f2a8521625d7b414c3561b607fa9cd9fdafe8059aef1c09d3cd41a33505c727ca84a4dff6239225f749f
|
7
|
+
data.tar.gz: fbc899e85333d47a92cc2ee5896f691ff35651442b2f308ae9441143cfc5f18403c06d7c10c1894146820b05ec06b65f6deef1cbf8b9459bc374d29fedb3a8da
|
data/CHANGELOG.md
CHANGED
@@ -20,7 +20,7 @@ Bugfixes:
|
|
20
20
|
Features:
|
21
21
|
- Added `aws-sdk` gem (< 2).
|
22
22
|
- Added `activeadmin_addons` when using ActiveAdmin.
|
23
|
-
- Added AngularJS support for ActiveAdmin.
|
23
|
+
- Added AngularJS support for ActiveAdmin.
|
24
24
|
|
25
25
|
Chore:
|
26
26
|
- Removed several questions for ActiveAdmin support.
|
@@ -46,3 +46,8 @@ Features:
|
|
46
46
|
- Versionist Support.
|
47
47
|
- `simple_token_authentication`, `active_model_serializers` and `responders` gem.
|
48
48
|
- A default responder for API common behavior.
|
49
|
+
|
50
|
+
## 1.2.4
|
51
|
+
|
52
|
+
Features:
|
53
|
+
- Added Rack CORS gem and config
|
data/README.md
CHANGED
@@ -26,21 +26,30 @@ Potassium Rails apps includes the following gems and technologies:
|
|
26
26
|
- [RSpec](http://rspec.info) for unit and integration testing.
|
27
27
|
- [FactoryGirl](https://github.com/thoughtbot/factory_girl) for test factories.
|
28
28
|
- [Guard](http://guardgem.org) for continuous testing and other watch-related tasks.
|
29
|
+
- [AWS-SDK](https://github.com/aws/aws-sdk-ruby) for file uploads, sdks, etc and because we use AWS.
|
29
30
|
|
30
|
-
|
31
|
+
The following optional integrations are added too:
|
31
32
|
|
32
33
|
- [PostgreSQL](http://www.postgresql.org) or [MySQL](https://www.mysql.com) for the database.
|
33
34
|
- [Devise](https://github.com/plataformatec/devise) for authentication.
|
34
35
|
- [ActiveAdmin](http://activeadmin.info) for admin interfaces.
|
36
|
+
- [ActiveAdminAddons](https://github.com/platanus/activeadmin_addons) for some help with ActiveAdmin.
|
35
37
|
- [Pundit](https://github.com/elabs/pundit) for role-based authorization.
|
36
38
|
|
39
|
+
And, finally, we also include optional API support, which includes:
|
40
|
+
|
41
|
+
- [Responders](https://github.com/plataformatec/responders) for dry-ing our api controllers.
|
42
|
+
- [Versionist](https://github.com/bploetz/versionist) for some flexible api versioning.
|
43
|
+
- [ActiveModel::Serializers](https://github.com/rails-api/active_model_serializers) for record serialization.
|
44
|
+
- [Simple Token Authentication](https://github.com/gonzalo-bulnes/simple_token_authentication) for stateless API authentication.
|
45
|
+
|
37
46
|
## Contributing
|
38
47
|
|
39
48
|
### How do I add something new to Potassium?
|
40
49
|
|
41
50
|
In the [lib/potassium/templates/application](lib/potassium/templates/application) folder, you will find [the template](lib/potassium/templates/application/template.rb). You should follow the next conventions to add something:
|
42
51
|
|
43
|
-
*__NOTE:__ If you only want to use Potassium but not to add something new, the next parts
|
52
|
+
*__NOTE:__ If you only want to use Potassium but not to add something new, the next parts can be easily skipped.*
|
44
53
|
|
45
54
|
#### Ask
|
46
55
|
|
@@ -115,3 +124,15 @@ For example, if we want to create an optional recipe to add a gem called `banana
|
|
115
124
|
#### The DSL
|
116
125
|
|
117
126
|
To see further documentation of what we added to the rails template's DSL, check the [DSL documentation](docs/dsl.md). Remember that the DSL we are documenting is an extension over the [Rails Application Template DSL](http://edgeguides.rubyonrails.org/rails_application_templates.html), that itself is a dsl based on [Thor](https://github.com/erikhuda/thor/wiki).
|
127
|
+
|
128
|
+
## Credits
|
129
|
+
|
130
|
+
Thank you [contributors](https://github.com/platanus/potassium/graphs/contributors)!
|
131
|
+
|
132
|
+
<img src="http://platan.us/gravatar_with_text.png" alt="Platanus" width="250"/>
|
133
|
+
|
134
|
+
potassium is maintained by [platanus](http://platan.us).
|
135
|
+
|
136
|
+
## License
|
137
|
+
|
138
|
+
Potassium is © 2014 platanus, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.
|
data/lib/potassium/cli.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module Potassium::CLI
|
2
|
+
desc "Create a new Potassium Rails project."
|
3
|
+
arg 'app_path'
|
2
4
|
command :create do |c|
|
5
|
+
c.default_desc "Create a new project."
|
3
6
|
c.action do |global_options, options, args|
|
4
7
|
require "potassium/templates/application/generator"
|
5
8
|
require "potassium/template_finder"
|
@@ -2,39 +2,39 @@ module ApiErrorConcern
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
5
|
-
rescue_from "Exception" do |
|
6
|
-
logger.error
|
7
|
-
logger.error
|
8
|
-
|
9
|
-
|
10
|
-
type:
|
11
|
-
detail:
|
5
|
+
rescue_from "Exception" do |exception|
|
6
|
+
logger.error exception.message
|
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
12
|
})
|
13
13
|
end
|
14
14
|
|
15
|
-
rescue_from "ActiveRecord::RecordNotFound" do |
|
16
|
-
|
17
|
-
|
18
|
-
detail:
|
15
|
+
rescue_from "ActiveRecord::RecordNotFound" do |exception|
|
16
|
+
respond_api_error(:not_found, {
|
17
|
+
message: "record_not_found",
|
18
|
+
detail: exception.message
|
19
19
|
})
|
20
20
|
end
|
21
21
|
|
22
|
-
rescue_from "ActiveModel::ForbiddenAttributesError" do |
|
23
|
-
|
24
|
-
|
25
|
-
detail:
|
22
|
+
rescue_from "ActiveModel::ForbiddenAttributesError" do |exception|
|
23
|
+
respond_api_error(:bad_request, {
|
24
|
+
message: "protected_attributes",
|
25
|
+
detail: exception.message
|
26
26
|
})
|
27
27
|
end
|
28
28
|
|
29
|
-
rescue_from "ActiveRecord::RecordInvalid" do |
|
30
|
-
|
31
|
-
|
32
|
-
errors:
|
29
|
+
rescue_from "ActiveRecord::RecordInvalid" do |exception|
|
30
|
+
respond_api_error(:bad_request, {
|
31
|
+
message: "invalid_attributes",
|
32
|
+
errors: exception.record.errors
|
33
33
|
})
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
render json:
|
37
|
+
def respond_api_error(status, error = {})
|
38
|
+
render json: error, status: status
|
39
39
|
end
|
40
40
|
end
|
@@ -2,6 +2,7 @@ if get(:admin_mode)
|
|
2
2
|
if equals?(:authentication, :devise)
|
3
3
|
gather_gem 'activeadmin', github: 'activeadmin'
|
4
4
|
gather_gem 'activeadmin_addons'
|
5
|
+
gather_gem 'active_skin'
|
5
6
|
|
6
7
|
after(:gem_install, :wrap_in_action => :admin_install) do
|
7
8
|
generate "active_admin:install"
|
@@ -20,6 +21,20 @@ if get(:admin_mode)
|
|
20
21
|
config.view_factory.footer = CustomFooter
|
21
22
|
HERE
|
22
23
|
end
|
24
|
+
|
25
|
+
line = "@import \"active_admin/base\";"
|
26
|
+
style = "app/assets/stylesheets/active_admin.css.scss"
|
27
|
+
gsub_file style, /(#{Regexp.escape(line)})/mi do |match|
|
28
|
+
<<-HERE.gsub(/^ {11}/, '')
|
29
|
+
#{line}
|
30
|
+
$skinActiveColor: #001CEE;
|
31
|
+
$skinHeaderBck: #002744;
|
32
|
+
$panelHeaderBck: #002744;
|
33
|
+
//$skinLogo: $skinHeaderBck image-url("logo_admin.png") no-repeat center center;
|
34
|
+
|
35
|
+
@import "active_skin";
|
36
|
+
HERE
|
37
|
+
end
|
23
38
|
end
|
24
39
|
else
|
25
40
|
say "ActiveAdmin can't be installed because Devise isn't enabled.", :red
|
@@ -18,6 +18,8 @@ authorization_framework = {
|
|
18
18
|
end
|
19
19
|
|
20
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"
|
21
23
|
end
|
22
24
|
end
|
23
25
|
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
gather_gem('rack-cors', '~> 0.4.0')
|
2
|
+
application %{
|
3
|
+
# Enables CORS for all requests
|
4
|
+
config.middleware.insert_before 0, "Rack::Cors" do
|
5
|
+
allow do
|
6
|
+
origins '*'
|
7
|
+
resource '*',
|
8
|
+
:headers => :any,
|
9
|
+
:expose => ['X-Page', 'X-PageTotal'],
|
10
|
+
:methods => [:get, :post, :delete, :put, :options]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
}
|
data/lib/potassium/version.rb
CHANGED
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: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- juliogarciag
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,6 +106,8 @@ files:
|
|
106
106
|
- lib/potassium/templates/application/assets/.pryrc
|
107
107
|
- lib/potassium/templates/application/assets/.rbenv-vars.example
|
108
108
|
- lib/potassium/templates/application/assets/active_admin/active_admin.js.coffee
|
109
|
+
- lib/potassium/templates/application/assets/active_admin/admin_user_policy.rb
|
110
|
+
- lib/potassium/templates/application/assets/active_admin/comment_policy.rb
|
109
111
|
- lib/potassium/templates/application/assets/active_admin/init_activeadmin_angular.rb
|
110
112
|
- lib/potassium/templates/application/assets/active_admin/pundit_page_policy.rb
|
111
113
|
- lib/potassium/templates/application/assets/api/api_error_concern.rb
|
@@ -143,6 +145,7 @@ files:
|
|
143
145
|
- lib/potassium/templates/application/recipes/production.rb
|
144
146
|
- lib/potassium/templates/application/recipes/pry.rb
|
145
147
|
- lib/potassium/templates/application/recipes/pundit.rb
|
148
|
+
- lib/potassium/templates/application/recipes/rack-cors.rb
|
146
149
|
- lib/potassium/templates/application/recipes/rbenv.rb
|
147
150
|
- lib/potassium/templates/application/recipes/readme.rb
|
148
151
|
- lib/potassium/templates/application/recipes/testing.rb
|