nazar 1.2.0 → 1.3.1

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: 29342461f59fd102beeb9253deb00b6f54086d855a2a62a11c1e108933f72600
4
- data.tar.gz: 758f662b5a103a244beea03963ebb79d658ae6e076874cba2cadea66c14869df
3
+ metadata.gz: 9ec818a6ac5c3b06e2544c97f8af1239fc25489f3098f9ca93557458a84d3aa6
4
+ data.tar.gz: febf9e37e281d3443d5d89924584d59383faa813cb8e346700355eae0ecc3975
5
5
  SHA512:
6
- metadata.gz: d0fcbdca62c72558c2ae5278efc603dbe30ef4a08ea7966a198a4f53ce58227cec71b36bdf5acc37954b47f7c379e460947c6ab8e12c804b38e74b08610aa1d9
7
- data.tar.gz: 07e02b611b902f7736ff1936b80b285da36e3fcacfc1492832eaf1b9ae307eaaa274d12f407d7cbbac4abc22a250a723943b449955dcb764c393b0a8d3650803
6
+ metadata.gz: 8b236ed7da8a4aceb2c60de3ec716b65af4ff823899bd5194613f6cb264396722c31d90903a30a7482a5b6426b2fe0ffa6dca89e8fa412532f46f66dd919a123
7
+ data.tar.gz: 2a0e0ac62a27f00ff1a36f9422ef4ed2ac9f86621ad3533b4b62b25080f598f19249b3584500f1e5a0f3dfda23150227320bba0a52bb950388e214bc3310ddb3
data/.rubocop.yml CHANGED
@@ -6,6 +6,8 @@ Style/SymbolArray:
6
6
  EnforcedStyle: brackets
7
7
  Style/WordArray:
8
8
  EnforcedStyle: brackets
9
+ Style/OpenStructUse:
10
+ Enabled: false
9
11
  Metrics/BlockLength:
10
12
  Exclude:
11
13
  - 'spec/**/*_spec.rb'
@@ -15,3 +17,5 @@ Layout/EndAlignment:
15
17
  EnforcedStyleAlignWith: variable
16
18
  Layout/FirstArrayElementIndentation:
17
19
  EnforcedStyle: consistent
20
+ Gemspec/DevelopmentDependencies:
21
+ Enabled: false
@@ -16,6 +16,8 @@ module Nazar
16
16
  end
17
17
 
18
18
  def self.valid?(data)
19
+ return false if data.is_a?(::Struct) || (defined?(OpenStruct) && data.is_a?(OpenStruct))
20
+
19
21
  data.is_a?(ActiveRecord::Associations::CollectionProxy) ||
20
22
  data.is_a?(ActiveRecord::Relation) ||
21
23
  (data.is_a?(Enumerable) && data.first.is_a?(ActiveRecord::Base))
@@ -27,10 +27,10 @@ module Nazar
27
27
  end
28
28
 
29
29
  def self.valid?(data)
30
- item = data&.first
31
- compatible = item.respond_to?(:keys) && item.respond_to?(:values)
30
+ return false unless data.is_a?(Enumerable)
32
31
 
33
- data.is_a?(Enumerable) && (item.is_a?(Struct) || compatible)
32
+ item = data&.first
33
+ item.respond_to?(:keys) && item.respond_to?(:values)
34
34
  end
35
35
 
36
36
  def valid?
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nazar
4
+ module Formatter
5
+ class Struct
6
+ def initialize(item)
7
+ @collection = item.is_a?(Array) ? item : [item]
8
+ @attributes = @collection.first.to_h.keys
9
+ end
10
+
11
+ def self.valid?(data)
12
+ valid_struct?(data) || (data.is_a?(Array) && data.all? { valid_struct?(_1) })
13
+ end
14
+
15
+ def self.valid_struct?(data)
16
+ data.is_a?(::Struct) || data.is_a?(::OpenStruct)
17
+ end
18
+
19
+ def valid?
20
+ @attributes.any?
21
+ end
22
+
23
+ def headers
24
+ HeadersFormatter.new(@attributes).format
25
+ end
26
+
27
+ def cells
28
+ @cells ||= @collection.map do |item|
29
+ item.to_h.values.map do |value|
30
+ CellFormatter.new(value, type: nil).format
31
+ end
32
+ end
33
+ end
34
+
35
+ def summary
36
+ false
37
+ end
38
+ end
39
+ end
40
+ end
data/lib/nazar/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nazar
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.1'
5
5
  end
data/lib/nazar.rb CHANGED
@@ -38,12 +38,12 @@ module Nazar # rubocop:disable Metrics/ModuleLength
38
38
 
