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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd347393200ee92556b1d3ea0c6c364d5da5a13be34100fda90056005ac22adf
4
- data.tar.gz: 92bf3aae8deda45cc40b2aa7eb77d5e8774e9ae46320246642e6ea1c8ba3102a
3
+ metadata.gz: '04538f8760bf132b3624905d73d7d814be6db112127400c8813f788fbbcccbd9'
4
+ data.tar.gz: a25eef7736cfe55d98316f55fc44fac46b1866cdfa27fdac19194942c55cd685
5
5
  SHA512:
6
- metadata.gz: aec073cf8aece0a5930fe22f83365fe804bc589b40b84b7524f5b21edaf4053df678b59968f9c1f1222b7773ec228b3cda5343d9d8c99fb7f7eddc79ab7d869e
7
- data.tar.gz: fdc642a6c32398c676e353599d61855390999eca7aea52a3c5a51a0a9c0fc7e3c28ea3c264fc75ac5112e3b30bd8dc97ebea664b819016b160567e854e6be90a
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
- /pkg/
7
- /spec/reports/
8
- /tmp/
15
+ /docs/yard
16
+ /.coveralls.yml
9
17
 
10
- # rspec failure tracking
11
- .rspec_status
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
@@ -0,0 +1,4 @@
1
+ --embed-mixins
2
+ --markup=markdown
3
+ --files docs/*.*
4
+ --plugin relative_markdown_links
data/README.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # RubySmart::Support
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/ruby_smart-support.svg)](https://badge.fury.io/rb/ruby_smart-support)
4
- [![Test](https://github.com/ruby-smart/support/actions/workflows/ruby.yml/badge.svg)](https://github.com/ruby-smart/support/actions/workflows/ruby.yml)
5
- [![RubySmart::Support Build Status](https://shields.io/github/workflow/status/ruby-smart/support/Test)](https://github.com/ruby-smart/support/actions)
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](./docs/CHANGELOG.md)
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](./docs/CODE_OF_CONDUCT.md).
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](./docs/LICENSE.txt) can be found @ the docs.
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](./docs/CODE_OF_CONDUCT.md).
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/support"
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 to_s method
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].to_s)
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 active gems
72
+ # returns an array of all required gems
69
73
  #
70
- # GemInfo.active
74
+ # GemInfo.required
71
75
  # > ['bundler']
72
76
  #
73
77
  # @return [Array<name>}] gem names
74
- def self.active
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 active.
86
- # the optional version requirement matches against the *loaded* version
89
+ # returns true if the provided gem name is required.
90
+ # the optional version matches against the *required* version
87
91
  #
88
- # GemInfo.active?('bundler')
92
+ # GemInfo.required?('bundler')
89
93
  # > true
90
94
  #
91
- # GemInfo.active?('bundler', '~> 3.0')
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.active?(name, version = nil)
98
- active.include?(name) && (version.nil? || match?(self.version(name), version))
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 && !active?(gem, version)
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::Version.new(version_requirement_str)
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
- version_requirement = "#{version_requirement_op}#{gem_version_requirement.release}"
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
- version_current = gem_version_current.release.to_s
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
- Gem::Dependency.new('', version_requirement).match?('', version_current)
208
+ gem_version_requirement.satisfied_by?(gem_version_current)
210
209
  end
211
210
  end
212
211
  end
@@ -9,8 +9,8 @@ module RubySmart
9
9
 
10
10
  module VERSION
11
11
  MAJOR = 1
12
- MINOR = 1
13
- TINY = 1
12
+ MINOR = 2
13
+ TINY = 0
14
14
  PRE = nil
15
15
 
16
16
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -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 = 'ruby_smart-support'
7
- spec.version = RubySmart::Support.version
8
- spec.authors = ['Tobias Gonsior']
9
- spec.email = ['info@ruby-smart.org']
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'] = spec.homepage
21
- spec.metadata['source_code_uri'] = 'https://github.com/ruby-smart/support'
22
- spec.metadata['changelog_uri'] = "#{spec.metadata["source_code_uri"]}/blob/main/docs/CHANGELOG.md"
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.1.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: 2022-11-15 00:00:00.000000000 Z
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: rake
28
+ name: coveralls_reborn
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '13.0'
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: '13.0'
40
+ version: '0.25'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
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: '3.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: simplecov
56
+ name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.21'
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.21'
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.22
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