ruby_smart-support 1.0.0 → 1.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/.gitignore +3 -0
- data/README.md +19 -10
- data/Rakefile +8 -0
- data/docs/CHANGELOG.md +9 -0
- data/lib/ruby_smart/support/core_ext/activesupport/hash.rb +10 -7
- data/lib/ruby_smart/support/core_ext/ruby/array.rb +3 -3
- data/lib/ruby_smart/support/gem_info.rb +14 -8
- data/lib/ruby_smart/support/gem_version.rb +2 -2
- data/lib/ruby_smart-support.rb +3 -1
- data/ruby_smart-support.gemspec +22 -21
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd347393200ee92556b1d3ea0c6c364d5da5a13be34100fda90056005ac22adf
|
4
|
+
data.tar.gz: 92bf3aae8deda45cc40b2aa7eb77d5e8774e9ae46320246642e6ea1c8ba3102a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aec073cf8aece0a5930fe22f83365fe804bc589b40b84b7524f5b21edaf4053df678b59968f9c1f1222b7773ec228b3cda5343d9d8c99fb7f7eddc79ab7d869e
|
7
|
+
data.tar.gz: fdc642a6c32398c676e353599d61855390999eca7aea52a3c5a51a0a9c0fc7e3c28ea3c264fc75ac5112e3b30bd8dc97ebea664b819016b160567e854e6be90a
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -60,10 +60,10 @@ ThreadInfo.console?
|
|
60
60
|
|
61
61
|
# returns the current thread name (rake / rails)
|
62
62
|
ThreadInfo.name
|
63
|
-
# >
|
63
|
+
# > "RakeTaskName"
|
64
64
|
|
65
65
|
# returns true if thread has a 'window'
|
66
|
-
ThreadInfo.
|
66
|
+
ThreadInfo.windowed?
|
67
67
|
# > true
|
68
68
|
|
69
69
|
# returns the thread type string
|
@@ -130,14 +130,15 @@ GemInfo.safe_require('action_view/helpers/date_helper','actionview', '> 0.1.0')
|
|
130
130
|
# compares two versions against each other
|
131
131
|
GemInfo.match?('4.3.0', '4.3.0')
|
132
132
|
# > true
|
133
|
-
|
134
|
-
GemInfo.match?('
|
133
|
+
|
134
|
+
GemInfo.match?('4.3.0', '>= 3.0')
|
135
135
|
# > true
|
136
|
-
|
137
|
-
|
136
|
+
|
137
|
+
# also works with split operator
|
138
|
+
GemInfo.match?( '3.3.0', '~>', ' 3.1')
|
138
139
|
# > true
|
139
|
-
|
140
|
-
GemInfo.match?( '
|
140
|
+
|
141
|
+
GemInfo.match?( '0.1.0', '~> 1.1.0',)
|
141
142
|
# > false
|
142
143
|
```
|
143
144
|
|
@@ -172,12 +173,20 @@ namespace :db do
|
|
172
173
|
end
|
173
174
|
end
|
174
175
|
|
175
|
-
task(:migrate).append do |
|
176
|
+
task(:migrate).append do |_t|
|
176
177
|
puts "execution done!"
|
177
178
|
end
|
178
179
|
end
|
179
180
|
```
|
180
181
|
|
182
|
+
_So the execution of this rake task will now execute `prepend`, `default` & `append` blocks:_
|
183
|
+
```shell
|
184
|
+
rake db:migrate
|
185
|
+
# > executes prepend
|
186
|
+
# > executes previously defined block
|
187
|
+
# > executes append block
|
188
|
+
```
|
189
|
+
|
181
190
|
-----
|
182
191
|
|
183
192
|
## Docs
|
@@ -186,7 +195,7 @@ end
|
|
186
195
|
|
187
196
|
## Contributing
|
188
197
|
|
189
|
-
Bug reports and pull requests are welcome on GitHub
|
198
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/ruby-smart/support).
|
190
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).
|
191
200
|
|
192
201
|
## License
|
data/Rakefile
CHANGED
@@ -6,3 +6,11 @@ require "rspec/core/rake_task"
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
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
|
data/docs/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# RubySmart::Support - CHANGELOG
|
2
2
|
|
3
|
+
## [1.1.1] - 2022-11-15
|
4
|
+
* **[fix]** `GemInfo` & `ThreadInfo` not being included on require 'ruby_smart-support'
|
5
|
+
* **[fix]** yard comments
|
6
|
+
* **[add]** `yard` gem for documentation
|
7
|
+
|
8
|
+
## [1.1.0] - 2022-11-12
|
9
|
+
* **[ref]** `GemInfo.match?` method to provide method parameters more intuitive like `.match?('3.4.0', '>', '3.1.0')`
|
10
|
+
* **[fix]** README
|
11
|
+
|
3
12
|
## [1.0.0] - 2022-11-08
|
4
13
|
* **[add]** `GemInfo` module
|
5
14
|
* **[add]** `ThreadInfo` module
|
@@ -8,12 +8,13 @@ unless Hash.method_defined? "only!"
|
|
8
8
|
# Replaces the hash with only the given keys (if exists),
|
9
9
|
# but returns the same hash (not the removed keys - this differs to *Hash#slice!*)
|
10
10
|
#
|
11
|
+
# @example
|
11
12
|
# hsh = {a: 1, b: 2, c: 3}
|
12
13
|
# hsh.only!(:a, :d)
|
13
14
|
# > {a: 1}
|
14
15
|
# > hsh == {a: 1}
|
15
16
|
#
|
16
|
-
# @param [
|
17
|
+
# @param [Array] keys
|
17
18
|
# @return [Hash] self
|
18
19
|
def only!(*keys)
|
19
20
|
slice!(*keys)
|
@@ -27,15 +28,16 @@ unless Hash.method_defined? "without!"
|
|
27
28
|
# removes the given keys from hash and returns those key => value pairs
|
28
29
|
# (this differs to *Hash#except!*)
|
29
30
|
#
|
31
|
+
# @example
|
30
32
|
# hsh = {a: 1, b: 2, c: 3}
|
31
33
|
# hsh.without!(:a, :d)
|
32
34
|
# > {a: 1}
|
33
35
|
# > hsh == {b: 2, c: 3}
|
34
36
|
#
|
35
|
-
# @param [
|
37
|
+
# @param [Array] keys
|
36
38
|
# @return [Hash] self
|
37
39
|
def without!(*keys)
|
38
|
-
Hash[
|
40
|
+
Hash[to_a - except!(*keys).to_a]
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
@@ -44,12 +46,13 @@ unless Hash.method_defined? "deep_reject"
|
|
44
46
|
class Hash
|
45
47
|
# returns a new Hash with items that the block evaluates to true removed, also to deep Hashes.
|
46
48
|
def deep_reject(&blk)
|
47
|
-
|
49
|
+
deep_dup.deep_reject!(&blk)
|
48
50
|
end
|
49
51
|
|
50
52
|
# deep reject by provided block
|
51
53
|
# deep remove keys that the block evaluates to true
|
52
54
|
#
|
55
|
+
# @example
|
53
56
|
# hsh = {a: 1, b: 2, c: 3, d: {a: 1, b: 2, c: 3}}
|
54
57
|
# hsh.deep_reject! {|_k,v| v.is_a?(Numeric) && v > 2}
|
55
58
|
# > hsh == {a: 1, b: 2, d: {a: 1, b: 2}}
|
@@ -58,13 +61,13 @@ unless Hash.method_defined? "deep_reject"
|
|
58
61
|
# hsh.deep_reject! {|k,v| k == :d || v == 2}
|
59
62
|
# > hsh == {a: 1, c: 3}
|
60
63
|
def deep_reject!(&blk)
|
61
|
-
|
64
|
+
each do |k, v|
|
62
65
|
if blk.(k, v)
|
63
|
-
|
66
|
+
delete(k)
|
64
67
|
elsif v.is_a?(Hash)
|
65
68
|
v.deep_reject!(&blk)
|
66
69
|
end
|
67
70
|
end
|
68
71
|
end
|
69
72
|
end
|
70
|
-
end
|
73
|
+
end
|
@@ -9,10 +9,10 @@ unless Array.method_defined? :only!
|
|
9
9
|
# ary.only!(:bar, :moon)
|
10
10
|
# > ary == [:bar]
|
11
11
|
#
|
12
|
-
# @param [
|
12
|
+
# @param [Array] values
|
13
13
|
# @return [Array] self
|
14
14
|
def only!(*values)
|
15
|
-
reject! {|value| !values.include?(value)}
|
15
|
+
reject! { |value| !values.include?(value) }
|
16
16
|
self
|
17
17
|
end
|
18
18
|
end
|
@@ -27,7 +27,7 @@ unless Array.method_defined? :only
|
|
27
27
|
# ary.only(:bar, :bat, :moon)
|
28
28
|
# > [:bar, :bat]
|
29
29
|
#
|
30
|
-
# @param [
|
30
|
+
# @param [Array] values
|
31
31
|
# @return [Array] ary
|
32
32
|
def only(*values)
|
33
33
|
dup.only!(*values)
|
@@ -36,7 +36,7 @@ module RubySmart
|
|
36
36
|
# @param [nil, String] version - optional version requirement
|
37
37
|
# @return [Boolean]
|
38
38
|
def self.installed?(name, version = nil)
|
39
|
-
installed.key?(name) && (version.nil? || installed[name].any? { |gem_version| match?(
|
39
|
+
installed.key?(name) && (version.nil? || installed[name].any? { |gem_version| match?(gem_version, version) })
|
40
40
|
end
|
41
41
|
|
42
42
|
# returns a hash of all loaded gems with its current version
|
@@ -62,7 +62,7 @@ module RubySmart
|
|
62
62
|
# @param [nil, String] version - optional version requirement
|
63
63
|
# @return [Boolean]
|
64
64
|
def self.loaded?(name, version = nil)
|
65
|
-
loaded.key?(name) && (version.nil? || match?(
|
65
|
+
loaded.key?(name) && (version.nil? || match?( loaded[name], version))
|
66
66
|
end
|
67
67
|
|
68
68
|
# returns an array of all active gems
|
@@ -95,7 +95,7 @@ module RubySmart
|
|
95
95
|
# @param [nil, String] version - optional version requirement
|
96
96
|
# @return [Boolean] activated?
|
97
97
|
def self.active?(name, version = nil)
|
98
|
-
active.include?(name) && (version.nil? || match?(version, version
|
98
|
+
active.include?(name) && (version.nil? || match?(self.version(name), version))
|
99
99
|
end
|
100
100
|
|
101
101
|
# returns an array of all loaded features
|
@@ -172,16 +172,22 @@ module RubySmart
|
|
172
172
|
# match?('4.3.0', '4.3.0')
|
173
173
|
# > true
|
174
174
|
#
|
175
|
-
# match?('
|
175
|
+
# match?('4.3.0', '>= 3.0')
|
176
176
|
# > true
|
177
177
|
#
|
178
|
-
# match?(
|
178
|
+
# match?('3.3.0', '~> 3.1')
|
179
179
|
# > true
|
180
180
|
#
|
181
|
-
# match?(
|
181
|
+
# match?('3.3.0', '~>', '3.1')
|
182
|
+
# > true
|
183
|
+
#
|
184
|
+
# match?('0.1.0', '~> 1.1.0')
|
182
185
|
# > false
|
183
|
-
def self.match?(
|
184
|
-
|
186
|
+
def self.match?(*args)
|
187
|
+
version_current = args.shift
|
188
|
+
version_requirement = args.join ' '
|
189
|
+
|
190
|
+
return true if version_requirement.nil? || version_requirement.strip == ''
|
185
191
|
|
186
192
|
# split version compare operators
|
187
193
|
version_requirement_str = version_requirement.gsub(/([=~>< ]+)/, '')
|
data/lib/ruby_smart-support.rb
CHANGED
data/ruby_smart-support.gemspec
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
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
|
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
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
RubySmart::Support is a toolkit of support libraries for Ruby - major features includes GemInfo & ThreadInfo, as well core extensions for Ruby & activesupport (if installed).
|
14
|
-
DESC
|
11
|
+
spec.summary = 'A toolkit of support libraries including GemInfo, ThreadInfo, Ruby core extensions & optionally activesupport extensions'
|
12
|
+
spec.description = <<~DESC
|
13
|
+
RubySmart::Support is a toolkit of support libraries for Ruby - major features includes GemInfo & ThreadInfo, as well core extensions for Ruby & activesupport (if installed).
|
14
|
+
DESC
|
15
15
|
|
16
|
-
spec.homepage =
|
17
|
-
spec.license =
|
18
|
-
spec.required_ruby_version =
|
16
|
+
spec.homepage = 'https://github.com/ruby-smart/support'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
spec.required_ruby_version = '>= 2.6.0'
|
19
19
|
|
20
|
-
spec.metadata[
|
21
|
-
spec.metadata[
|
22
|
-
spec.metadata[
|
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"
|
23
23
|
|
24
|
-
spec.metadata[
|
24
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
25
25
|
|
26
26
|
# Specify which files should be added to the gem when it is released.
|
27
27
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -29,10 +29,11 @@ DESC
|
|
29
29
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
30
30
|
end
|
31
31
|
|
32
|
-
spec.require_paths = [
|
32
|
+
spec.require_paths = ['lib']
|
33
33
|
|
34
|
-
spec.add_development_dependency 'activesupport',
|
35
|
-
spec.add_development_dependency '
|
36
|
-
spec.add_development_dependency '
|
37
|
-
spec.add_development_dependency 'simplecov',
|
34
|
+
spec.add_development_dependency 'activesupport', '>= 4.0'
|
35
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
|
+
spec.add_development_dependency 'simplecov', '~> 0.21'
|
38
|
+
spec.add_development_dependency 'yard', '~> 0.9'
|
38
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.1.1
|
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-
|
11
|
+
date: 2022-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -25,33 +25,33 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
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: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.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: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.21'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.9'
|
69
83
|
description: 'RubySmart::Support is a toolkit of support libraries for Ruby - major
|
70
84
|
features includes GemInfo & ThreadInfo, as well core extensions for Ruby & activesupport
|
71
85
|
(if installed).
|
@@ -129,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
143
|
- !ruby/object:Gem::Version
|
130
144
|
version: '0'
|
131
145
|
requirements: []
|
132
|
-
rubygems_version: 3.3.
|
146
|
+
rubygems_version: 3.3.22
|
133
147
|
signing_key:
|
134
148
|
specification_version: 4
|
135
149
|
summary: A toolkit of support libraries including GemInfo, ThreadInfo, Ruby core extensions
|