39
39
  setting :enable_shorthand_method, default: true
40
40
 
41
- class << self
41
+ class << self # rubocop:disable Metrics/ClassLength
42
42
  def formatters
43
43
  @formatters ||= Set.new
44
44
  end
45
45
 
46
- def enable!(extensions: [:active_record, :csv])
46
+ def enable!(extensions: [:active_record, :csv, :struct])
47
47
  return if @enabled
48
48
 
49
49
  load_extensions!(extensions)
@@ -67,6 +67,12 @@ module Nazar # rubocop:disable Metrics/ModuleLength
67
67
  register_formatter!('CSVTable', 'nazar/formatter/csv_table')
68
68
  end
69
69
 
70
+ def load_struct!
71
+ require 'ostruct'
72
+
73
+ register_formatter!('Struct', 'nazar/formatter/struct')
74
+ end
75
+
70
76
  def load_active_record!
71
77
  require 'active_record'
72
78
 
@@ -113,6 +119,7 @@ module Nazar # rubocop:disable Metrics/ModuleLength
113
119
  def load_extensions!(extensions)
114
120
  load_active_record! if extensions.include?(:active_record)
115
121
  load_csv! if extensions.include?(:csv)
122
+ load_struct! if extensions.include?(:struct)
116
123
  load_sequel! if extensions.include?(:sequel)
117
124
  end
118
125
 
data/nazar.gemspec CHANGED
@@ -25,9 +25,6 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.cert_chain = ['certs/krzyzak.pem']
29
- spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME =~ /gem\z/
30
-
31
28
  spec.add_development_dependency 'activerecord', '>= 3.0', '< 6.2'
32
29
  spec.add_development_dependency 'rubocop', '~> 1.21'
33
30
  spec.add_development_dependency 'sequel', '~> 5.0'
metadata CHANGED
@@ -1,42 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nazar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Krzyżanowski
8
8
  autorequire:
9
9
  bindir: exe
10
- cert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cnp5emFub3dza2krZ2l0aHViQGdtYWlsLmNvbTANBgkqhkiG9w0BAQsF
29
- AAOCAYEAfmM8QzJAfeZkmHonfleoiIIFNSeG84wK/MWBGKr0VMIalhNHpR6DQbao
30
- 5kAQh7PMWjPr0n3ZHUT4QU7lqp1/eiErEXtKAExnxRefzWSHNm0WjXT/dIyFUbYQ
31
- rRnKtabxRNWtRIrK3GecPBDtAVTRtYQQkCaSwbwE37sHJhntS/Dvnl8pw2THq7ef
32
- XbhPDcqmP+yWRCszn9Hzda19+8VA6Sn+fIwevXMUgvb3VHqLYcIO2amHtnCeM8Q5
33
- caYBi+Tx9EDFh04EE4rbUGX25RcLO43j3ShLLqfW6QHFUtJIKS7WhgBVoEGvNA35
34
- 2KAZEiV7+ByRFKndeJmFtom0GMNBYPQW4l96aCrQJZyVhWSWGQZornxbH+hylJEp
35
- on5yD3vJbVQXzwm0Z4I1IH5xc4YbEepCQRK6u/cT6NuiQqbqeW82BxjXMPu4HVBy
36
- WXVb638bzH4OYBIYuGcw50jqBK1SyDx4exzThr6KxSiGwhAKj2xFqy51MIQjfUN0
37
- TL5B7Buq
38
- -----END CERTIFICATE-----
39
- date: 2022-10-12 00:00:00.000000000 Z
10
+ cert_chain: []
11
+ date: 2024-07-01 00:00:00.000000000 Z
40
12
  dependencies:
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: activerecord
@@ -201,7 +173,6 @@ files:
201
173
  - Rakefile
202
174
  - bin/console
203
175
  - bin/setup
204
- - certs/krzyzak.pem
205
176
  - lib/nazar.rb
206
177
  - lib/nazar/base_table.rb
207
178
  - lib/nazar/cell_formatter.rb
@@ -214,6 +185,7 @@ files:
214
185
  - lib/nazar/formatter/sequel_collection.rb
215
186
  - lib/nazar/formatter/sequel_interface.rb
216
187
  - lib/nazar/formatter/sequel_item.rb
188
+ - lib/nazar/formatter/struct.rb
217
189
  - lib/nazar/headers_formatter.rb
218
190
  - lib/nazar/horizontal_table.rb
219
191
  - lib/nazar/renderer.rb
@@ -242,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
214
  - !ruby/object:Gem::Version
243
215
  version: '0'
244
216
  requirements: []
245
- rubygems_version: 3.1.6
217
+ rubygems_version: 3.4.6
246
218
  signing_key:
