chic 0.3.1 → 0.4.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: 29c1b7b66f93c55e96cd4f3399b52a89461f32212c5752df80f3413a5c8898ce
4
- data.tar.gz: 3cd78efa318d5614ab2c37a02c986bbe2f27760e1710591b32059889aa1c7cd4
3
+ metadata.gz: 7f1e33c29c46b9b252242a63738d36d8c0df73c376e28fb48cbd523714c1457b
4
+ data.tar.gz: 3fc457a2964db0476da406ec8fb65e218708a71664401214021ad10f169a1d2d
5
5
  SHA512:
6
- metadata.gz: 101121d9551d426c4c6d8e39b75f96def4ae7bd22955d1c0a93ff6509e755bcad33eb55bc1bfbae0cbdbffae03c1aea459c82fcbc3dfad0410b5db77960e73ea
7
- data.tar.gz: edef9ddd2761744818b172b34f1d6942fc2d3fafaf81ec6edc600e26eab36bfafb75d55916830931b74cf1e20679f657c81babf326ee5bc75e8241d6cdb370e8
6
+ metadata.gz: 351e6e91852b4d8d99c49e0e17e5a5be9b27a0f8fe945efde4557710deae561db4aa02eb2498f17246d19d8fe1ec33dc855ee122e7659bce5c239d090e52a8b8
7
+ data.tar.gz: cdfd46826892dd382bc5bd04484eadccce465b5577102df406bd56d1228f56a8d18113fbba93929a73c33c646c536b73771135c74b6b543fbb812416b725ebc3
@@ -0,0 +1,29 @@
1
+ name: pr-updated
2
+ on:
3
+ pull_request:
4
+ types:
5
+ - opened
6
+ - synchronize
7
+ jobs:
8
+ run_lint:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - name: Set up Ruby
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ bundler-cache: true
16
+ ruby-version: 3.2.2
17
+ - name: Run Rubocop
18
+ run: bundle exec rubocop lib
19
+ run_tests:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ bundler-cache: true
27
+ ruby-version: 3.2.2
28
+ - name: Test
29
+ run: bundle exec rake test
data/chic.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.required_ruby_version = '>= 2.7'
27
27
 
28
- spec.add_development_dependency 'bundler', '~> 2.3.10'
28
+ spec.add_development_dependency 'bundler', '~> 2.4'
29
29
  spec.add_development_dependency 'minitest', '~> 5.0'
30
30
  spec.add_development_dependency 'rake', '~> 13.0'
31
31
  spec.add_development_dependency 'rubocop', '~> 0.71'
data/lib/chic/formats.rb CHANGED
@@ -110,7 +110,8 @@ module Chic
110
110
  end
111
111
 
112
112
  def format(value, with: nil, **options)
113
- _formatter_class(with).new(value).tap do |formatter|
113
+ formatter_context = respond_to?(:context) ? context : nil
114
+ _formatter_class(with).new(value, formatter_context).tap do |formatter|
114
115
  options.each do |option, argument|
115
116
  formatter.public_send(option, argument) if formatter.respond_to?(option)
116
117
  end
@@ -2,11 +2,19 @@
2
2
 
3
3
  module Chic
4
4
  class Formatter < SimpleDelegator
5
- delegate :to_s,
6
- to: :object
5
+ attr_reader :context
6
+
7
+ def initialize(object, context = nil)
8
+ super(object)
9
+ @context = context
10
+ end
7
11
 
8
12
  def object
9
13
  __getobj__
10
14
  end
15
+
16
+ def to_s
17
+ object.to_s
18
+ end
11
19
  end
12
20
  end
data/lib/chic/presents.rb CHANGED
@@ -91,7 +91,7 @@ module Chic
91
91
  def present(object, with: nil)
92
92
  if object.is_a?(Enumerable)
93
93
  object.map { |o| present(o, with: with) }
94
- elsif with.present?
94
+ elsif with.is_a?(Class)
95
95
  with.new(object, context)
96
96
  elsif object.nil?
97
97
  nil_presenter(object)
data/lib/chic/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chic
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.0'
5
5
  end
data/lib/chic.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'delegate'
4
+
3
5
  require 'chic/version'
4
6
  require 'chic/errors'
5
7
  require 'chic/helpers'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lawrance Shepstone
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-03 00:00:00.000000000 Z
11
+ date: 2023-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.10
19
+ version: '2.4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.3.10
26
+ version: '2.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,16 +66,16 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.71'
69
- description:
69
+ description:
70
70
  email:
71
71
  - lawrance@collabcollective.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".github/workflows/pr-updated.yml"
76
77
  - ".gitignore"
77
78
  - ".rubocop.yml"
78
- - ".travis.yml"
79
79
  - CODE_OF_CONDUCT.md
80
80
  - Gemfile
81
81
  - LICENSE.txt
@@ -104,7 +104,7 @@ homepage: https://github.com/collcoll/chic
104
104
  licenses:
105
105
  - MIT
106
106
  metadata: {}
107
- post_install_message:
107
+ post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
@@ -119,8 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubygems_version: 3.1.2
123
- signing_key:
122
+ rubygems_version: 3.4.10
123
+ signing_key:
124
124
  specification_version: 4
125
125
  summary: Opinionated presentation layer comprised of presenters and formatters.
126
126
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.5.5
7
- before_install: gem install bundler -v 2.0.1