adornable 1.1.1 → 1.2.1

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
  SHA256:
3
- metadata.gz: 3b916559874ffdc52baa8f1b2a75a7e550ad600c501d45adeaf4c53aa0796c97
4
- data.tar.gz: b7fd7d3eeaaae6b706fbe9f9b9f0d24770351a5ebbbd18759bd96d014466b001
3
+ metadata.gz: 2b36a2ad558b19305d75b4d59c81b93574b2d4635a267d00cb97bbd26e218e76
4
+ data.tar.gz: 7e23c912633d929ae70078e8d10ec286d379196e5e59bb27f877764494cce4a0
5
5
  SHA512:
6
- metadata.gz: b3d49e5efb60aec78d2b416c6d36c8c02844151a6824503f9301db45a4cd392ccea9f316500723e84a07d7ecb200b86a31c71bbc571e3294adfa637a7b92956f
7
- data.tar.gz: a97a7142ccc356e8657421e32de71f30c6a9070e73a618e5fbaa238ae2b7e3e7193ce11782a942f75b0606d14af54f79a4fd772de83526f200c2da504f353140
6
+ metadata.gz: 3a8b0dfb923e8f997e24ca6636de35d8f5f432f0f13143ff5bdd108b0c0ae6d9a74b42c5f4d2da59576ce8c9724918ed4ad8d20b7dae25347807192acb7a11e6
7
+ data.tar.gz: 4e5df5251a5ca785fca8ce87bf849e29234c514951012dde337dd865ea823d1abe50f59c085eaf10c95d6dabcd0a317f0c08ed9c2b7de0a2bd84a5feeb11911e
@@ -0,0 +1,45 @@
1
+ name: Test and lint
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ pull_request:
9
+ branches:
10
+ - main
11
+
12
+ # Allows you to run this workflow manually from the Actions tab
13
+ workflow_dispatch:
14
+
15
+ jobs:
16
+ build:
17
+ name: Run RSpec tests and RuboCop lints
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ strategy:
22
+ matrix:
23
+ ruby-version:
24
+ - 2.7
25
+ - 2.6
26
+ - 2.5
27
+
28
+ steps:
29
+ - name: Checkout the repo
30
+ uses: actions/checkout@v2
31
+
32
+ - name: Set up Ruby v${{ matrix.ruby-version }}
33
+ uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: ${{ matrix.ruby-version }}
36
+ bundler-cache: true
37
+
38
+ - name: Install dependencies
39
+ run: bundle install
40
+
41
+ - name: Run RSpec tests
42
+ run: bundle exec rake spec
43
+
44
+ - name: Run RuboCop lints
45
+ run: bundle exec rubocop
data/.rubocop.yml CHANGED
@@ -8,6 +8,11 @@ require:
8
8
  AllCops:
9
9
  NewCops: enable
10
10
 
11
+ # Gemspec
12
+
13
+ Gemspec/RequiredRubyVersion:
14
+ Enabled: false
15
+
11
16
  # Layout
12
17
 
13
18
  Layout/LineLength:
@@ -63,7 +68,7 @@ Metrics/ModuleLength:
63
68
  # Rspec
64
69
 
65
70
  RSpec/ExampleLength:
66
- Max: 25
71
+ Max: 30
67
72
 
68
73
  RSpec/MessageSpies:
69
74
  Enabled: false
data/Gemfile CHANGED
@@ -6,3 +6,14 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in adornable.gemspec
8
8
  gemspec
9
+
10
+ group :development, :test do
11
+ gem "bundler", "~> 2.2"
12
+ gem "rake", "~> 13.0"
13
+ gem "rspec", "~> 3.0"
14
+ gem "rubocop", "~> 1.10"
15
+ gem "rubocop-performance", "~> 1.9"
16
+ gem "rubocop-rake", "~> 0.5"
17
+ gem "rubocop-rspec", "~> 2.2"
18
+ gem "solargraph"
19
+ end
data/README.md CHANGED
@@ -156,6 +156,7 @@ end
156
156
  - `decorate :log` logs the method name and any passed arguments to the console
157
157
  - `decorate :memoize` caches the result of the first call and returns that initial result (and does not execute the method again) for any additional calls. By default, it namespaces the cache by the arguments passed to the method, so it will re-compute only if the arguments change; if the arguments are the same as any previous time the method was called, it will return the cached result instead.
158
158
  - pass the `for_any_arguments: true` option (e.g., `decorate :memoize, for_any_arguments: true`) to ignore the arguments in the caching process and simply memoize the result no matter what
159
+ - a `nil` value returned from a memoized method will still be cached like any other value
159
160
 
160
161
  > **Note:** in the case of multiple decorators decorating a method, each is executed from top to bottom.
161
162
 
@@ -350,12 +351,6 @@ rake spec
350
351
  rubocop
