controller_resources 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 459e751d3a47e041aadfe3f37d1bb7fb0ff73fad
4
- data.tar.gz: b9f291d66260d8d4d461ac3a6428aa487ea877a7
3
+ metadata.gz: 6641d78693a54de498d10f9d1d53243bcaf1997d
4
+ data.tar.gz: 180ca43f6043f5a50a094e167cf399da6010b57c
5
5
  SHA512:
6
- metadata.gz: c051eb4fa63eef2cb3fe1fc23641450ad294f2fdd629722e96ff49d28f1c7f68ec299a9396b8b93c5abdf6f4946f80d052c946b6b3d17549803bb561f47b706b
7
- data.tar.gz: b09c0ad13de16a3d756e8dcc842e2665653e2d4cf04b785e370f1ee4802d23c8d5fe83b5cc82efb6642a950c0385befcba115bcb6bb48f4cbec57e5ddb2e2261
6
+ metadata.gz: 08d0bc4c3a24e6110df16fb9210d4def5884f3cfaee4254ee2ca99367ad0dccdf4ec897a72944daa90c003a3866cffaaa592e5ea5267f68960e71b00afc2e730
7
+ data.tar.gz: 0e968d80f3d199f1ed5b800e61d2190c3e1fbd226ced05a59e0ce4eca736772f39090fa118a75564e0bf4604bb078b97423f10f3da7d5a63e08c047a5463571f
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ /spec/dummy/log/*.log
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ rvm: 2.1.5
3
+ cache: bundle
4
+ before_script: bundle exec rake db:setup
5
+ script: bundle exec rspec
6
+ addons:
7
+ codeclimate:
8
+ repo_token:
9
+ secure: CxFMGcOhwkzowVZyys4fxSlsahNTNR6eBnRJmXqOhzjZwOoB7z0j3wfvIv8lDkKl03ayFUmToH147M4euh6RTbyCiFa9ti/bcVglWHaTDn6Qh5Ow6FWSJ76tIPAXpDaipn+ns8PQpsvrBISu6pB0MTgBbMwGQLpEUbDKtOCxexY=
10
+ deploy:
11
+ provider: rubygems
12
+ api_key:
13
+ secure: Ss+mExNaQHwVyJ0u5cN/BrrVEPZPUdojUxbVj5xa4fjT8OCmaeXY6DM24L1dDpysNLlExKzNVzK6JZNl1KFE03U6Be+S8sr5yJ3hlhPIqShA21+riiC/yeEnNw9oWv+EDDw2CD5TImF3u4YmGJohVdpCGl2U3tlRP5Kchz1vYjw=
14
+ gem: controller_resources
15
+ on:
16
+ tags: true
17
+ repo: tubbo/controller_resources
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # ControllerResources
2
2
 
3
+ [![Build Status](https://travis-ci.org/tubbo/controller_resources.svg)](https://travis-ci.org/tubbo/controller_resources)
4
+ [![Code Climate](https://codeclimate.com/github/tubbo/controller_resources/badges/gpa.svg)](https://codeclimate.com/github/tubbo/controller_resources)
5
+ [![Test Coverage](https://codeclimate.com/github/tubbo/controller_resources/badges/coverage.svg)](https://codeclimate.com/github/tubbo/controller_resources)
6
+
3
7
  A Rails engine that unites DecentExposure, StrongParameters, Devise (if
4
8
  installed) and Draper (if installed) to provide one hell of an awesome
5
9
  controller DSL.
@@ -4,27 +4,28 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'controller_resources/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "controller_resources"
7
+ spec.name = 'controller_resources'
8
8
  spec.version = ControllerResources::VERSION
9
- spec.authors = ["Tom Scott"]
10
- spec.email = ["tubbo@psychedeli.ca"]
9
+ spec.authors = ['Tom Scott']
10
+ spec.email = ['tubbo@psychedeli.ca']
11
11
  spec.summary = %q{A "glue" for decent_exposure, responders, draper and strong_params}
12
12
  spec.description = %q{A "glue" for decent_exposure, responders, draper and strong_params}
13
- spec.homepage = "https://github.com/tubbo/controller_resources"
14
- spec.license = "MIT"
13
+ spec.homepage = 'https://github.com/tubbo/controller_resources'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^|spec/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", "~> 3"
24
- spec.add_development_dependency "pg"
25
- spec.add_development_dependency "generator_spec"
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec', '~> 3'
24
+ spec.add_development_dependency 'pg'
25
+ spec.add_development_dependency 'generator_spec'
26
+ spec.add_development_dependency 'codeclimate-test-reporter'
26
27
 
27
- spec.add_dependency "rails", ">= 4.0.0"
28
- spec.add_dependency "decent_exposure"
29
- spec.add_dependency "responders"
28
+ spec.add_dependency 'rails', '>= 4.0.0'
29
+ spec.add_dependency 'decent_exposure'
30
+ spec.add_dependency 'responders'
30
31
  end
@@ -27,6 +27,7 @@ module ControllerResources
27
27
  class_attribute :_singleton_resource
28
28
  class_attribute :_collection_resource
29
29
  class_attribute :_finder_method
30
+ class_attribute :_protected_actions
30
31
 
31
32
  # Use the StrongParameters strategy in DecentExposure
32
33
  decent_configuration do
@@ -46,6 +47,7 @@ module ControllerResources
46
47
  name = self.name.gsub(/Controller/, '').tableize if name.nil?
47
48
  self._singleton_resource = name.to_s.singularize.to_sym
48
49
  self._collection_resource = name.to_s.pluralize.to_sym
50
+ self._protected_actions = %w(create update destroy edit new)
49
51
 
50
52
  class_eval <<-RUBY
51
53
  expose :#{model}, except: %w(index)
@@ -70,13 +72,17 @@ module ControllerResources
70
72
  self._edit_params = hash_of_params
71
73
  end
72
74
 
75
+ def protect(action)
76
+ self._protected_actions << action
77
+ end
78
+
73
79
  private
74
80
  def authenticate
75
- "before_action :authenticate_user!, except: %w(index show)"
81
+ "before_action :authenticate_user!, only: %w(#{_protected_actions.join(' ')})"
76
82
  end
77
83
 
78
84
  def authorize
79
- "authorize_actions_for #{model_class}"
85
+ "authorize_actions_for #{model.to_s.classify}, only: %w(#{_protected_actions.join(' ')})"
80
86
  end
81
87
 
82
88
  def model_class
@@ -1,3 +1,3 @@
1
1
  module ControllerResources
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  # Configure Rails Environment
2
2
  ENV["RAILS_ENV"] = "test"
3
3
 
4
+ require "codeclimate-test-reporter"
5
+ CodeClimate::TestReporter.start
6
+
4
7
  require "bundler/setup"
5
8
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
6
9
  require "rails/test_help"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: controller_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Scott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-20 00:00:00.000000000 Z
11
+ date: 2015-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: codeclimate-test-reporter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rails
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -132,9 +146,9 @@ extra_rdoc_files: []
132
146
  files:
133
147
  - ".gitignore"
134
148
  - ".ruby-version"
149
+ - ".travis.yml"
135
150
  - Gemfile
136
151
  - LICENSE.txt
137
- - MIT-LICENSE
138
152
  - README.md
139
153
  - Rakefile
140
154
  - bin/rails
@@ -210,16 +224,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
224
  version: '0'
211
225
  requirements: []
212
226
  rubyforge_project:
213
- rubygems_version: 2.2.2
227
+ rubygems_version: 2.4.5
214
228
  signing_key:
215
229
  specification_version: 4
216
230
  summary: A "glue" for decent_exposure, responders, draper and strong_params
217
231
  test_files:
218
232
  - ".gitignore"
219
233
  - ".ruby-version"
234
+ - ".travis.yml"
220
235
  - Gemfile
221
236
  - LICENSE.txt
222
- - MIT-LICENSE
223
237
  - README.md
224
238
  - Rakefile
225
239
  - bin/rails
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2014 YOURNAME
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.