ruby_smart-support 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/CHANGELOG.md +7 -0
- data/lib/ruby_smart/support/core_ext/ruby/enumerator.rb +19 -0
- data/lib/ruby_smart/support/core_ext.rb +1 -0
- data/lib/ruby_smart/support/gem_info.rb +12 -0
- data/lib/ruby_smart/support/gem_version.rb +1 -1
- data/lib/ruby_smart/support/thread_info.rb +3 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e2254a95ec35c6fcbd887b968dbc6a75bdfdc68289450f19b79b302cd9010d9
|
4
|
+
data.tar.gz: ade5163e4e702f1a9526da9619d40db03b60ba16505ec1e5c5408ce67642d00d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e828e44eca0c4d4c7723a03f1364463d2c6d9d7190218a089ea401c8c40d3762ef491d5df0d8d9d7086144407db7253058e7beb424771369e4ac5f1b37209fa8
|
7
|
+
data.tar.gz: c44c1784d5219dc885ab96c5dace9f877e8ded2f7c1d6ae4a2aab111a480de21ebaf03d4ae0ca63cd8f81e7625c5e3f386d1f02e55a6873b103b33ff001c0316
|
data/docs/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# RubySmart::Support - CHANGELOG
|
2
2
|
|
3
|
+
## [1.3.0] - 2023-08-08
|
4
|
+
* **[add]** `Enumerator.from_hash` to easily resolve values from Array-of-Hashes (use: ary.map.from_hash(key))
|
5
|
+
* **[add]** `RubySmart::Support::GemInfo.licenses` to resolve a hash of licences per loaded gem
|
6
|
+
* **[fix]** `RubySmart::Support::ThreadInfo.winsize`-detection for debug-ENVs
|
7
|
+
* **[ref]** `RubySmart::Support::ThreadInfo.name` to show full application namespace
|
8
|
+
* **[ref]** `RubySmart::Support::ThreadInfo.info` to show a optimized info-string
|
9
|
+
|
3
10
|
## [1.2.0] - 2023-01-24
|
4
11
|
* **[ref]** `GemInfo` methods (active -> required & active? -> required?)
|
5
12
|
* **[ref]** simplify `GemInfo.match?`method
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
unless Enumerator.method_defined? :from_hash
|
4
|
+
class Enumerator
|
5
|
+
# returns a new array with only values from provided key.
|
6
|
+
# The Enumerator must be an array of hashes.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# ary = [{a: 34, b: 12}, {a: 19, c: 4}, {b: 3, c: 11}]
|
10
|
+
# ary.with_hash(:a)
|
11
|
+
# > [34, 19, nil]
|
12
|
+
#
|
13
|
+
# @param [Object] key
|
14
|
+
# @return [Array] ary
|
15
|
+
def from_hash(key)
|
16
|
+
map &->(item){item[key]}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -53,6 +53,18 @@ module RubySmart
|
|
53
53
|
Hash[::Gem.loaded_specs.values.map { |g| [g.name, g.version.to_s] }.sort]
|
54
54
|
end
|
55
55
|
|
56
|
+
# returns a hash of all loaded gems with it's licenses
|
57
|
+
#
|
58
|
+
# @example
|
59
|
+
#
|
60
|
+
# GemInfo.licenses
|
61
|
+
# # > {'bundler' => 'MIT', 'hashery' => 'BSD-2-Clause'}
|
62
|
+
#
|
63
|
+
# @return [Hash{<name> => <license>}] licenses
|
64
|
+
def self.licenses
|
65
|
+
Hash[::Gem.loaded_specs.values.map { |g| [g.name, g.license || '?'] }.sort]
|
66
|
+
end
|
67
|
+
|
56
68
|
# returns true if the provided gem name is loaded (defined within any Gemfile), but must not be required yet.
|
57
69
|
# the optional version requirement matches against the loaded version
|
58
70
|
#
|
@@ -98,7 +98,7 @@ module RubySmart
|
|
98
98
|
# @return [String] name
|
99
99
|
def self.name
|
100
100
|
return Rake.application.top_level_tasks.first.to_s if rake?
|
101
|
-
return Rails.application.
|
101
|
+
return Rails.application.class.name if rails?
|
102
102
|
''
|
103
103
|
end
|
104
104
|
|
@@ -112,9 +112,7 @@ module RubySmart
|
|
112
112
|
# returns the thread type string
|
113
113
|
# @return [String] thread-info string
|
114
114
|
def self.info
|
115
|
-
|
116
|
-
strs << " :: #{name}" if name != ''
|
117
|
-
strs.join ' '
|
115
|
+
"$(#{id}) -> [##{process_object_id}] @ #{type} :: #{self.name}"
|
118
116
|
end
|
119
117
|
|
120
118
|
# returns true if thread has a 'window'
|
@@ -127,7 +125,7 @@ module RubySmart
|
|
127
125
|
# @return [Array<rows, columns>] winsize
|
128
126
|
def self.winsize
|
129
127
|
return IO.console.winsize if io_console?
|
130
|
-
return [ENV['ROWS'], ENV['COLUMNS']] unless ENV['ROWS'].nil?
|
128
|
+
return [ENV['ROWS'].to_i, ENV['COLUMNS'].to_i] unless ENV['ROWS'].nil? || ENV['COLUMNS'].nil?
|
131
129
|
[0, 0]
|
132
130
|
end
|
133
131
|
|
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.3.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: 2023-
|
11
|
+
date: 2023-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/ruby_smart/support/core_ext/rails/info.rb
|
112
112
|
- lib/ruby_smart/support/core_ext/rake/task.rb
|
113
113
|
- lib/ruby_smart/support/core_ext/ruby/array.rb
|
114
|
+
- lib/ruby_smart/support/core_ext/ruby/enumerator.rb
|
114
115
|
- lib/ruby_smart/support/core_ext/ruby/float.rb
|
115
116
|
- lib/ruby_smart/support/core_ext/ruby/hash.rb
|
116
117
|
- lib/ruby_smart/support/core_ext/ruby/object.rb
|