coactive 0.2.2 → 0.3.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: cc658ad8e03f5de6bb345b90606d45be83e91ec260e39abcdf4008f2890d6505
4
- data.tar.gz: bbe87c6271b5a42b4f4a08fc4c095d1f2078d9d4d9a4e6b8c8d0d7e05b771725
3
+ metadata.gz: d34754b34f7bf3ed8e44b8f7b1ef42eff9a8c2915c335e5098e119b891c27053
4
+ data.tar.gz: e9194f39d2395961bceb2f88613de90e2f8acb7028af24ffd868c651f78f60c8
5
5
  SHA512:
6
- metadata.gz: 6f48fcf54084e267df1533eefe6569fca5ee5d36181c8e4ed36ab6327b1cd94b81d1a163f0dfdbe54058c061bc58410d10e925b7fa3d180a95bb0ebe740fe6c5
7
- data.tar.gz: f4f2339513f0292800d5d65862b631c989a0ccd0ae8d3aad3ad9e2f906692b71c1eca0df4684ffbb9e61475d3f1b80c6ed815758949de472da3ff4f6694d14e3
6
+ metadata.gz: c78fca95b4d4ffc86a5be1327d2049e9bd8023844aa48ff864185aa5ce6852cd9170fb8080bb412792db11db23b591ca67d79699c8b9ebeecbcc8ce8063247b3
7
+ data.tar.gz: 7c95f6e44e30304170a983db92c41ca446605d1b5abc15ffe92a680b76a0fba376ab5b629abf78c7ea6bf39aef81a174358db16628617ee1fe104f817bd6b5f3
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0']
11
+ ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1]
12
12
  gemfile: ['rails50', 'rails51', 'rails52', 'rails60', 'rails61', 'rails70']
13
13
  exclude:
14
14
  - ruby: 2.3
@@ -33,6 +33,12 @@ jobs:
33
33
  gemfile: rails51
34
34
  - ruby: 3.0
35
35
  gemfile: rails52
36
+ - ruby: 3.1
37
+ gemfile: rails50
38
+ - ruby: 3.1
39
+ gemfile: rails51
40
+ - ruby: 3.1
41
+ gemfile: rails52
36
42
 
37
43
  name: ruby ${{ matrix.ruby }}, ${{ matrix.gemfile }}
38
44
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.3.0
4
+
5
+ * Reduce inspection size for context.
6
+
3
7
  ## 0.2.2
4
8
 
5
9
  * Allow overwrite context variables.
data/bin/console CHANGED
@@ -10,5 +10,5 @@ require "coactive"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- # require "irb"
14
- # IRB.start
13
+ require "irb"
14
+ IRB.start
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "rails", "~> 7.0.0"
3
+ gem "rails", "~> 7.0.1"
4
4
 
5
5
  gemspec path: "../"
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'contexts/inspect'
4
+
3
5
  module Coactive
4
6
  class Context
7
+ include Contexts::Inspect
8
+
5
9
  attr_reader :_data
6
10
 
7
11
  def initialize(data = {}, &block)
@@ -25,11 +29,6 @@ module Coactive
25
29
  @_data
26
30
  end
27
31
 
28
- def to_s
29
- attrs = @_data.map { |k, v| "#{k}=#{v.to_s.truncate(300)}" }.join(', ')
30
- "#<#{self.class} #{attrs}>"
31
- end
32
-
33
32
  def define_accessors!(keys)
34
33
  Array(keys).each do |key|
35
34
  define_singleton_method key do
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coactive
4
+ module Contexts
5
+ module Inspect
6
+ extend ActiveSupport::Concern
7
+
8
+ def to_s
9
+ "#<#{self.class} #{self.class.inspect(@_data)}>"
10
+ end
11
+
12
+ class_methods do
13
+ def inspect(data)
14
+ data.map { |k, v| "#{k}=#{Coactive::Contexts::Inspect.call(v)}" }.join(', ')
15
+ end
16
+ end
17
+
18
+ class << self
19
+ class_attribute :max_num, :max_length
20
+ self.max_num = 5
21
+ self.max_length = 300
22
+
23
+ def call(data)
24
+ if data.is_a?(Array)
25
+ str = data.take(max_num).map { |v| call(v) }.join(', ')
26
+ str += '...' if data.size > max_num
27
+ "[#{str}]"
28
+ elsif data.is_a?(Hash)
29
+ str = data.take(max_num).map { |k, v| "#{k}: #{call(v)}" }.join(', ')
30
+ str += '...' if data.size > max_num
31
+ "{#{str}}"
32
+ else
33
+ data.to_s.truncate(max_length)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coactive
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coactive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshikazu Kaneta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-05 00:00:00.000000000 Z
11
+ date: 2022-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -127,6 +127,7 @@ files:
127
127
  - lib/coactive/config.rb
128
128
  - lib/coactive/configure.rb
129
129
  - lib/coactive/context.rb
130
+ - lib/coactive/contexts/inspect.rb
130
131
  - lib/coactive/contextualizer.rb
131
132
  - lib/coactive/errors.rb
132
133
  - lib/coactive/initializer.rb
@@ -158,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  - !ruby/object:Gem::Version
159
160
  version: '0'
160
161
  requirements: []
161
- rubygems_version: 3.0.3
162
+ rubygems_version: 3.1.2
162
163
  signing_key:
163
164
  specification_version: 4
164
165
  summary: Make classes coactive