resourcerer 2.0.3 → 2.0.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
- SHA1:
3
- metadata.gz: ecc554dcf8cff06fd33d74f17763e4be93830c12
4
- data.tar.gz: 822ece730ec85a39775250b14163549407c3d4fc
2
+ SHA256:
3
+ metadata.gz: 1097af8bba31336db7caf41e84c05587cb1f43fb3561405c28e73f9a034d510d
4
+ data.tar.gz: fce0ba2273e4632d6ea879d97d3b3de6a66c9ba8398416ad488b8b81ade15bcb
5
5
  SHA512:
6
- metadata.gz: 39261e118675be12572f8a52e1df8de3049e401f2d47f08a6d3bb63efa8f64a54ea71d948ea9526c7bed0bb034f05cefa30a8d4985e7398c709baa1e1a802018
7
- data.tar.gz: 435fe862ac93948f2f4122555463f73ef079d8ca0172baadef5bb7392374975b17a7e4cbd4228c9ecb20e6c6ba1c5ed87e13445e830016b3a753fab1c4663ff2
6
+ metadata.gz: e8cc87a1601df6643f9abb2134b236379f00bca9a39ae088f2670051651b2e422f896c1684602c215d1a98c72576a2f8c46f3310839fd4cc0d2a392990febdc8
7
+ data.tar.gz: 9e9d1ab0976fcdccb8987b90d2368ae46dc65f1848787a51644e31ba213e16351b77a85739f9b2ab49ab7c02a3cda1687380e3f0dfc876273038c1cc3e2499ce
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## Resourcerer 2.0.4 (2021-02-24) ##
2
+
3
+ * Update `ruby_version` requirement in gemspec to allow usage in Ruby 3.0.
4
+
5
+ ## Resourcerer 2.0.3 (2017-04-03) ##
6
+
7
+ * Complete rewrite, embrace functions as first-class citizens for configuration.
data/README.md CHANGED
@@ -1,5 +1,23 @@
1
- Resourcerer [![Gem Version](https://img.shields.io/gem/v/resourcerer.svg?colorB=e9573f)](https://rubygems.org/gems/resourcerer) [![Build Status](https://travis-ci.org/ElMassimo/resourcerer.svg)](https://travis-ci.org/ElMassimo/resourcerer) [![Coverage Status](https://coveralls.io/repos/github/ElMassimo/resourcerer/badge.svg?branch=master)](https://coveralls.io/github/ElMassimo/resourcerer?branch=master) [![Inline docs](http://inch-ci.org/github/ElMassimo/resourcerer.svg)](http://inch-ci.org/github/ElMassimo/resourcerer) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ElMassimo/resourcerer/blob/master/LICENSE.txt)
2
- =====================
1
+ <h1 align="center">
2
+ Resourcerer
3
+ <p align="center">
4
+ <a href="https://github.com/ElMassimo/resourcerer/actions">
5
+ <img alt="Build Status" src="https://github.com/ElMassimo/resourcerer/workflows/build/badge.svg"/>
6
+ </a>
7
+ <a href="https://codeclimate.com/github/ElMassimo/vite_ruby">
8
+ <img alt="Maintainability" src="https://codeclimate.com/github/ElMassimo/vite_ruby/badges/gpa.svg"/>
9
+ </a>
10
+ <a href="https://codeclimate.com/github/ElMassimo/resourcerer">
11
+ <img alt="Test Coverage" src="https://codeclimate.com/github/ElMassimo/resourcerer/badges/coverage.svg"/>
12
+ </a>
13
+ <a href="https://rubygems.org/gems/resourcerer">
14
+ <img alt="Gem Version" src="https://img.shields.io/gem/v/resourcerer.svg?colorB=e9573f"/>
15
+ </a>
16
+ <a href="https://github.com/ElMassimo/resourcerer/blob/master/LICENSE.txt">
17
+ <img alt="License" src="https://img.shields.io/badge/license-MIT-428F7E.svg"/>
18
+ </a>
19
+ </p>
20
+ </h1>
3
21
 
4
22
  A small library to help you avoid boilerplate for standard CRUD actions, while improving your controllers' readibility.
5
23
 
@@ -240,14 +258,14 @@ resource :band, assign: ->(band, attrs) { band.set_info(attrs) }
240
258
  ```
241
259
 
242
260
 
243
- ## Advanced Configuration with `resource_config`
261
+ ## Advanced Configuration with `resourcerer_config`
244
262
 
245
- You can define configuration presets with the `resource_config` method to reuse
263
+ You can define configuration presets with the `resourcerer_config` method to reuse
246
264
  them later in different resource definitions.
247
265
 
248
266
  ```ruby
249
- resource_config :cool_find, find: ->{ very_cool_find_code }
250
- resource_config :cool_build, build: ->{ very_cool_build_code }
267
+ resourcerer_config :cool_find, find: ->{ very_cool_find_code }
268
+ resourcerer_config :cool_build, build: ->{ very_cool_build_code }
251
269
 
252
270
  resource :band, using: [:cool_find, :cool_build]
253
271
  resource :another_band, using: :cool_build
@@ -16,19 +16,20 @@ module Resourcerer
16
16
  instance_accessor: false, instance_predicate: false
17
17
  end
18
18
 
19
- def resource(*args)
20
- Resource.new(self, *args).get(self)
19
+ def resource(name, **options)
20
+ Resource.new(self, name, **options).get(self)
21
21
  end
22
22
 
23
23
  module ClassMethods
24
24
  # Public: Defines a Resource in a controller Class.
25
25
  #
26
- # *args - See Resource#initialize for details.
26
+ # name - The name of the method to define.
27
+ # **options - See Resource#initialize for details.
27
28
  # block - If supplied, the block is executed to provide options.
28
29
  #
29
30
  # Returns the name of the defined resource.
30
- def resource(*args, &block)
31
- Resource.define(self, *args, &block)
31
+ def resource(name, **options, &block)
32
+ Resource.define(self, name, **options, &block)
32
33
  end
33
34
 
34
35
  # Public: Defines a Configuration preset that can be reused in different
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resourcerer
4
- VERSION = '2.0.3'
4
+ VERSION = '2.0.4'
5
5
  end
@@ -18,7 +18,7 @@ RSpec.describe GuitarsController, type: :controller do
18
18
  Given {
19
19
  expect(Guitar).to receive(:find).with('ES-335').and_return(guitar)
20
20
  }
21
- When { get :show, request_params(id: 'ES-335') }
21
+ When { get :show, **request_params(id: 'ES-335') }
22
22
  Then { controller.guitar == guitar }
23
23
  end
24
24
 
@@ -26,7 +26,7 @@ RSpec.describe GuitarsController, type: :controller do
26
26
  Given {
27
27
  expect(Guitar).to receive(:find).with('ES-335').and_return(guitar)
28
28
  }
29
- When { get :new, request_params(guitar_id: 'ES-335') }
29
+ When { get :new, **request_params(guitar_id: 'ES-335') }
30
30
  Then { controller.guitar == guitar }
31
31
  end
32
32
 
@@ -37,7 +37,7 @@ RSpec.describe GuitarsController, type: :controller do
37
37
  end
38
38
 
39
39
  context 'when build params are used' do
40
- When { post :create, request_params(guitar: { name: 'strat' }) }
40
+ When { post :create, **request_params(guitar: { name: 'strat' }) }
41
41
  Then { controller.guitar.name == 'strat' }
42
42
  end
43
43
 
@@ -45,7 +45,7 @@ RSpec.describe GuitarsController, type: :controller do
45
45
  Given {
46
46
  expect(Guitar).to receive(:find).with('ES-335').and_return(guitar)
47
47
  }
48
- When { get :show, request_params(id: 'ES-335') }
48
+ When { get :show, **request_params(id: 'ES-335') }
49
49
  Then { controller.guitar? == true }
50
50
  end
51
51
  end
@@ -39,6 +39,12 @@ RSpec.describe Resourcerer::Controller do
39
39
  And { controller.method(:thing=).parameters.size == 1 }
40
40
  end
41
41
 
42
+ context 'incorrect proc options' do
43
+ Given { resource :thing, build: :thing }
44
+ When(:usage) { controller_thing }
45
+ Then { expect(usage).to have_failed(ArgumentError, /Can't handle :build => :thing option/) }
46
+ end
47
+
42
48
  context 'memoization' do
43
49
  Given { resource :thing, build: -> { SecureRandom.hex(32) } }
44
50
  Then { controller_thing == controller_thing }
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  require "simplecov"
2
- require "coveralls"
3
2
  SimpleCov.start { add_filter '/spec/' }
4
- Coveralls.wear!
5
3
 
6
4
  require "resourcerer"
7
5
  require "rspec/given"
@@ -2,7 +2,7 @@ require "action_controller"
2
2
  require "rails"
3
3
 
4
4
  def request_params(params)
5
- { params: params, **params }
5
+ { params: params }
6
6
  end
7
7
 
8
8
  module Rails
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resourcerer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-03 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: coveralls
42
+ name: simplecov
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "<"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '0.18'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "<"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '0.18'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry-byebug
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -116,6 +116,7 @@ extensions: []
116
116
  extra_rdoc_files:
117
117
  - README.md
118
118
  files:
119
+ - CHANGELOG.md
119
120
  - README.md
120
121
  - lib/resourcerer.rb
121
122
  - lib/resourcerer/configuration.rb
@@ -131,13 +132,13 @@ homepage: https://github.com/ElMassimo/resourcerer
131
132
  licenses:
132
133
  - MIT
133
134
  metadata: {}
134
- post_install_message:
135
+ post_install_message:
135
136
  rdoc_options: []
136
137
  require_paths:
137
138
  - lib
138
139
  required_ruby_version: !ruby/object:Gem::Requirement
139
140
  requirements:
140
- - - "~>"
141
+ - - ">="
141
142
  - !ruby/object:Gem::Version
142
143
  version: '2.2'
143
144
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -146,9 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  - !ruby/object:Gem::Version
147
148
  version: '0'
148
149
  requirements: []
149
- rubyforge_project:
150
- rubygems_version: 2.5.1
151
- signing_key:
150
+ rubygems_version: 3.2.3
151
+ signing_key:
152
152
  specification_version: 4
153
153
  summary: Dry up your controllers by defining resources
154
154
  test_files: