ruby_smart-support 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +15 -12
- data/.yardopts +4 -0
- data/README.md +15 -7
- data/Rakefile +1 -9
- data/bin/console +1 -1
- data/docs/CHANGELOG.md +5 -0
- data/lib/ruby_smart/support/core_ext/ruby/hash.rb +2 -2
- data/lib/ruby_smart/support/gem_info.rb +26 -27
- data/lib/ruby_smart/support/gem_version.rb +2 -2
- data/ruby_smart-support.gemspec +9 -9
- metadata +14 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '04538f8760bf132b3624905d73d7d814be6db112127400c8813f788fbbcccbd9'
|
4
|
+
data.tar.gz: a25eef7736cfe55d98316f55fc44fac46b1866cdfa27fdac19194942c55cd685
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdca8016dc310dee6967f9f35ee9ba24bbb67e968ed6836306e2df22f68433d5d8cc86260b8c7b00ea86ea173e44d02a5efe89cbf3403f3a0091eab609a40aef
|
7
|
+
data.tar.gz: c8d56578f4bc8dd2fb8adcd081176b1ffd5c8fa52db1cc82380f6baac7358e7163e4b54810fd8d21ca15f2e0c9aa8dd4024516dfbbb58eb6e14767555fd2fe28
|
data/.gitignore
CHANGED
@@ -1,22 +1,25 @@
|
|
1
|
+
# defaults
|
1
2
|
/.bundle/
|
3
|
+
/tmp/
|
4
|
+
Gemfile.lock
|
5
|
+
|
6
|
+
# testing
|
7
|
+
.rspec_status
|
8
|
+
/spec/reports/
|
9
|
+
|
10
|
+
# documentation & coverage
|
2
11
|
/.yardoc
|
3
12
|
/_yardoc/
|
4
13
|
/coverage/
|
5
14
|
/doc/
|
6
|
-
/
|
7
|
-
|
8
|
-
/tmp/
|
15
|
+
/docs/yard
|
16
|
+
/.coveralls.yml
|
9
17
|
|
10
|
-
#
|
11
|
-
|
18
|
+
# builds
|
19
|
+
/pkg/
|
20
|
+
/*.gem
|
12
21
|
|
13
22
|
# IDE related files
|
14
23
|
/.idea
|
15
24
|
/.ruby-version
|
16
|
-
/.bundle-version
|
17
|
-
|
18
|
-
# Github testing
|
19
|
-
Gemfile.lock
|
20
|
-
|
21
|
-
# builds
|
22
|
-
/*.gem
|
25
|
+
/.bundle-version
|
data/.yardopts
ADDED
data/README.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
# RubySmart::Support
|
2
2
|
|
3
|
-
[![
|
4
|
-
[![
|
5
|
-
|
3
|
+
[![GitHub](https://img.shields.io/badge/github-ruby--smart/support-blue.svg)](http://github.com/ruby-smart/support)
|
4
|
+
[![Documentation](https://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://rubydoc.info/gems/ruby_smart-support)
|
5
|
+
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/ruby_smart-support.svg?kill_cache=1)](https://badge.fury.io/rb/ruby_smart-support)
|
7
|
+
[![License](https://img.shields.io/github/license/ruby-smart/support)](docs/LICENSE.txt)
|
8
|
+
|
9
|
+
[![Coverage Status](https://coveralls.io/repos/github/ruby-smart/support/badge.svg?branch=main&kill_cache=1)](https://coveralls.io/github/ruby-smart/support?branch=main)
|
10
|
+
[![Tests](https://github.com/ruby-smart/support/actions/workflows/ruby.yml/badge.svg)](https://github.com/ruby-smart/support/actions/workflows/ruby.yml)
|
6
11
|
|
7
12
|
A toolkit of support libraries including GemInfo, ThreadInfo, Ruby core extensions & optionally activesupport extensions.
|
8
13
|
|
@@ -43,6 +48,9 @@ Or install it yourself as:
|
|
43
48
|
* to `append` & `prepend` additional blocks
|
44
49
|
* to check task-state with `#invoked?`, `#performed?` & `#running?`
|
45
50
|
|
51
|
+
|
52
|
+
|
53
|
+
|
46
54
|
-----
|
47
55
|
|
48
56
|
## ThreadInfo module
|
@@ -191,19 +199,19 @@ rake db:migrate
|
|
191
199
|
|
192
200
|
## Docs
|
193
201
|
|
194
|
-
[CHANGELOG](
|
202
|
+
[CHANGELOG](docs/CHANGELOG.md)
|
195
203
|
|
196
204
|
## Contributing
|
197
205
|
|
198
206
|
Bug reports and pull requests are welcome on [GitHub](https://github.com/ruby-smart/support).
|
199
|
-
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](
|
207
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](docs/CODE_OF_CONDUCT.md).
|
200
208
|
|
201
209
|
## License
|
202
210
|
|
203
211
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
204
212
|
|
205
|
-
A copy of the [LICENSE](
|
213
|
+
A copy of the [LICENSE](docs/LICENSE.txt) can be found @ the docs.
|
206
214
|
|
207
215
|
## Code of Conduct
|
208
216
|
|
209
|
-
Everyone interacting in the project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [CODE OF CONDUCT](
|
217
|
+
Everyone interacting in the project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [CODE OF CONDUCT](docs/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -5,12 +5,4 @@ require "rspec/core/rake_task"
|
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
task default: :spec
|
9
|
-
|
10
|
-
# ----- Documentation tasks ---------------------------------------------------
|
11
|
-
|
12
|
-
require 'yard'
|
13
|
-
YARD::Rake::YardocTask.new(:doc) do |t|
|
14
|
-
t.options = %w| --embed-mixins --markup=markdown|
|
15
|
-
t.files = ['lib/**/*.rb','-','docs/*.*']
|
16
|
-
end
|
8
|
+
task default: :spec
|
data/bin/console
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "bundler/setup"
|
5
|
-
require "ruby_smart
|
5
|
+
require "ruby_smart-support"
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
data/docs/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# RubySmart::Support - CHANGELOG
|
2
2
|
|
3
|
+
## [1.2.0] - 2023-01-24
|
4
|
+
* **[ref]** `GemInfo` methods (active -> required & active? -> required?)
|
5
|
+
* **[ref]** simplify `GemInfo.match?`method
|
6
|
+
* **[fix]** `Hash#to_md5` method to use `#inspect` instead of `#to_s`
|
7
|
+
|
3
8
|
## [1.1.1] - 2022-11-15
|
4
9
|
* **[fix]** `GemInfo` & `ThreadInfo` not being included on require 'ruby_smart-support'
|
5
10
|
* **[fix]** yard comments
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
unless Hash.method_defined? "to_md5"
|
4
4
|
class Hash
|
5
|
-
# returns the md5 of any hash by using the
|
5
|
+
# returns the md5 of any hash by using the +#inspect+ method
|
6
6
|
# @return [String] md5
|
7
7
|
def to_md5
|
8
|
-
Digest::MD5.hexdigest(Hash[self.sort].
|
8
|
+
Digest::MD5.hexdigest(Hash[self.sort].inspect)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -15,8 +15,10 @@ module RubySmart
|
|
15
15
|
|
16
16
|
# returns a hash of all installed gems with it's versions
|
17
17
|
#
|
18
|
+
# @example
|
19
|
+
#
|
18
20
|
# GemInfo.installed
|
19
|
-
# > {'bundler' => ['2.2.30', '1.2.3']}
|
21
|
+
# # > {'bundler' => ['2.2.30', '1.2.3']}
|
20
22
|
#
|
21
23
|
# @return [Hash{<name> => Array[<version>]}] gem name-versions hash
|
22
24
|
def self.installed
|
@@ -27,10 +29,10 @@ module RubySmart
|
|
27
29
|
# the optional version requirement matches against any available version
|
28
30
|
#
|
29
31
|
# GemInfo.installed?('bundler')
|
30
|
-
# > true
|
32
|
+
# # > true
|
31
33
|
#
|
32
34
|
# GemInfo.installed?('bundler', '~> 3.0')
|
33
|
-
# > false
|
35
|
+
# # > false
|
34
36
|
#
|
35
37
|
# @param [String] name - the gem name
|
36
38
|
# @param [nil, String] version - optional version requirement
|
@@ -41,22 +43,24 @@ module RubySmart
|
|
41
43
|
|
42
44
|
# returns a hash of all loaded gems with its current version
|
43
45
|
#
|
46
|
+
# @example
|
47
|
+
#
|
44
48
|
# GemInfo.loaded
|
45
|
-
# > {'bundler' => '2.2.30'}
|
49
|
+
# # > {'bundler' => '2.2.30'}
|
46
50
|
#
|
47
51
|
# @return [Hash{<name> => <version>}] gem name-version hash
|
48
52
|
def self.loaded
|
49
53
|
Hash[::Gem.loaded_specs.values.map { |g| [g.name, g.version.to_s] }.sort]
|
50
54
|
end
|
51
55
|
|
52
|
-
# returns true if the provided gem name is loaded.
|
56
|
+
# returns true if the provided gem name is loaded (defined within any Gemfile), but must not be required yet.
|
53
57
|
# the optional version requirement matches against the loaded version
|
54
58
|
#
|
55
59
|
# GemInfo.loaded?('bundler')
|
56
|
-
# > true
|
60
|
+
# # > true
|
57
61
|
#
|
58
62
|
# GemInfo.loaded?('bundler', '~> 3.0')
|
59
|
-
# > false
|
63
|
+
# # > false
|
60
64
|
#
|
61
65
|
# @param [String] name - the gem name
|
62
66
|
# @param [nil, String] version - optional version requirement
|
@@ -65,13 +69,13 @@ module RubySmart
|
|
65
69
|
loaded.key?(name) && (version.nil? || match?( loaded[name], version))
|
66
70
|
end
|
67
71
|
|
68
|
-
# returns an array of all
|
72
|
+
# returns an array of all required gems
|
69
73
|
#
|
70
|
-
# GemInfo.
|
74
|
+
# GemInfo.required
|
71
75
|
# > ['bundler']
|
72
76
|
#
|
73
77
|
# @return [Array<name>}] gem names
|
74
|
-
def self.
|
78
|
+
def self.required
|
75
79
|
$LOADED_FEATURES.
|
76
80
|
select { |feature| feature.match(GEM_PATH_REGEXP) }.
|
77
81
|
map { |feature|
|
@@ -82,20 +86,20 @@ module RubySmart
|
|
82
86
|
sort
|
83
87
|
end
|
84
88
|
|
85
|
-
# returns true if the provided gem name is
|
86
|
-
# the optional version
|
89
|
+
# returns true if the provided gem name is required.
|
90
|
+
# the optional version matches against the *required* version
|
87
91
|
#
|
88
|
-
# GemInfo.
|
92
|
+
# GemInfo.required?('bundler')
|
89
93
|
# > true
|
90
94
|
#
|
91
|
-
# GemInfo.
|
95
|
+
# GemInfo.required?('bundler', '~> 3.0')
|
92
96
|
# > false
|
93
97
|
#
|
94
98
|
# @param [String] name - the gem name
|
95
99
|
# @param [nil, String] version - optional version requirement
|
96
100
|
# @return [Boolean] activated?
|
97
|
-
def self.
|
98
|
-
|
101
|
+
def self.required?(name, version = nil)
|
102
|
+
required.include?(name) && (version.nil? || match?(self.version(name), version))
|
99
103
|
end
|
100
104
|
|
101
105
|
# returns an array of all loaded features
|
@@ -154,7 +158,7 @@ module RubySmart
|
|
154
158
|
# @return [Boolean]
|
155
159
|
def self.safe_require(path, gem = nil, version = nil)
|
156
160
|
# check for missing gem (nicely check if the feature name differs to the gem name)
|
157
|
-
return false if !gem.nil? && path != gem && !
|
161
|
+
return false if !gem.nil? && path != gem && !required?(gem, version)
|
158
162
|
|
159
163
|
# try to require the feature
|
160
164
|
begin
|
@@ -185,28 +189,23 @@ module RubySmart
|
|
185
189
|
# > false
|
186
190
|
def self.match?(*args)
|
187
191
|
version_current = args.shift
|
188
|
-
version_requirement = args.join
|
192
|
+
version_requirement = args.join(' ')
|
189
193
|
|
190
194
|
return true if version_requirement.nil? || version_requirement.strip == ''
|
191
195
|
|
192
|
-
# split version compare operators
|
193
|
-
version_requirement_str = version_requirement.gsub(/([=~>< ]+)/, '')
|
194
|
-
version_requirement_op = $1
|
195
|
-
|
196
|
-
# create plain versions without compare operators
|
197
196
|
gem_version_current = Gem::Version.new(version_current)
|
198
|
-
gem_version_requirement = Gem::
|
197
|
+
gem_version_requirement = Gem::Requirement.new(version_requirement)
|
199
198
|
|
200
199
|
# check if required version is PRE & current is NOT
|
201
200
|
if gem_version_requirement.prerelease? && !gem_version_current.prerelease?
|
202
|
-
|
201
|
+
gem_version_requirement = Gem::Requirement.new("#{gem_version_requirement.requirements[0][0]} #{gem_version_requirement.requirements[0][1].release.version}")
|
203
202
|
elsif gem_version_requirement.prerelease? != gem_version_current.prerelease?
|
204
203
|
# check if required version PRE doesn't equal current version PRE
|
205
|
-
|
204
|
+
gem_version_current = gem_version_current.release
|
206
205
|
end
|
207
206
|
# else is not required here: either its PRE && PRE || !PRE && !PRE
|
208
207
|
|
209
|
-
|
208
|
+
gem_version_requirement.satisfied_by?(gem_version_current)
|
210
209
|
end
|
211
210
|
end
|
212
211
|
end
|
data/ruby_smart-support.gemspec
CHANGED
@@ -3,11 +3,10 @@
|
|
3
3
|
require_relative 'lib/ruby_smart/support/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
10
|
-
|
6
|
+
spec.name = 'ruby_smart-support'
|
7
|
+
spec.version = RubySmart::Support.version
|
8
|
+
spec.authors = ['Tobias Gonsior']
|
9
|
+
spec.email = ['info@ruby-smart.org']
|
11
10
|
spec.summary = 'A toolkit of support libraries including GemInfo, ThreadInfo, Ruby core extensions & optionally activesupport extensions'
|
12
11
|
spec.description = <<~DESC
|
13
12
|
RubySmart::Support is a toolkit of support libraries for Ruby - major features includes GemInfo & ThreadInfo, as well core extensions for Ruby & activesupport (if installed).
|
@@ -17,9 +16,10 @@ Gem::Specification.new do |spec|
|
|
17
16
|
spec.license = 'MIT'
|
18
17
|
spec.required_ruby_version = '>= 2.6.0'
|
19
18
|
|
20
|
-
spec.metadata['homepage_uri']
|
21
|
-
spec.metadata['source_code_uri']
|
22
|
-
spec.metadata['
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = 'https://github.com/ruby-smart/support'
|
21
|
+
spec.metadata['documentation_uri'] = 'https://rubydoc.info/gems/ruby_smart-support'
|
22
|
+
spec.metadata['changelog_uri'] = "#{spec.metadata["source_code_uri"]}/blob/main/docs/CHANGELOG.md"
|
23
23
|
|
24
24
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
25
25
|
|
@@ -32,8 +32,8 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ['lib']
|
33
33
|
|
34
34
|
spec.add_development_dependency 'activesupport', '>= 4.0'
|
35
|
+
spec.add_development_dependency 'coveralls_reborn', '~> 0.25'
|
35
36
|
spec.add_development_dependency 'rake', '~> 13.0'
|
36
37
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
|
-
spec.add_development_dependency 'simplecov', '~> 0.21'
|
38
38
|
spec.add_development_dependency 'yard', '~> 0.9'
|
39
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_smart-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Gonsior
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -25,47 +25,47 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: coveralls_reborn
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0.25'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0.25'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
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: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- ".github/workflows/ruby.yml"
|
95
95
|
- ".gitignore"
|
96
96
|
- ".rspec"
|
97
|
+
- ".yardopts"
|
97
98
|
- Gemfile
|
98
99
|
- README.md
|
99
100
|
- Rakefile
|
@@ -126,6 +127,7 @@ licenses:
|
|
126
127
|
metadata:
|
127
128
|
homepage_uri: https://github.com/ruby-smart/support
|
128
129
|
source_code_uri: https://github.com/ruby-smart/support
|
130
|
+
documentation_uri: https://rubydoc.info/gems/ruby_smart-support
|
129
131
|
changelog_uri: https://github.com/ruby-smart/support/blob/main/docs/CHANGELOG.md
|
130
132
|
allowed_push_host: https://rubygems.org
|
131
133
|
post_install_message:
|
@@ -143,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
145
|
- !ruby/object:Gem::Version
|
144
146
|
version: '0'
|
145
147
|
requirements: []
|
146
|
-
rubygems_version: 3.3.
|
148
|
+
rubygems_version: 3.3.7
|
147
149
|
signing_key:
|
148
150
|
specification_version: 4
|
149
151
|
summary: A toolkit of support libraries including GemInfo, ThreadInfo, Ruby core extensions
|