contextualizer 0.0.6 → 0.1.0

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: e4e8936f90745f3f7bcc2d55b9ed9ea80a3701f88bcbac199761d5e8c198bbb2
4
- data.tar.gz: 8a52995c0569c7d8271b5aff3623cce888ee1eea8f3d9e809612eb2fe53ba3da
3
+ metadata.gz: 1424baf84e6af815afc2c61de2e1c2cf74c5ee96afbbfb123fccb169a0076a19
4
+ data.tar.gz: 6a69f1ddd869d3bc0ccdadff2bf8d57b2f312dd510947631bcb126a9b3a33060
5
5
  SHA512:
6
- metadata.gz: ddf97150f7a70d16b157ec0e6ae7f9fb4c5a042aa84ada0a5a585ba94f137eb3537200ce96e52134402482e9719bb9361d3b8878df8315148ce197cdf570b480
7
- data.tar.gz: f72fead3e5c3013f1fa27d8b5948f9c531079cd253496a8da74f6d161c6e25a6eaa12f636f6f0b36ad3514e91236b834dced720ca4b7b9263097ae72bc6d6e64
6
+ metadata.gz: b4e3572d4f21a19cc7240e5db085bf6f5cf500fdc81622b8f66a241d203006a57355f0912ceedece41491aef714bb4c4c6ce735c8eae8153225a1ec0eea9fb92
7
+ data.tar.gz: 3581f6d903d188a9ee89bf3dc75e3b1ecb07a5b612735782e0fd704e35607cab730eb4a34366e3a67b3fe351cd99ed3d886513abb0046901ef2efbd0404220e0
@@ -11,18 +11,19 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby-version: [2.6, 2.7, 3.0, 3.1]
14
+ ruby-version: ['3.0', '3.1', '3.2', '3.3']
15
15
  steps:
16
- - uses: actions/checkout@v2
16
+ - uses: actions/checkout@v4
17
17
  - name: Set up Ruby
18
18
  uses: ruby/setup-ruby@v1
19
19
  with:
20
20
  ruby-version: ${{ matrix.ruby-version }}
21
+ bundler: '2.5.14'
21
22
  bundler-cache: true
22
23
  - name: Run tests
23
24
  run: bundle exec rake
24
25
  - name: Coveralls GitHub Action
25
- if: matrix.ruby-version == '3.1'
26
- uses: coverallsapp/github-action@1.1.3
26
+ if: matrix.ruby-version == '3.3'
27
+ uses: coverallsapp/github-action@v2
27
28
  with:
28
29
  github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -1,4 +1,5 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  lib = File.expand_path("../lib", __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require "contextualizer/version"
@@ -21,11 +22,9 @@ Gem::Specification.new do |spec|
21
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
23
  spec.require_paths = ["lib"]
23
24
 
24
- spec.required_ruby_version = ">= 2.4.0"
25
-
26
- spec.add_dependency "ruby2_keywords"
25
+ spec.required_ruby_version = ">= 3.0.0"
27
26
 
28
- spec.add_development_dependency "bundler", "~> 2.3.7"
27
+ spec.add_development_dependency "bundler", ">= 2.5.0"
29
28
  spec.add_development_dependency "rake", "~> 12.3.3"
30
29
  spec.add_development_dependency "rspec", "~> 3.0"
31
30
  spec.add_development_dependency "simplecov-lcov", '~> 0.8.0'
@@ -1,10 +1,11 @@
1
- require 'contextualizer'
2
- require 'ruby2_keywords'
1
+ # frozen_string_literal: true
2
+
3
+ require "contextualizer"
3
4
 
4
5
  module Contextualizer
5
6
  module Callable
6
- ruby2_keywords def call(ctx, *args, &bl)
7
- new(ctx).call(*args, &bl)
7
+ def call(ctx,...)
8
+ new(ctx).call(...)
8
9
  end
9
10
 
10
11
  def self.extended(klass)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Contextualizer
2
- VERSION = "0.0.6"
4
+ VERSION = "0.1.0"
3
5
  end
@@ -1,4 +1,6 @@
1
- require 'contextualizer/version'
1
+ # frozen_string_literal: true
2
+
3
+ require "contextualizer/version"
2
4
 
3
5
  module Contextualizer
4
6
  OPTIONAL = Object.new.freeze
@@ -24,14 +26,14 @@ module Contextualizer
24
26
  def self.init_for(setter, inherited = true)
25
27
  Module.new do |mod|
26
28
  if inherited
27
- mod.send(:define_method, :initialize) do |args = {}|
28
- super(args)
29
- setter.set(self, args)
29
+ mod.send(:define_method, :initialize) do |ctx = {}|
30
+ super(ctx)
31
+ setter.set(self, ctx)
30
32
  end
31
33
  else
32
- mod.send(:define_method, :initialize) do |args = {}|
34
+ mod.send(:define_method, :initialize) do |ctx = {}|
33
35
  super()
34
- setter.set(self, args)
36
+ setter.set(self, ctx)
35
37
  end
36
38
  end
37
39
  end
@@ -50,14 +52,14 @@ module Contextualizer
50
52
  @with_default.merge!(with_default)
51
53
  end
52
54
 
53
- def set(obj, args)
55
+ def set(obj, ctx)
54
56
  context = obj.context&.dup || {}
55
57
 
56
- @with_default.each { |key, default| context[key] = args.fetch(key, default) }
57
- @optional.each { |key| context[key] = args[key] if args.key?(key) }
58
+ @with_default.each { |key, default| context[key] = ctx.fetch(key, default) }
59
+ @optional.each { |key| context[key] = ctx[key] if ctx.key?(key) }
58
60
  @mandatory.each do |key|
59
- fail ":#{key} was not found in scope" unless args.key?(key)
60
- context[key] = args[key]
61
+ fail ":#{key} was not found in scope" unless ctx.key?(key)
62
+ context[key] = ctx[key]
61
63
  end
62
64
 
63
65
  context.each do |attr, value|
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contextualizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Herrero
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-18 00:00:00.000000000 Z
11
+ date: 2024-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ruby2_keywords
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - "~>"
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: 2.3.7
19
+ version: 2.5.0
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: 2.3.7
26
+ version: 2.5.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +142,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - ">="
158
144
  - !ruby/object:Gem::Version
159
- version: 2.4.0
145
+ version: 3.0.0
160
146
  required_rubygems_version: !ruby/object:Gem::Requirement
161
147
  requirements:
162
148
  - - ">="
163
149
  - !ruby/object:Gem::Version
164
150
  version: '0'
165
151
  requirements: []
166
- rubygems_version: 3.0.9
152
+ rubygems_version: 3.2.3
167
153
  signing_key:
168
154
  specification_version: 4
169
155
  summary: Allows to define context values for your objects