nazar 1.3.0 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nazar/formatter/active_record_collection.rb +2 -2
- data/lib/nazar/formatter/struct.rb +13 -6
- data/lib/nazar/version.rb +1 -1
- data/nazar.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcc3232a7523f78bf69adb0739dd0291085fdefb9d9e9e134aa353de19bba9d8
|
4
|
+
data.tar.gz: a63f9ae27c24191f564afc9e49533265d71fc49273cd225b69e88dfffe8072aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2787f4a577a2c5acf16de9ec2469ba11f9531995478cc5677392d0055337214eb9fe2a7bd21b796a14210eaea5558d1295893c06ab7613991273b1974639d03f
|
7
|
+
data.tar.gz: 6655b2be011cd2b480ba112cd6e276ad4e3467df5a5ce1f53800852e3cc4a1df828d0c299478c1d73bbbaff325609d7768701903220a2589708b7117a32f799a
|
@@ -16,11 +16,11 @@ 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))
|
19
|
+
return false if data.is_a?(::Struct) || (defined?(OpenStruct) && data.is_a?(OpenStruct))
|
20
20
|
|
21
21
|
data.is_a?(ActiveRecord::Associations::CollectionProxy) ||
|
22
22
|
data.is_a?(ActiveRecord::Relation) ||
|
23
|
-
(data.is_a?(Enumerable) && data.first.is_a?(ActiveRecord::Base))
|
23
|
+
(data.is_a?(Enumerable) && !data.is_a?(Range) && data.first.is_a?(ActiveRecord::Base))
|
24
24
|
end
|
25
25
|
|
26
26
|
def summary
|
@@ -4,30 +4,37 @@ module Nazar
|
|
4
4
|
module Formatter
|
5
5
|
class Struct
|
6
6
|
def initialize(item)
|
7
|
-
@collection = Array
|
8
|
-
@attributes =
|
9
|
-
@item = item
|
7
|
+
@collection = item.is_a?(Array) ? item : [item]
|
8
|
+
@attributes = @collection.first.to_h.keys
|
10
9
|
end
|
11
10
|
|
12
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)
|
13
16
|
data.is_a?(::Struct) || data.is_a?(::OpenStruct)
|
14
17
|
end
|
15
18
|
|
16
19
|
def valid?
|
17
|
-
|
20
|
+
@attributes.any?
|
18
21
|
end
|
19
22
|
|
20
23
|
def headers
|
21
|
-
HeadersFormatter.new(attributes).format
|
24
|
+
HeadersFormatter.new(@attributes).format
|
22
25
|
end
|
23
26
|
|
24
27
|
def cells
|
25
28
|
@cells ||= @collection.map do |item|
|
26
|
-
item.
|
29
|
+
item.to_h.values.map do |value|
|
27
30
|
CellFormatter.new(value, type: nil).format
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
34
|
+
|
35
|
+
def summary
|
36
|
+
false
|
37
|
+
end
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
data/lib/nazar/version.rb
CHANGED
data/nazar.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
31
31
|
spec.add_development_dependency 'simplecov', '~> 0.20'
|
32
32
|
spec.add_development_dependency 'sqlite3', '~> 1.0'
|
33
33
|
|
34
|
-
spec.add_runtime_dependency 'dry-configurable', '~>
|
34
|
+
spec.add_runtime_dependency 'dry-configurable', '~> 1.2'
|
35
35
|
spec.add_runtime_dependency 'pastel', '~> 0.8'
|
36
36
|
spec.add_runtime_dependency 'tty-pager', '~> 0.14'
|
37
37
|
spec.add_runtime_dependency 'tty-screen', '~> 0.8'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nazar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Krzyżanowski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '1.2'
|
96
96
|
type: :runtime
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
102
|
+
version: '1.2'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: pastel
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|