turbo_test_ruby_refinements 0.1.0 → 0.1.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 +4 -4
- data/.github/workflows/tests.yml +12 -0
- data/Gemfile +3 -6
- data/Gemfile.common +5 -0
- data/Gemfile.lock +3 -3
- data/GemfileCI +9 -0
- data/GemfileCI.lock +71 -0
- data/README.md +4 -0
- data/Rakefile +5 -0
- data/lib/turbo_test_ruby_refinements/hash/leaf_paths.rb +10 -5
- data/lib/turbo_test_ruby_refinements/string/relative_path.rb +8 -5
- data/lib/turbo_test_ruby_refinements/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 74091d4cb67194293f5b9d0a6419b457f653df3e34cd38993bfa146f54002ce9
|
|
4
|
+
data.tar.gz: b1279671b0c53142b59533d71f7345b3a793f9766ac3f27c5538a2d9960d7dd4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 87f1f616214029b5e3c0ece0e14ca824c46f9c7bd48c34d6e23ea977e875b8ff8fe02377e3fce074b170d301dd91055df5cabe5a55020c3e357aeba7d961140c
|
|
7
|
+
data.tar.gz: 865219445f1d142bc832e28b7758ae69b7fcdf606989d6b06084bfe67662d5731ae89772bafd98464fa0dc85597fe64d7d296813367d7246c719f2e7e0e622c3
|
data/.github/workflows/tests.yml
CHANGED
|
@@ -21,10 +21,22 @@ jobs:
|
|
|
21
21
|
ruby-version: ${{ matrix.ruby }}
|
|
22
22
|
|
|
23
23
|
- name: Install dependencies
|
|
24
|
+
env:
|
|
25
|
+
BUNDLE_GEMFILE: GemfileCI
|
|
24
26
|
run: |
|
|
25
27
|
bundle config path vendor/bundle
|
|
26
28
|
bundle install --binstubs --jobs 4 --retry 3
|
|
27
29
|
|
|
28
30
|
- name: Run tests
|
|
31
|
+
env:
|
|
32
|
+
BUNDLE_GEMFILE: GemfileCI
|
|
29
33
|
run: |
|
|
30
34
|
bundle exec rake
|
|
35
|
+
|
|
36
|
+
- name: Coveralls
|
|
37
|
+
if: ${{ matrix.ruby == '2.7' }}
|
|
38
|
+
env:
|
|
39
|
+
BUNDLE_GEMFILE: GemfileCI
|
|
40
|
+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
|
41
|
+
run: |
|
|
42
|
+
bundle exec rake coveralls:push
|
data/Gemfile
CHANGED
|
@@ -3,9 +3,6 @@ source "https://rubygems.org"
|
|
|
3
3
|
# Specify your gem's dependencies in turbo_test_ruby_refinements.gemspec
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
gem "simplecov"
|
|
9
|
-
gem "byebug"
|
|
10
|
-
gem "rubocop"
|
|
11
|
-
gem "mocha"
|
|
6
|
+
eval_gemfile(File.expand_path("Gemfile.common", __dir__))
|
|
7
|
+
|
|
8
|
+
gem "simplecov", "~> 0.18.5"
|
data/Gemfile.common
ADDED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
|
|
4
|
+
turbo_test_ruby_refinements (0.1.1)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -45,8 +45,8 @@ DEPENDENCIES
|
|
|
45
45
|
mocha
|
|
46
46
|
rake
|
|
47
47
|
rubocop
|
|
48
|
-
simplecov
|
|
49
|
-
|
|
48
|
+
simplecov (~> 0.18.5)
|
|
49
|
+
turbo_test_ruby_refinements!
|
|
50
50
|
|
|
51
51
|
BUNDLED WITH
|
|
52
52
|
2.1.4
|
data/GemfileCI
ADDED
data/GemfileCI.lock
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
turbo_test_ruby_refinements (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.1)
|
|
10
|
+
byebug (11.1.3)
|
|
11
|
+
coveralls (0.7.2)
|
|
12
|
+
multi_json (~> 1.3)
|
|
13
|
+
rest-client (= 1.6.7)
|
|
14
|
+
simplecov (>= 0.7)
|
|
15
|
+
term-ansicolor (= 1.2.2)
|
|
16
|
+
thor (= 0.18.1)
|
|
17
|
+
docile (1.3.2)
|
|
18
|
+
json (2.3.1)
|
|
19
|
+
mime-types (3.3.1)
|
|
20
|
+
mime-types-data (~> 3.2015)
|
|
21
|
+
mime-types-data (3.2020.0512)
|
|
22
|
+
minitest (5.14.1)
|
|
23
|
+
mocha (1.11.2)
|
|
24
|
+
multi_json (1.15.0)
|
|
25
|
+
parallel (1.19.2)
|
|
26
|
+
parser (2.7.1.4)
|
|
27
|
+
ast (~> 2.4.1)
|
|
28
|
+
rainbow (3.0.0)
|
|
29
|
+
rake (13.0.1)
|
|
30
|
+
regexp_parser (1.7.1)
|
|
31
|
+
rest-client (1.6.7)
|
|
32
|
+
mime-types (>= 1.16)
|
|
33
|
+
rexml (3.2.4)
|
|
34
|
+
rubocop (0.89.0)
|
|
35
|
+
parallel (~> 1.10)
|
|
36
|
+
parser (>= 2.7.1.1)
|
|
37
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
38
|
+
regexp_parser (>= 1.7)
|
|
39
|
+
rexml
|
|
40
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
|
41
|
+
ruby-progressbar (~> 1.7)
|
|
42
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
43
|
+
rubocop-ast (0.3.0)
|
|
44
|
+
parser (>= 2.7.1.4)
|
|
45
|
+
ruby-progressbar (1.10.1)
|
|
46
|
+
simplecov (0.16.1)
|
|
47
|
+
docile (~> 1.1)
|
|
48
|
+
json (>= 1.8, < 3)
|
|
49
|
+
simplecov-html (~> 0.10.0)
|
|
50
|
+
simplecov-html (0.10.2)
|
|
51
|
+
term-ansicolor (1.2.2)
|
|
52
|
+
tins (~> 0.8)
|
|
53
|
+
thor (0.18.1)
|
|
54
|
+
tins (0.13.2)
|
|
55
|
+
unicode-display_width (1.7.0)
|
|
56
|
+
|
|
57
|
+
PLATFORMS
|
|
58
|
+
ruby
|
|
59
|
+
|
|
60
|
+
DEPENDENCIES
|
|
61
|
+
byebug
|
|
62
|
+
coveralls
|
|
63
|
+
minitest
|
|
64
|
+
mocha
|
|
65
|
+
rake
|
|
66
|
+
rubocop
|
|
67
|
+
simplecov (~> 0.16.1)
|
|
68
|
+
turbo_test_ruby_refinements!
|
|
69
|
+
|
|
70
|
+
BUNDLED WITH
|
|
71
|
+
2.1.4
|
data/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+

