nazar 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/.rubocop.yml +4 -0
- data/lib/nazar/formatter/active_record_collection.rb +2 -0
- data/lib/nazar/formatter/generic.rb +3 -3
- data/lib/nazar/formatter/struct.rb +33 -0
- data/lib/nazar/version.rb +1 -1
- data/lib/nazar.rb +9 -2
- data/nazar.gemspec +0 -3
- metadata +5 -33
- checksums.yaml.gz.sig +0 -4
- data/certs/krzyzak.pem +0 -27
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d6d959973fd00cf0d233b01f69c7cd4bbd08889bc2251427ab855d24e13ce42
|
4
|
+
data.tar.gz: 233302d7d8b97a7299763c8f3ef70bb7182f34094f22033cc22a0781fa08379b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab38635347ebc90e8439b8a59af77b52c38f90a73a58dfd347506e6b2c1c923b4e0a8f890bad5de1d1554eb9612871b14577bc26ca264dd36db3b391b645841b
|
7
|
+
data.tar.gz: 0b0f71f05886d5b65728ab935c0ae3bbcce5ee3411e4eeadb7639e30ec0133a3c6e023127ca6b981ee075db1a60819c2a9f2cf9ea78c2174c6dd86fd021abbc8
|
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
|
-
|
31
|
-
compatible = item.respond_to?(:keys) && item.respond_to?(:values)
|
30
|
+
return false unless data.is_a?(Enumerable)
|
32
31
|
|
33
|
-
|
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,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nazar
|
4
|
+
module Formatter
|
5
|
+
class Struct
|
6
|
+
def initialize(item)
|
7
|
+
@collection = Array(item)
|
8
|
+
@attributes = item.to_h.keys
|
9
|
+
@item = item
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.valid?(data)
|
13
|
+
data.is_a?(::Struct) || data.is_a?(::OpenStruct)
|
14
|
+
end
|
15
|
+
|
16
|
+
def valid?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def headers
|
21
|
+
HeadersFormatter.new(attributes).format
|
22
|
+
end
|
23
|
+
|
24
|
+
def cells
|
25
|
+
@cells ||= @collection.map do |item|
|
26
|
+
item.each_pair do |_, value|
|
27
|
+
CellFormatter.new(value, type: nil).format
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/nazar/version.rb
CHANGED
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Krzyżanowski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIEgjCCAuqgAwIBAgIBATANBgkqhkiG9w0BAQsFADA1MTMwMQYDVQQDDCptaWNo
|
14
|
-
YWwua3J6eXphbm93c2tpX2dpdGh1Yi9EQz1nbWFpbC9EQz1jb20wHhcNMjIwOTE5
|
15
|
-
MTQwNDQyWhcNMjMwOTE5MTQwNDQyWjA1MTMwMQYDVQQDDCptaWNoYWwua3J6eXph
|
16
|
-
bm93c2tpX2dpdGh1Yi9EQz1nbWFpbC9EQz1jb20wggGiMA0GCSqGSIb3DQEBAQUA
|
17
|
-
A4IBjwAwggGKAoIBgQC22POIs4KtFipZ5W1nYbBu2iUck//fJrhyssXVxnljkZr/
|
18
|
-
8P6/BH9SiWmyatDQ+LiYug72olUoMQ2wRoZzEn58ZllZlHfPJSQ5QnIjKjITWHJt
|
19
|
-
iBi/ou31T0/OU7KVnPzryMKBL9smbxhwRbBrQlT8nV5rfHXCrpvGdOElM3EvNWwR
|
20
|
-
HM7Klal/3zlr3q/X3BZQvOp8R8hmR6OYtgNrYclS6IkvqKpcD9Y3q8K4Snz6RZ3o
|
21
|
-
DGp0QW28cF5m6CJ+N7KpQkASPuFFMAjnqyhE6r5VsklxR7I083UI1JLVOq/+s6Yt
|
22
|
-
kbCBqscI55BwcYakszStNqJXiqrEOqUEdcg5tkzc0PFC+ZEzWbMU1RTox17N1pwG
|
23
|
-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 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.
|
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
data/certs/krzyzak.pem
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
2
|
-
MIIEgjCCAuqgAwIBAgIBATANBgkqhkiG9w0BAQsFADA1MTMwMQYDVQQDDCptaWNo
|
3
|
-
YWwua3J6eXphbm93c2tpX2dpdGh1Yi9EQz1nbWFpbC9EQz1jb20wHhcNMjIwOTE5
|
4
|
-
MTQwNDQyWhcNMjMwOTE5MTQwNDQyWjA1MTMwMQYDVQQDDCptaWNoYWwua3J6eXph
|
5
|
-
bm93c2tpX2dpdGh1Yi9EQz1nbWFpb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