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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fd59590a454f141e47a7b05b95fc2d5f65b1090
4
- data.tar.gz: b11f7656978a084f13d54b9c106fd7a7505ffbf7
3
+ metadata.gz: b04a7870f2d5f9ea1f6d44317fb454f055936c6a
4
+ data.tar.gz: cf7db9e1b9697fa5fef3ef7c16349268c7c98744
5
5
  SHA512:
6
- metadata.gz: 813d08a035604474ff85f3c7e5bcd927dd3f29ac5425b021c64680b1cd301bed27cd4574164ddb8895eeba79b5693ebbf548d4273a3d0203c92d7e488b6657ab
7
- data.tar.gz: a821c3bd515630a6d284b5578bc3a252bb6a47830e9ed49ac3e7b9f0f8b1bb572f1214363bfd80b39a1ad4be7d1ee60f6bbcd7f3fafdc241d514dc00d45750bb
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
- And some optional integrations that will be asked for on project's creation:
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 shouldn't be necessary.*
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
@@ -4,6 +4,8 @@ require "gli"
4
4
  module Potassium::CLI
5
5
  extend GLI::App
6
6
 
7
+ program_desc "Plataus Rails application generator"
8
+
7
9
  version Potassium::VERSION
8
10
  hide_commands_without_desc true
9
11
 
@@ -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"
@@ -0,0 +1,2 @@
1
+ class AdminUserPolicy < ApplicationPolicy
2
+ end
@@ -0,0 +1,2 @@
1
+ class ActiveAdmin::CommentPolicy < ApplicationPolicy
2
+ end
@@ -2,39 +2,39 @@ module ApiErrorConcern
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do
5
- rescue_from "Exception" do |exc|
6
- logger.error exc.message
7
- logger.error exc.backtrace.join("\n")
8
- api_respond_error(:internal_server_error, {
9
- msg: "server_error",
10
- type: exc.class.to_s,
11
- detail: exc.message
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 |exc|
16
- api_respond_error(:not_found, {
17
- msg: "record_not_found",
18
- detail: exc.message
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 |exc|
23
- api_respond_error(:bad_request, {
24
- msg: "protected_attributes",
25
- detail: exc.message
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 |exc|
30
- api_respond_error(:bad_request, {
31
- msg: "invalid_attributes",
32
- errors: exc.record.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 api_respond_error(_status, _error_obj = {})
38
- render json: _error_obj, status: _status
37
+ def respond_api_error(status, error = {})
38
+ render json: error, status: status
39
39
  end
40
40
  end
@@ -1,5 +1,8 @@
1
1
  class Api::V1::BaseController < ApplicationController
2
- include ApiErrorConcern
2
+ if Rails.env.production?
3
+ include ApiErrorConcern
4
+ end
5
+
3
6
  self.responder = ApiResponder
4
7
 
5
8
  respond_to :json
@@ -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
+ }
@@ -1,4 +1,4 @@
1
1
  create_file '.rbenv-vars'
2
2
  template 'assets/.rbenv-vars.example', '.rbenv-vars.example'
3
3
  run "cp .rbenv-vars.example .rbenv-vars"
4
- create_file '.ruby-version', '2.0.0'
4
+ create_file '.ruby-version', '2.2'
@@ -40,6 +40,7 @@ run_action(:recipe_loading) do
40
40
  eval_file "recipes/production.rb"
41
41
  eval_file "recipes/git.rb"
42
42
  eval_file "recipes/api.rb"
43
+ eval_file "recipes/rack-cors.rb"
43
44
  end
44
45
 
45
46
  say "Gathered enough information. Applying the template. Wait a minute.", :green
@@ -1,3 +1,3 @@
1
1
  module Potassium
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  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: 1.2.3
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-06-06 00:00:00.000000000 Z
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