|
|
2
|
+
[](https://codeclimate.com/github/dunkelbraun/turbo-test-ruby-refinements/maintainability)
|
|
3
|
+
[](https://coveralls.io/github/dunkelbraun/turbo-test-ruby-refinements?branch=main)
|
|
4
|
+
|
|
1
5
|
# TurboTestRubyRefinements
|
|
2
6
|
|
|
3
7
|
Collection of refinements for Ruby classes:
|
data/Rakefile
CHANGED
|
@@ -8,16 +8,21 @@ module TurboTestRubyRefinements
|
|
|
8
8
|
# h = { key1: "1", key2: "2", key3: { key4: { key41: "3", key42: "4" }
|
|
9
9
|
# h.leaf_paths => [ "key1", "key2", "key3.key4.key41", "key3.key4.key42" ]
|
|
10
10
|
def leaf_paths(hash = {}, memo = [], scope = [])
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
case hash
|
|
12
|
+
when Hash
|
|
13
|
+
traverse_hash(hash, memo, scope)
|
|
14
|
+
memo
|
|
15
|
+
else
|
|
16
|
+
memo.push scope.join(".")
|
|
13
17
|
scope.pop
|
|
14
|
-
return
|
|
15
18
|
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def traverse_hash(hash, memo, scope)
|
|
16
22
|
hash.each_key do |key|
|
|
17
|
-
leaf_paths(hash[key], memo, scope
|
|
23
|
+
leaf_paths(hash[key], memo, scope.push(key))
|
|
18
24
|
scope.pop if scope.last == key
|
|
19
25
|
end
|
|
20
|
-
memo
|
|
21
26
|
end
|
|
22
27
|
end
|
|
23
28
|
end
|
|
@@ -20,15 +20,18 @@ module TurboTestRubyRefinements
|
|
|
20
20
|
refine ::String do
|
|
21
21
|
def relative_path
|
|
22
22
|
StringRelativePath.fetch(self) do
|
|
23
|
-
|
|
24
|
-
return self unless path.exist?
|
|
23
|
+
return self unless File.exist?(self)
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
path = path.realpath.relative_path_from(StringRelativePath.app_root_path)
|
|
28
|
-
end
|
|
25
|
+
path = path_to_relative_path(Pathname.new(self))
|
|
29
26
|
path.cleanpath.to_s
|
|
30
27
|
end
|
|
31
28
|
end
|
|
29
|
+
|
|
30
|
+
def path_to_relative_path(path)
|
|
31
|
+
return path if path.relative?
|
|
32
|
+
|
|
33
|
+
path.realpath.relative_path_from(StringRelativePath.app_root_path)
|
|
34
|
+
end
|
|
32
35
|
end
|
|
33
36
|
|
|
34
37
|
refine ::NilClass do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: turbo_test_ruby_refinements
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marcos Essindi
|
|
@@ -52,7 +52,10 @@ files:
|
|
|
52
52
|
- Appraisals
|
|
53
53
|
- CODE_OF_CONDUCT.md
|
|
54
54
|
- Gemfile
|
|
55
|
+
- Gemfile.common
|
|
55
56
|
- Gemfile.lock
|
|
57
|
+
- GemfileCI
|
|
58
|
+
- GemfileCI.lock
|
|
56
59
|
- LICENSE.txt
|
|
57
60
|
- Makefile
|
|
58
61
|
- README.md
|