proc-value 1.0 → 1.0.1
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 +5 -5
- data/.editorconfig +12 -0
- data/.github/workflows/cache.yml +32 -0
- data/.github/workflows/release.yml +37 -0
- data/.github/workflows/test.yml +53 -0
- data/.rubocop.yml +9 -0
- data/Gemfile +11 -0
- data/README.md +14 -6
- data/Rakefile +3 -1
- data/lib/proc/value.rb +4 -2
- data/proc-value.gemspec +10 -15
- data/renovate.json +6 -0
- data/spec/proc_value_spec.rb +26 -28
- data/spec/spec_helper.rb +6 -3
- metadata +18 -75
- data/.travis.yml +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: feaedb45404bda31962aabc36bdbf3d5514551bc4789ceae1d0dc278c1d8e937
|
|
4
|
+
data.tar.gz: '0191d4d11f46335bd842b95a8959fcc3f9c6e394b6ad151c7ca242528acd0a61'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba14e9d2f4927d2eabcae51ca8f8ca1947567abf083f8fbf310742f087ee9b749672e073b21d062bf4cfe39184aa33bea7914f87393ad1aa898c15c6de744a6b
|
|
7
|
+
data.tar.gz: 849317efe79ede808b999b97775a01d957565e6937ba3f3e6b6d6349822c3ddb4e21b25015d77b0f0a6f4aec4477298c5bd579f849974913d62a951e323096e9
|
data/.editorconfig
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Clear all caches
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
permissions:
|
|
7
|
+
actions: write
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
clear-cache:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Clear cache
|
|
14
|
+
uses: actions/github-script@v8
|
|
15
|
+
with:
|
|
16
|
+
script: |
|
|
17
|
+
const caches = await github.rest.actions.getActionsCacheList({
|
|
18
|
+
owner: context.repo.owner,
|
|
19
|
+
repo: context.repo.repo,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
for (const cache of caches.data.actions_caches) {
|
|
23
|
+
console.log(cache)
|
|
24
|
+
|
|
25
|
+
github.rest.actions.deleteActionsCacheById({
|
|
26
|
+
owner: context.repo.owner,
|
|
27
|
+
repo: context.repo.repo,
|
|
28
|
+
cache_id: cache.id,
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log("Clear completed")
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# vim: ft=yaml
|
|
2
|
+
|
|
3
|
+
name: release
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
tags:
|
|
8
|
+
- v*
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
rubygems:
|
|
12
|
+
if: github.repository == 'jgraichen/proc-value'
|
|
13
|
+
runs-on: ubuntu-24.04
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: write
|
|
17
|
+
id-token: write
|
|
18
|
+
|
|
19
|
+
env:
|
|
20
|
+
BUNDLE_JOBS: 4
|
|
21
|
+
BUNDLE_RETRY: 10
|
|
22
|
+
BUNDLE_WITHOUT: development test
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
|
|
27
|
+
- uses: ruby/setup-ruby@v1
|
|
28
|
+
with:
|
|
29
|
+
ruby-version: ruby
|
|
30
|
+
bundler-cache: true
|
|
31
|
+
|
|
32
|
+
- uses: rubygems/release-gem@v1
|
|
33
|
+
|
|
34
|
+
- name: Release
|
|
35
|
+
uses: softprops/action-gh-release@v2
|
|
36
|
+
with:
|
|
37
|
+
generate_release_notes: true
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
- push
|
|
6
|
+
- pull_request
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
rspec:
|
|
10
|
+
name: "ruby-${{ matrix.ruby }}"
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
ruby:
|
|
17
|
+
- "4.0"
|
|
18
|
+
- "3.4"
|
|
19
|
+
- "3.3"
|
|
20
|
+
- "3.2"
|
|
21
|
+
- "3.1"
|
|
22
|
+
- "3.0"
|
|
23
|
+
- "2.7"
|
|
24
|
+
|
|
25
|
+
env:
|
|
26
|
+
BUNDLE_WITHOUT: development
|
|
27
|
+
BUNDLE_JOBS: 4
|
|
28
|
+
BUNDLE_RETRY: 3
|
|
29
|
+
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@master
|
|
32
|
+
- uses: ruby/setup-ruby@v1
|
|
33
|
+
with:
|
|
34
|
+
ruby-version: "${{ matrix.ruby }}"
|
|
35
|
+
bundler-cache: true
|
|
36
|
+
|
|
37
|
+
- run: bundle exec rspec --color --format documentation
|
|
38
|
+
|
|
39
|
+
rubocop:
|
|
40
|
+
name: rubocop
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
|
|
43
|
+
env:
|
|
44
|
+
BUNDLE_WITHOUT: development
|
|
45
|
+
|
|
46
|
+
steps:
|
|
47
|
+
- uses: actions/checkout@master
|
|
48
|
+
- uses: ruby/setup-ruby@v1
|
|
49
|
+
with:
|
|
50
|
+
ruby-version: "4.0"
|
|
51
|
+
bundler-cache: true
|
|
52
|
+
|
|
53
|
+
- run: bundle exec rubocop --parallel --fail-level E
|
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
source 'https://rubygems.org'
|
|
2
4
|
|
|
3
5
|
# Specify your gem's dependencies in proc-value.gemspec
|
|
4
6
|
gemspec
|
|
7
|
+
|
|
8
|
+
gem 'rake'
|
|
9
|
+
gem 'rake-release'
|
|
10
|
+
|
|
11
|
+
gem 'rspec'
|
|
12
|
+
|
|
13
|
+
gem 'simplecov', require: false
|
|
14
|
+
|
|
15
|
+
gem 'rubocop-config', github: 'jgraichen/rubocop-config', ref: '129cb1338637f7a32f0ee84edf0cd23da9d1e0db', require: false
|
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
# Proc::Value
|
|
2
|
-
|
|
3
|
-
[](https://rubygems.org/gems/proc-value)
|
|
4
|
+
[](https://github.com/jgraichen/proc-value/actions/workflows/test.yml)
|
|
5
|
+
[](https://codecov.io/gh/jgraichen/proc-value)
|
|
4
6
|
|
|
5
7
|
**Proc::Value** extends Ruby Objects with a Smalltalk like `#value` method that always returns the object except when called on a block. In this case the block will be evaluated and the result returned. This allows the transparent exchange of static object with lazy evaluated blocks e.g. for configuration classes.
|
|
6
8
|
|
|
@@ -28,15 +30,21 @@ config2.path # Same code. No extra if statement needed.
|
|
|
28
30
|
|
|
29
31
|
Add this line to your application's Gemfile:
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
```ruby
|
|
34
|
+
gem 'proc-value'
|
|
35
|
+
```
|
|
32
36
|
|
|
33
37
|
And then execute:
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
```console
|
|
40
|
+
bundle
|
|
41
|
+
```
|
|
36
42
|
|
|
37
43
|
Or install it yourself as:
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
```console
|
|
46
|
+
gem install proc-value
|
|
47
|
+
```
|
|
40
48
|
|
|
41
49
|
## Usage
|
|
42
50
|
|
data/Rakefile
CHANGED
data/lib/proc/value.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Proc
|
|
2
4
|
module ValueClassPatch
|
|
3
5
|
# Evaluate block if block is given or return
|
|
@@ -40,7 +42,7 @@ class Proc
|
|
|
40
42
|
# config_option = proc { "#{lazy_var}/path/to/file.rb" }
|
|
41
43
|
# config_option.value.to_s
|
|
42
44
|
#
|
|
43
|
-
def value(*
|
|
45
|
+
def value(*_args)
|
|
44
46
|
self
|
|
45
47
|
end
|
|
46
48
|
end
|
|
@@ -49,4 +51,4 @@ class Proc
|
|
|
49
51
|
extend ValueClassPatch
|
|
50
52
|
end
|
|
51
53
|
|
|
52
|
-
Object.
|
|
54
|
+
Object.include Proc::ValueObjectPatch
|
data/proc-value.gemspec
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
#
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)\
|
|
1
|
+
# frozen_string_literal: true
|
|
4
2
|
|
|
5
3
|
Gem::Specification.new do |spec|
|
|
6
4
|
spec.name = 'proc-value'
|
|
7
|
-
spec.version = '1.0'
|
|
5
|
+
spec.version = '1.0.1'
|
|
8
6
|
spec.authors = ['Jan Graichen']
|
|
9
|
-
spec.email = ['
|
|
10
|
-
spec.description =
|
|
11
|
-
spec.summary =
|
|
7
|
+
spec.email = ['jgraichen@altimos.de']
|
|
8
|
+
spec.description = 'Proc::Value allows transparent block evaluation on all objects using #value method.'
|
|
9
|
+
spec.summary = 'Proc::Value allows transparent block evaluation on all objects using #value method.'
|
|
12
10
|
spec.homepage = 'https://github.com/jgraichen/proc-value'
|
|
13
11
|
spec.license = 'MIT'
|
|
14
12
|
|
|
15
|
-
spec.
|
|
16
|
-
spec.
|
|
17
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
18
|
-
spec.require_paths = ["lib"]
|
|
13
|
+
spec.required_ruby_version = '>= 2.7.0'
|
|
14
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
19
15
|
|
|
20
|
-
spec.
|
|
21
|
-
spec.
|
|
22
|
-
spec.
|
|
23
|
-
spec.add_development_dependency "coveralls"
|
|
16
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
|
|
18
|
+
spec.require_paths = ['lib']
|
|
24
19
|
end
|
data/renovate.json
ADDED
data/spec/proc_value_spec.rb
CHANGED
|
@@ -1,66 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Proc::Value' do
|
|
4
|
-
|
|
5
|
-
it 'should allow transparent usage of blocks' do
|
|
6
|
+
it 'allows transparent usage of blocks' do
|
|
6
7
|
option1 = 'path/to/file.rb'
|
|
7
8
|
expect(option1.value.to_s).to be == 'path/to/file.rb'
|
|
8
9
|
|
|
9
10
|
option2 = proc { 'path/to/file.rb' }
|
|
10
11
|
expect(option2.value.to_s).to be == 'path/to/file.rb'
|
|
11
12
|
|
|
12
|
-
option3 =
|
|
13
|
+
option3 = -> { 'path/to/file.rb' }
|
|
13
14
|
expect(option3.value.to_s).to be == 'path/to/file.rb'
|
|
14
15
|
end
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
subject { sample }
|
|
17
|
+
describe 'Object' do
|
|
18
|
+
subject(:sample) { Object.new }
|
|
19
19
|
|
|
20
|
-
it '
|
|
21
|
-
expect(
|
|
20
|
+
it 'has #value method' do
|
|
21
|
+
expect(sample).to respond_to(:value)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
it 'should return same object' do
|
|
28
|
-
expect(subject).to be === subject
|
|
24
|
+
describe '#value' do
|
|
25
|
+
it 'returns same object' do
|
|
26
|
+
expect(sample.value).to be sample
|
|
29
27
|
end
|
|
30
28
|
end
|
|
31
29
|
end
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
describe 'Proc' do
|
|
32
|
+
subject(:block) { proc { sample } }
|
|
33
|
+
|
|
34
34
|
let(:sample) { Object.new }
|
|
35
|
-
let(:block) { proc { sample } }
|
|
36
|
-
subject { block }
|
|
37
35
|
|
|
38
|
-
it '
|
|
39
|
-
expect(
|
|
36
|
+
it 'has #value method' do
|
|
37
|
+
expect(block).to respond_to(:value)
|
|
40
38
|
end
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
describe '#value' do
|
|
43
41
|
subject { block.value }
|
|
44
42
|
|
|
45
|
-
it '
|
|
46
|
-
expect(
|
|
43
|
+
it 'returns block result' do
|
|
44
|
+
expect(block.value).to be sample
|
|
47
45
|
end
|
|
48
46
|
end
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
describe '.val' do
|
|
51
49
|
context 'with block' do
|
|
52
|
-
subject { Proc.val(block) }
|
|
50
|
+
subject(:val) { Proc.val(block) }
|
|
53
51
|
|
|
54
|
-
it '
|
|
55
|
-
expect(
|
|
52
|
+
it 'evaluates block' do
|
|
53
|
+
expect(val).to be sample
|
|
56
54
|
end
|
|
57
55
|
end
|
|
58
56
|
|
|
59
57
|
context 'with object' do
|
|
60
|
-
subject { Proc.val(sample) }
|
|
58
|
+
subject(:val) { Proc.val(sample) }
|
|
61
59
|
|
|
62
|
-
it '
|
|
63
|
-
expect(
|
|
60
|
+
it 'evaluates block' do
|
|
61
|
+
expect(val).to be sample
|
|
64
62
|
end
|
|
65
63
|
end
|
|
66
64
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'simplecov'
|
|
4
|
+
|
|
5
|
+
SimpleCov.start do
|
|
3
6
|
add_filter 'spec'
|
|
4
7
|
end
|
|
5
8
|
|
|
6
9
|
require 'proc/value'
|
|
7
10
|
|
|
8
11
|
RSpec.configure do |config|
|
|
9
|
-
config.order =
|
|
12
|
+
config.order = 'random'
|
|
10
13
|
config.expect_with :rspec do |c|
|
|
11
14
|
c.syntax = :expect
|
|
12
15
|
end
|
metadata
CHANGED
|
@@ -1,115 +1,58 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: proc-value
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jan Graichen
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
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: '1.3'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ~>
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '1.3'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - '>='
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - '>='
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '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: '0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - '>='
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: coveralls
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - '>='
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - '>='
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
69
12
|
description: 'Proc::Value allows transparent block evaluation on all objects using
|
|
70
13
|
#value method.'
|
|
71
14
|
email:
|
|
72
|
-
-
|
|
15
|
+
- jgraichen@altimos.de
|
|
73
16
|
executables: []
|
|
74
17
|
extensions: []
|
|
75
18
|
extra_rdoc_files: []
|
|
76
19
|
files:
|
|
77
|
-
- .
|
|
78
|
-
- .
|
|
20
|
+
- ".editorconfig"
|
|
21
|
+
- ".github/workflows/cache.yml"
|
|
22
|
+
- ".github/workflows/release.yml"
|
|
23
|
+
- ".github/workflows/test.yml"
|
|
24
|
+
- ".gitignore"
|
|
25
|
+
- ".rubocop.yml"
|
|
79
26
|
- Gemfile
|
|
80
27
|
- LICENSE.txt
|
|
81
28
|
- README.md
|
|
82
29
|
- Rakefile
|
|
83
30
|
- lib/proc/value.rb
|
|
84
31
|
- proc-value.gemspec
|
|
32
|
+
- renovate.json
|
|
85
33
|
- spec/proc_value_spec.rb
|
|
86
34
|
- spec/spec_helper.rb
|
|
87
35
|
homepage: https://github.com/jgraichen/proc-value
|
|
88
36
|
licenses:
|
|
89
37
|
- MIT
|
|
90
|
-
metadata:
|
|
91
|
-
|
|
38
|
+
metadata:
|
|
39
|
+
rubygems_mfa_required: 'true'
|
|
92
40
|
rdoc_options: []
|
|
93
41
|
require_paths:
|
|
94
42
|
- lib
|
|
95
43
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
44
|
requirements:
|
|
97
|
-
- -
|
|
45
|
+
- - ">="
|
|
98
46
|
- !ruby/object:Gem::Version
|
|
99
|
-
version:
|
|
47
|
+
version: 2.7.0
|
|
100
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
49
|
requirements:
|
|
102
|
-
- -
|
|
50
|
+
- - ">="
|
|
103
51
|
- !ruby/object:Gem::Version
|
|
104
52
|
version: '0'
|
|
105
53
|
requirements: []
|
|
106
|
-
|
|
107
|
-
rubygems_version: 2.0.3
|
|
108
|
-
signing_key:
|
|
54
|
+
rubygems_version: 4.0.3
|
|
109
55
|
specification_version: 4
|
|
110
56
|
summary: 'Proc::Value allows transparent block evaluation on all objects using #value
|
|
111
57
|
method.'
|
|
112
|
-
test_files:
|
|
113
|
-
- spec/proc_value_spec.rb
|
|
114
|
-
- spec/spec_helper.rb
|
|
115
|
-
has_rdoc:
|
|
58
|
+
test_files: []
|