247
219
  specification_version: 4
248
220
  summary: Nazar is a tool that enhances default IRB/Pry inspect output
checksums.yaml.gz.sig DELETED
@@ -1,4 +0,0 @@
1
- =�A��u���,��BH>���q
2
- �/�����L�\�U�"����/�O�ս���4�Ɋ��q&�Q8_��|UГ��7��A���w3Ũ�¿�OU��a<���������jy$��%��-#�ª��E�F]kO�����i�cc��.�hyw��iO�#<!�AGb�s��Ri��@�bє�
3
- /�(����i�q��_[
4
-
data/certs/krzyzak.pem DELETED
@@ -1,27 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIEgjCCAuqgAwIBAgIBATANBgkqhkiG9w0BAQsFADA1MTMwMQYDVQQDDCptaWNo
3
- YWwua3J6eXphbm93c2tpX2dpdGh1Yi9EQz1nbWFpbC9EQz1jb20wHhcNMjIwOTE5
4
- MTQwNDQyWhcNMjMwOTE5MTQwNDQyWjA1MTMwMQYDVQQDDCptaWNoYWwua3J6eXph
5
- bm93c2tpX2dpdGh1Yi9EQz1nbWFpbC9EQz1jb20wggGiMA0GCSqGSIb3DQEBAQUA
6
- A4IBjwAwggGKAoIBgQC22POIs4KtFipZ5W1nYbBu2iUck//fJrhyssXVxnljkZr/
7
- 8P6/BH9SiWmyatDQ+LiYug72olUoMQ2wRoZzEn58ZllZlHfPJSQ5QnIjKjITWHJt
8
- iBi/ou31T0/OU7KVnPzryMKBL9smbxhwRbBrQlT8nV5rfHXCrpvGdOElM3EvNWwR
9
- HM7Klal/3zlr3q/X3BZQvOp8R8hmR6OYtgNrYclS6IkvqKpcD9Y3q8K4Snz6RZ3o
10
- DGp0QW28cF5m6CJ+N7KpQkASPuFFMAjnqyhE6r5VsklxR7I083UI1JLVOq/+s6Yt
11
- kbCBqscI55BwcYakszStNqJXiqrEOqUEdcg5tkzc0PFC+ZEzWbMU1RTox17N1pwG
12
- VGtdE/3OxK2A/hm6GM/sFPR2ig7wRSBs6AI9bwbv259RzHvm4wr1yQDAQzuNWeyZ
13
- Wd3/SkNDN3nEF9mTEF1pyRC4UO2+tvQc5YOoW66a6W/gNyhGQk4QFT39Pt1Mq/VX
14
- Ec8+0b1uEAKvD+z9xPcCAwEAAaOBnDCBmTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE
15
- sDAdBgNVHQ4EFgQUSu4g81ThKkq44UAqzDkZQAEi4eUwLwYDVR0RBCgwJoEkbWlj
16
- aGFsLmtyenl6YW5vd3NraStnaXRodWJAZ21haWwuY29tMC8GA1UdEgQoMCaBJG1p
17
- Y2hhbC5rcnp5emFub3dza2krZ2l0aHViQGdtYWlsLmNvbTANBgkqhkiG9w0BAQsF
18
- AAOCAYEAfmM8QzJAfeZkmHonfleoiIIFNSeG84wK/MWBGKr0VMIalhNHpR6DQbao
19
- 5kAQh7PMWjPr0n3ZHUT4QU7lqp1/eiErEXtKAExnxRefzWSHNm0WjXT/dIyFUbYQ
20
- rRnKtabxRNWtRIrK3GecPBDtAVTRtYQQkCaSwbwE37sHJhntS/Dvnl8pw2THq7ef
21
- XbhPDcqmP+yWRCszn9Hzda19+8VA6Sn+fIwevXMUgvb3VHqLYcIO2amHtnCeM8Q5
22
- caYBi+Tx9EDFh04EE4rbUGX25RcLO43j3ShLLqfW6QHFUtJIKS7WhgBVoEGvNA35
23
- 2KAZEiV7+ByRFKndeJmFtom0GMNBYPQW4l96aCrQJZyVhWSWGQZornxbH+hylJEp
24
- on5yD3vJbVQXzwm0Z4I1IH5xc4YbEepCQRK6u/cT6NuiQqbqeW82BxjXMPu4HVBy
25
- WXVb638bzH4OYBIYuGcw50jqBK1SyDx4exzThr6KxSiGwhAKj2xFqy51MIQjfUN0
26
- TL5B7Buq
27
- -----END CERTIFICATE-----
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
Binary file