nazar 0.0.1 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/workflows/main.yml +38 -0
- data/.rubocop.yml +15 -0
- data/README.md +5 -29
- data/certs/krzyzak.pem +27 -0
- data/lib/nazar/cell_formatter.rb +36 -0
- data/lib/nazar/formatter/active_record_collection.rb +23 -0
- data/lib/nazar/formatter/active_record_interface.rb +25 -0
- data/lib/nazar/formatter/active_record_item.rb +21 -0
- data/lib/nazar/formatter/csv_table.rb +48 -0
- data/lib/nazar/formatter.rb +8 -0
- data/lib/nazar/headers_formatter.rb +21 -0
- data/lib/nazar/renderer.rb +30 -0
- data/lib/nazar/version.rb +1 -1
- data/lib/nazar/view.rb +89 -0
- data/lib/nazar.rb +87 -0
- data/nazar.gemspec +5 -0
- data.tar.gz.sig +4 -0
- metadata +77 -3
- metadata.gz.sig +1 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caea3f0827d9d39e782cf749a4e4d1d4828ef5e6c0fc1293eceb4aa084ea77c7
|
4
|
+
data.tar.gz: 3dcb286c61452847f5c5d0d6aa8ea03d36943ba76c322cf0c09995cb6655efe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66df708fe14e78480c65ef01f1353e0454b4f423aa2a47888c6b9ce3c19a2ddec26d53ce64f18d4b6339eaaa64c4ae5591e2d680e5e90721f86ac50baf932658
|
7
|
+
data.tar.gz: 79976a910bf1bd58c8a0b60bbe9d50d4c0a24d61d2dcc756f5fe3404e672263e332ea5feeae1f20631addc0c991c216b6e93d84e03d34b02a37e613883418495
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# This is a basic workflow to help you get started with Actions
|
2
|
+
|
3
|
+
name: CI
|
4
|
+
|
5
|
+
# Controls when the workflow will run
|
6
|
+
on: [push]
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 2.7
|
16
|
+
bundler-cache: true
|
17
|
+
|
18
|
+
- name: Bundle
|
19
|
+
run: bundle
|
20
|
+
rubocop:
|
21
|
+
runs-on: ubuntu-latest
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
- uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: 2.7
|
27
|
+
bundler-cache: true
|
28
|
+
- run: bundle exec rubocop --format simple
|
29
|
+
specs:
|
30
|
+
runs-on: ubuntu-latest
|
31
|
+
steps:
|
32
|
+
- uses: actions/checkout@v2
|
33
|
+
- uses: ruby/setup-ruby@v1
|
34
|
+
with:
|
35
|
+
ruby-version: 2.7
|
36
|
+
bundler-cache: true
|
37
|
+
- name: Specs
|
38
|
+
run: bundle exec rspec
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
Style/Documentation:
|
4
|
+
Enabled: false
|
5
|
+
Style/SymbolArray:
|
6
|
+
EnforcedStyle: brackets
|
7
|
+
Style/WordArray:
|
8
|
+
EnforcedStyle: brackets
|
9
|
+
Metrics/BlockLength:
|
10
|
+
Exclude:
|
11
|
+
- 'spec/**/*_spec.rb'
|
12
|
+
Layout/CaseIndentation:
|
13
|
+
EnforcedStyle: end
|
14
|
+
Layout/EndAlignment:
|
15
|
+
EnforcedStyleAlignWith: variable
|
data/README.md
CHANGED
@@ -1,36 +1,12 @@
|
|
1
|
-
# Nazar
|
1
|
+
# Nazar [![Build Status](https://github.com/krzyzak/nazar/actions/workflows/main.yml/badge.svg)](https://github.com/krzyzak/nazar/actions) [![Gem Version](https://badge.fury.io/rb/nazar.svg)](https://badge.fury.io/rb/nazar) [![Code Climate](https://codeclimate.com/github/krzyzak/nazar/badges/gpa.svg)](https://codeclimate.com/github/krzyzak/nazar)
|
2
2
|
|
3
|
-
|
3
|
+
Nazar improves defvault inspect output for console applications (supports IRB and Pry).
|
4
4
|
|
5
|
-
|
5
|
+
**Nazar is under heavy development now. Expect bumpy ride or wait until the API will stabilise a bit ;)**
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'nazar'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install nazar
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
7
|
+
[![asciicast](https://asciinema.org/a/436814.png)](https://asciinema.org/a/436814)
|
32
8
|
|
33
9
|
## Contributing
|
34
10
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
11
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/krzyzak/nazar.
|
36
12
|
|
data/certs/krzyzak.pem
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIEgjCCAuqgAwIBAgIBATANBgkqhkiG9w0BAQsFADA1MTMwMQYDVQQDDCptaWNo
|
3
|
+
YWwua3J6eXphbm93c2tpX2dp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CAYEAw0q3kANMgrsHJ76bt86tTfJhMFhqldTzlXE92nuM8wTonNTiuwNpbJW0
|
19
|
+
sd2mK/n0Lm4kfe/wt5uwtvggtxhmoH8Sac1VyLiVOj+/7jfymYbxfMCC8uGDsPX0
|
20
|
+
CU7u/Mp+Dr9U8PXIM+ICQ5PmhxZjK0BUXZlZ18shGI1mFY+v0FwjDNYgTgmiHAiW
|
21
|
+
rH93qOM3GH6L1NykkBnmwZyLtIYhEvMpWebqojW+A3wrhxrVUG7XiqMrn2vy0pZW
|
22
|
+
9SRgzlg5M1H3rU+RJVp8ve5Nz1gfb0C5kXnOtvDQuLAX+8OzE/kPi8K0lCKvfJpC
|
23
|
+
3HPm1Il1fZp5WMnGj4zsIIESYj9j0Q12x9yygZGPksZrgcbdho1lBaZTt0+eqTVq
|
24
|
+
JWaxXNTngvP87JEn1IlU2S+n2huSBtSd+h3UaubUMDUanTewtjfp1HOpGdN5qTsS
|
25
|
+
FlwFUDGjWAe8lcsjyGp1dox0FK91TAHdZW1op8LYnOcO2DM8Mgzu4Gp7mibATEnx
|
26
|
+
ooN2pwmH
|
27
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nazar
|
4
|
+
class CellFormatter
|
5
|
+
def initialize(value, type: :string)
|
6
|
+
@value = value
|
7
|
+
@type = type
|
8
|
+
end
|
9
|
+
|
10
|
+
def format
|
11
|
+
case type
|
12
|
+
when :boolean
|
13
|
+
format_boolean(value)
|
14
|
+
when :integer
|
15
|
+
Pastel.new(enabled: Nazar.config.colors.enabled).bright_blue(value)
|
16
|
+
else
|
17
|
+
value.nil? ? format_nil : value.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :value, :type
|
24
|
+
|
25
|
+
def format_boolean(value)
|
26
|
+
return format_nil if value.nil?
|
27
|
+
|
28
|
+
true_value, false_value = Nazar.config.formatter.boolean
|
29
|
+
Formatter::TRUTHY_VALUES.include?(value.to_s.downcase) ? true_value : false_value
|
30
|
+
end
|
31
|
+
|
32
|
+
def format_nil
|
33
|
+
Pastel.new(enabled: Nazar.config.colors.enabled).dim(Nazar.config.formatter.nil)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nazar/formatter/active_record_interface'
|
4
|
+
|
5
|
+
module Nazar
|
6
|
+
module Formatter
|
7
|
+
class ActiveRecordCollection
|
8
|
+
include ActiveRecordInterface
|
9
|
+
|
10
|
+
def initialize(collection)
|
11
|
+
@collection = collection
|
12
|
+
@collection.load if @collection.respond_to?(:loaded?) && !@collection.loaded?
|
13
|
+
|
14
|
+
@attributes = collection.first&.attributes
|
15
|
+
@klass = collection.first&.class
|
16
|
+
end
|
17
|
+
|
18
|
+
def summary
|
19
|
+
collection.size
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nazar
|
4
|
+
module Formatter
|
5
|
+
module ActiveRecordInterface
|
6
|
+
attr_reader :collection, :klass, :attributes
|
7
|
+
|
8
|
+
def valid?
|
9
|
+
!!(attributes && klass)
|
10
|
+
end
|
11
|
+
|
12
|
+
def headers
|
13
|
+
HeadersFormatter.new(attributes.keys).format
|
14
|
+
end
|
15
|
+
|
16
|
+
def cells
|
17
|
+
@cells ||= collection.map do |item|
|
18
|
+
item.attributes.map do |column, value|
|
19
|
+
CellFormatter.new(value, type: klass.type_for_attribute(column).type).format
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nazar/formatter/active_record_interface'
|
4
|
+
|
5
|
+
module Nazar
|
6
|
+
module Formatter
|
7
|
+
class ActiveRecordItem
|
8
|
+
include ActiveRecordInterface
|
9
|
+
|
10
|
+
def initialize(item)
|
11
|
+
@collection = [item]
|
12
|
+
@attributes = item.attributes
|
13
|
+
@klass = item.class
|
14
|
+
end
|
15
|
+
|
16
|
+
def summary
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nazar
|
4
|
+
module Formatter
|
5
|
+
class CSVTable
|
6
|
+
attr_reader :collection
|
7
|
+
|
8
|
+
def initialize(collection)
|
9
|
+
@collection = collection
|
10
|
+
end
|
11
|
+
|
12
|
+
def valid?
|
13
|
+
!!collection && !collection.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
def headers
|
17
|
+
HeadersFormatter.new(collection.headers).format
|
18
|
+
end
|
19
|
+
|
20
|
+
def cells
|
21
|
+
@cells ||= collection.map do |item|
|
22
|
+
item.fields.map do |value|
|
23
|
+
CellFormatter.new(value, type: detect_type(value)).format
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def summary
|
29
|
+
collection.size
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
BOOLEAN_VALUES = TRUTHY_VALUES + FALSY_VALUES
|
35
|
+
|
36
|
+
def detect_type(value)
|
37
|
+
case value
|
38
|
+
when ->(val) { BOOLEAN_VALUES.include?(val.to_s.downcase) }
|
39
|
+
:boolean
|
40
|
+
when Numeric
|
41
|
+
:numeric
|
42
|
+
else
|
43
|
+
:string
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nazar
|
4
|
+
class HeadersFormatter
|
5
|
+
def initialize(headers)
|
6
|
+
@headers = headers
|
7
|
+
end
|
8
|
+
|
9
|
+
def format
|
10
|
+
headers.map { |header| pastel.bold(header) }
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_reader :headers
|
16
|
+
|
17
|
+
def pastel
|
18
|
+
@pastel ||= Pastel.new(enabled: Nazar.config.colors.enabled)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nazar
|
4
|
+
class Renderer
|
5
|
+
def initialize(data)
|
6
|
+
@data = data
|
7
|
+
end
|
8
|
+
|
9
|
+
def render
|
10
|
+
pager.page(view.render)
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def valid?
|
15
|
+
view.supported_data?
|
16
|
+
end
|
17
|
+
|
18
|
+
def pager
|
19
|
+
@pager ||= TTY::Pager::SystemPager.new(command: 'less -iMSx4 -FX')
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :data
|
25
|
+
|
26
|
+
def view
|
27
|
+
@view ||= View.new(data)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/nazar/version.rb
CHANGED
data/lib/nazar/view.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nazar
|
4
|
+
class View
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def_delegators :formatter, :headers, :cells, :summary
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@data = data
|
11
|
+
end
|
12
|
+
|
13
|
+
def render
|
14
|
+
return unless supported_data?
|
15
|
+
|
16
|
+
table.tap do
|
17
|
+
add_summary if summary
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def supported_data?
|
22
|
+
!!formatter_klass && formatter.valid?
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :data
|
28
|
+
|
29
|
+
def formatter_klass
|
30
|
+
@formatter_klass ||= case data
|
31
|
+
when boolean?
|
32
|
+
nil
|
33
|
+
when acttive_record_collection?
|
34
|
+
Formatter::ActiveRecordCollection
|
35
|
+
when active_record_item?
|
36
|
+
Formatter::ActiveRecordItem
|
37
|
+
when csv_table?
|
38
|
+
Formatter::CSVTable
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def formatter
|
43
|
+
@formatter ||= formatter_klass.new(data)
|
44
|
+
end
|
45
|
+
|
46
|
+
def boolean?
|
47
|
+
proc { data === true || data === false } # rubocop:disable Style/CaseEquality
|
48
|
+
end
|
49
|
+
|
50
|
+
def acttive_record_collection?
|
51
|
+
return false unless Nazar.extensions.include?(:active_record)
|
52
|
+
|
53
|
+
proc do
|
54
|
+
data.is_a?(ActiveRecord::Associations::CollectionProxy) ||
|
55
|
+
data.is_a?(ActiveRecord::Relation) ||
|
56
|
+
(data.is_a?(Array) && data.first.is_a?(ActiveRecord::Base))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def active_record_item?
|
61
|
+
return false unless Nazar.extensions.include?(:active_record)
|
62
|
+
|
63
|
+
proc { data.is_a?(ActiveRecord::Base) }
|
64
|
+
end
|
65
|
+
|
66
|
+
def csv_table?
|
67
|
+
return false unless Nazar.extensions.include?(:csv)
|
68
|
+
|
69
|
+
proc { data.is_a?(CSV::Table) }
|
70
|
+
end
|
71
|
+
|
72
|
+
def add_summary
|
73
|
+
table.add_separator
|
74
|
+
table.add_row [pastel.bold('Total'), { value: summary, colspan: headers.size - 1 }]
|
75
|
+
end
|
76
|
+
|
77
|
+
def table
|
78
|
+
@table ||= Terminal::Table.new(
|
79
|
+
headings: headers,
|
80
|
+
rows: cells,
|
81
|
+
style: { border: :unicode_thick_edge }
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
def pastel
|
86
|
+
@pastel ||= Pastel.new(enabled: Nazar.config.colors.enabled)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/nazar.rb
CHANGED
@@ -1,6 +1,93 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'dry-configurable'
|
4
|
+
require 'terminal-table'
|
5
|
+
require 'pastel'
|
6
|
+
require 'tty-pager'
|
7
|
+
|
3
8
|
require 'nazar/version'
|
9
|
+
require 'nazar/cell_formatter'
|
10
|
+
require 'nazar/headers_formatter'
|
11
|
+
require 'nazar/renderer'
|
12
|
+
require 'nazar/formatter'
|
13
|
+
require 'nazar/view'
|
4
14
|
|
5
15
|
module Nazar
|
16
|
+
extend Dry::Configurable
|
17
|
+
|
18
|
+
setting :formatter do
|
19
|
+
setting :nil, default: '∅'
|
20
|
+
setting :boolean, default: ['✓', '✗']
|
21
|
+
end
|
22
|
+
|
23
|
+
setting :colors do
|
24
|
+
setting :enabled, default: ENV.fetch('ENABLE_TTY_COLORS') { TTY::Color.color? ? 'true' : 'false' } == 'true'
|
25
|
+
end
|
26
|
+
|
27
|
+
class << self
|
28
|
+
def extensions
|
29
|
+
@extensions ||= Set.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def enable!(extensions: [:active_record, :csv])
|
33
|
+
return if @enabled
|
34
|
+
|
35
|
+
load_active_record! if extensions.include?(:active_record)
|
36
|
+
load_csv! if extensions.include?(:csv)
|
37
|
+
|
38
|
+
enable_for_irb! if defined?(IRB)
|
39
|
+
enable_for_pry! if defined?(Pry)
|
40
|
+
|
41
|
+
@enabled = true
|
42
|
+
end
|
43
|
+
|
44
|
+
def load_csv!
|
45
|
+
extensions << :csv
|
46
|
+
|
47
|
+
require 'csv'
|
48
|
+
load 'nazar/formatter/csv_table.rb'
|
49
|
+
end
|
50
|
+
|
51
|
+
def load_active_record!
|
52
|
+
extensions << :active_record
|
53
|
+
|
54
|
+
require 'active_record'
|
55
|
+
load 'nazar/formatter/active_record_collection.rb'
|
56
|
+
load 'nazar/formatter/active_record_item.rb'
|
57
|
+
end
|
58
|
+
|
59
|
+
def enable_for_irb!
|
60
|
+
::IRB::Irb.class_eval do
|
61
|
+
alias_method :__original_output_value__, :output_value
|
62
|
+
def output_value(omit = false) # rubocop:disable Style/OptionalBooleanParameter
|
63
|
+
renderer = Nazar::Renderer.new(@context.last_value)
|
64
|
+
renderer.valid? ? renderer.render : __original_output_value__(omit)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def enable_for_pry!
|
70
|
+
@__original_pry_print = Pry.config.print
|
71
|
+
Pry.config.print = proc do |output, value, instance|
|
72
|
+
renderer = Nazar::Renderer.new(value)
|
73
|
+
renderer.valid? ? renderer.render : @__original_pry_print.call(output, value, instance)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def disable!
|
78
|
+
return unless @enabled
|
79
|
+
|
80
|
+
disable_for_irb! if defined?(IRB)
|
81
|
+
|
82
|
+
@enabled = false
|
83
|
+
end
|
84
|
+
|
85
|
+
def disable_for_irb!
|
86
|
+
::IRB::Irb.send(:alias_method, :output_value, :__original_output_value__)
|
87
|
+
end
|
88
|
+
|
89
|
+
def disable_for_pry!
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
end
|
6
93
|
end
|
data/nazar.gemspec
CHANGED
@@ -23,7 +23,12 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
|
+
spec.cert_chain = ['certs/krzyzak.pem']
|
27
|
+
spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME =~ /gem\z/
|
28
|
+
|
29
|
+
spec.add_development_dependency 'activerecord', '>= 3.0', '< 6.2'
|
26
30
|
spec.add_development_dependency 'rubocop', '~> 1.21'
|
31
|
+
spec.add_development_dependency 'sqlite3'
|
27
32
|
|
28
33
|
spec.add_runtime_dependency 'dry-configurable', '~> 0.12'
|
29
34
|
spec.add_runtime_dependency 'pastel', '~> 0.8'
|
data.tar.gz.sig
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
@�O��a���/��W��58H͑�˃�E�5����-eFa�oJI� + �t+�3����������$���ZO�����4ٸorl�٣�&{��P¢�{А ÛH�-�!Ћ�&
|
2
|
+
}�^j�_�w�w���/p߫��H���}�J��d��TC�cd1��-&�6�N���j�J��q15����z�n�/B���ש�H���2m��]�Bt�h�\�P)��J$=��c��2����
|
3
|
+
@�Y�E�
|
4
|
+
,w��i�ú��y����{U����'I��Kr.:���F�Y��e@ccE6�Xe� ��7��Љd�wz ��>(�+�K�� �6iG���a�V�l���^&UX��bԤ旻����]Zf~c
|
metadata
CHANGED
@@ -1,15 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nazar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Krzyżanowski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEgjCCAuqgAwIBAgIBATANBgkqhkiG9w0BAQsFADA1MTMwMQYDVQQDDCptaWNo
|
14
|
+
YWwua3J6eXphbm93c2tpX2dpdGh1Yi9EQz1nbWFpbC9EQz1jb20wHhcNMjEwOTE3
|
15
|
+
MTYyMDMyWhcNMjIwOTE3MTYyMDMyWjA1MTMwMQYDVQQDDCptaWNoYWwua3J6eXph
|
16
|
+
bm93c2tpX2dpdGh1Yi9EQz1nbWFpbC9EQz1jb20wggGiMA0GCSqGSIb3DQEBAQUA
|
17
|
+
A4IBjwAwggGKAoIBgQDEWgTDpbt17SytlzKcnFAeiNeL95n0/kwX6ubyXItTDKlG
|
18
|
+
Tw4KuDrqp2rcEZZhbqVLfJX3NgAFpme6fC1sg6KfG6b5w6g+b9NBw4q1+gw1LS0J
|
19
|
+
SITmgZJrMOq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vfJpC
|
34
|
+
3HPm1Il1fZp5WMnGj4zsIIESYj9j0Q12x9yygZGPksZrgcbdho1lBaZTt0+eqTVq
|
35
|
+
JWaxXNTngvP87JEn1IlU2S+n2huSBtSd+h3UaubUMDUanTewtjfp1HOpGdN5qTsS
|
36
|
+
FlwFUDGjWAe8lcsjyGp1dox0FK91TAHdZW1op8LYnOcO2DM8Mgzu4Gp7mibATEnx
|
37
|
+
ooN2pwmH
|
38
|
+
-----END CERTIFICATE-----
|
39
|
+
date: 2021-09-23 00:00:00.000000000 Z
|
12
40
|
dependencies:
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activerecord
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '6.2'
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.0'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '6.2'
|
13
61
|
- !ruby/object:Gem::Dependency
|
14
62
|
name: rubocop
|
15
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +72,20 @@ dependencies:
|
|
24
72
|
- - "~>"
|
25
73
|
- !ruby/object:Gem::Version
|
26
74
|
version: '1.21'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: sqlite3
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
27
89
|
- !ruby/object:Gem::Dependency
|
28
90
|
name: dry-configurable
|
29
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,16 +149,28 @@ executables: []
|
|
87
149
|
extensions: []
|
88
150
|
extra_rdoc_files: []
|
89
151
|
files:
|
152
|
+
- ".github/workflows/main.yml"
|
90
153
|
- ".gitignore"
|
91
154
|
- ".rspec"
|
155
|
+
- ".rubocop.yml"
|
92
156
|
- Gemfile
|
93
157
|
- LICENSE.txt
|
94
158
|
- README.md
|
95
159
|
- Rakefile
|
96
160
|
- bin/console
|
97
161
|
- bin/setup
|
162
|
+
- certs/krzyzak.pem
|
98
163
|
- lib/nazar.rb
|
164
|
+
- lib/nazar/cell_formatter.rb
|
165
|
+
- lib/nazar/formatter.rb
|
166
|
+
- lib/nazar/formatter/active_record_collection.rb
|
167
|
+
- lib/nazar/formatter/active_record_interface.rb
|
168
|
+
- lib/nazar/formatter/active_record_item.rb
|
169
|
+
- lib/nazar/formatter/csv_table.rb
|
170
|
+
- lib/nazar/headers_formatter.rb
|
171
|
+
- lib/nazar/renderer.rb
|
99
172
|
- lib/nazar/version.rb
|
173
|
+
- lib/nazar/view.rb
|
100
174
|
- nazar.gemspec
|
101
175
|
homepage: https://github.com/krzyzak/nazar
|
102
176
|
licenses: []
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
���h���"Z��LQ+��+�d1ά&|������>�7-��y�_"m��?��lm�<<D�Ҧ��1Əu9IZH��;j��c����P=�=���-i����W������:�w�κ�䲁��}]���3����D"&B�k" ]�'���0��ɴa-�Ig������T��4�}���hT:>6$�<�%�j�e�Xg�g��1{����N�����0Qڎ��BUOU��ȓ�]�I1B{M�+:�n��U�ə�&�ј/�@��I������i���Mds�u�� GPS�t���4����S��:�v#�����r�@[I����g����2\r�����<��H"�y@���v/\Kk�3c�ė���J�=�
|