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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '04538f8760bf132b3624905d73d7d814be6db112127400c8813f788fbbcccbd9'
4
- data.tar.gz: a25eef7736cfe55d98316f55fc44fac46b1866cdfa27fdac19194942c55cd685
3
+ metadata.gz: 4e2254a95ec35c6fcbd887b968dbc6a75bdfdc68289450f19b79b302cd9010d9
4
+ data.tar.gz: ade5163e4e702f1a9526da9619d40db03b60ba16505ec1e5c5408ce67642d00d
5
5
  SHA512:
6
- metadata.gz: cdca8016dc310dee6967f9f35ee9ba24bbb67e968ed6836306e2df22f68433d5d8cc86260b8c7b00ea86ea173e44d02a5efe89cbf3403f3a0091eab609a40aef
7
- data.tar.gz: c8d56578f4bc8dd2fb8adcd081176b1ffd5c8fa52db1cc82380f6baac7358e7163e4b54810fd8d21ca15f2e0c9aa8dd4024516dfbbb58eb6e14767555fd2fe28
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
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "core_ext/ruby/array"
4
+ require_relative "core_ext/ruby/enumerator"
4
5
  require_relative "core_ext/ruby/float"
5
6
  require_relative "core_ext/ruby/hash"
6
7
  require_relative "core_ext/ruby/object"
@@ -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
  #
@@ -9,7 +9,7 @@ module RubySmart
9
9
 
10
10
  module VERSION
11
11
  MAJOR = 1
12
- MINOR = 2
12
+ MINOR = 3
13
13
  TINY = 0
14
14
  PRE = nil
15
15
 
@@ -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.to_s.split('::').first if rails?
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
- strs = ["$#{id}", "[##{process_object_id}]","@ #{type}"]
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? && ENV['COLUMNS'].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.2.0
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-01-24 00:00:00.000000000 Z
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