351
352
  ```
352
353
 
353
- ### Create release
354
-
355
- ```
356
- rake release
357
- ```
358
-
359
354
  ## Contributing
360
355
 
361
356
  Bug reports and pull requests for this project are welcome at its [GitHub page](https://github.com/kjleitz/adornable). If you choose to contribute, please be nice so I don't have to run out of bubblegum, etc.
data/adornable.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ["kjleitz@gmail.com"]
12
12
 
13
13
  spec.summary = "Method decorators for Ruby"
14
- spec.description = "Adornable provides the ability to cleanly decorate methods in Ruby. You can make and use your own decorators, and you can also use some of the built-in ones that the gem provides. _Decorating_ methods is as simple as slapping a `decorate :some_decorator` above your method definition. _Defining_ decorators can be as simple as defining a method that yields to a block, or as complex as manipulating the decorated method's receiver and arguments, and/or changing the functionality of the decorator based on custom options supplied to it when initially applying the decorator."
14
+ spec.description = "Adornable provides the ability to cleanly decorate methods in Ruby. You can make and use your own decorators, and you can also use some of the built-in ones that the gem provides. _Decorating_ methods is as simple as slapping a `decorate :some_decorator` above your method definition. _Defining_ decorators can be as simple as defining a method that yields to a block, or as complex as manipulating the decorated method's receiver and arguments, and/or changing the functionality of the decorator based on custom options supplied to it when initially applying the decorator." # rubocop:disable Layout/LineLength
15
15
  spec.homepage = "https://github.com/kjleitz/adornable"
16
16
  spec.license = "MIT"
17
17
  spec.required_ruby_version = ">= 2.4.7"
@@ -24,13 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.bindir = "exe"
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
-
28
- spec.add_development_dependency "bundler", "~> 2.2"
29
- spec.add_development_dependency "rake", "~> 13.0"
30
- spec.add_development_dependency "rspec", "~> 3.0"
31
- spec.add_development_dependency "rubocop", "~> 1.10"
32
- spec.add_development_dependency "rubocop-performance", "~> 1.9"
33
- spec.add_development_dependency "rubocop-rake", "~> 0.5"
34
- spec.add_development_dependency "rubocop-rspec", "~> 2.2"
35
- spec.add_development_dependency "solargraph"
27
+ spec.metadata['rubygems_mfa_required'] = 'true'
36
28
  end
@@ -24,9 +24,12 @@ module Adornable
24
24
  method_receiver = context.method_receiver
25
25
  method_name = context.method_name
26
26
  memo_var_name = :"@adornable_memoized_#{method_receiver.object_id}_#{method_name}"
27
- existing = instance_variable_get(memo_var_name)
28
- value = existing.nil? ? yield : existing
29
- instance_variable_set(memo_var_name, value)
27
+
28
+ if instance_variable_defined?(memo_var_name)
29
+ instance_variable_get(memo_var_name)
30
+ else
31
+ instance_variable_set(memo_var_name, yield)
32
+ end
30
33
  end
31
34
 
32
35
  def self.memoize_for_arguments(context)
@@ -37,7 +40,7 @@ module Adornable
37
40
  memo = instance_variable_get(memo_var_name) || {}
38
41
  instance_variable_set(memo_var_name, memo)
39
42
  args_key = method_args.inspect
40
- memo[args_key] = yield if memo[args_key].nil?
43
+ memo[args_key] = yield unless memo.key?(args_key)
41
44
  memo[args_key]
42
45
  end
43
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Adornable
4
- VERSION = "1.1.1"
4
+ VERSION = "1.2.1"
5
5
  end
data/lib/adornable.rb CHANGED
@@ -14,7 +14,7 @@ module Adornable
14
14
  end
15
15
 
16
16
  def decorate(decorator_name, from: nil, defer_validation: false, **decorator_options)
17
- if Adornable::Utils.blank?(name)
17
+ if Adornable::Utils.blank?(decorator_name)
18
18
  raise Adornable::Error::InvalidDecoratorArguments, "Decorator name must be provided."
19
19
  end
20
20
 
metadata CHANGED
@@ -1,127 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adornable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keegan Leitz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-17 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.2'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.2'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '13.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '13.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.10'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.10'
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop-performance
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.9'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.9'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0.5'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0.5'
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop-rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '2.2'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '2.2'
111
- - !ruby/object:Gem::Dependency
112
- name: solargraph
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
11
+ date: 2023-07-07 00:00:00.000000000 Z
12
+ dependencies: []
125
13
  description: Adornable provides the ability to cleanly decorate methods in Ruby. You
126
14
  can make and use your own decorators, and you can also use some of the built-in
127
15
  ones that the gem provides. _Decorating_ methods is as simple as slapping a `decorate
@@ -135,6 +23,7 @@ executables: []
135
23
  extensions: []
136
24
  extra_rdoc_files: []
137
25
  files:
26
+ - ".github/workflows/main.yml"
138
27
  - ".gitignore"
139
28
  - ".rspec"
140
29
  - ".rubocop.yml"
@@ -156,7 +45,8 @@ files:
156
45
  homepage: https://github.com/kjleitz/adornable
157
46
  licenses:
158
47
  - MIT
159
- metadata: {}
48
+ metadata:
49
+ rubygems_mfa_required: 'true'
160
50
  post_install_message:
161
51
  rdoc_options: []
162
52
  require_paths:
@@ -172,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
62
  - !ruby/object:Gem::Version
173
63
  version: '0'
174
64
  requirements: []
175
- rubygems_version: 3.1.4
65
+ rubygems_version: 3.1.6
176
66
  signing_key:
177
67
  specification_version: 4
178
68
  summary: Method decorators for Ruby