coactive 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +7 -1
- data/CHANGELOG.md +12 -0
- data/bin/console +2 -2
- data/gemfiles/rails70.gemfile +1 -1
- data/lib/coactive/context.rb +4 -6
- data/lib/coactive/contexts/inspect.rb +39 -0
- data/lib/coactive/initializers/contexts.rb +2 -1
- data/lib/coactive/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d34754b34f7bf3ed8e44b8f7b1ef42eff9a8c2915c335e5098e119b891c27053
|
4
|
+
data.tar.gz: e9194f39d2395961bceb2f88613de90e2f8acb7028af24ffd868c651f78f60c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c78fca95b4d4ffc86a5be1327d2049e9bd8023844aa48ff864185aa5ce6852cd9170fb8080bb412792db11db23b591ca67d79699c8b9ebeecbcc8ce8063247b3
|
7
|
+
data.tar.gz: 7c95f6e44e30304170a983db92c41ca446605d1b5abc15ffe92a680b76a0fba376ab5b629abf78c7ea6bf39aef81a174358db16628617ee1fe104f817bd6b5f3
|
data/.github/workflows/ci.yml
CHANGED
@@ -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
data/bin/console
CHANGED
data/gemfiles/rails70.gemfile
CHANGED
data/lib/coactive/context.rb
CHANGED
@@ -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,12 +29,6 @@ module Coactive
|
|
25
29
|
@_data
|
26
30
|
end
|
27
31
|
|
28
|
-
def to_s
|
29
|
-
attrs = @_data.map { |k, v| "#{k}=#{v.inspect}" }.join(', ')
|
30
|
-
"#<#{self.class} #{attrs}>"
|
31
|
-
end
|
32
|
-
alias :inspect :to_s
|
33
|
-
|
34
32
|
def define_accessors!(keys)
|
35
33
|
Array(keys).each do |key|
|
36
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
|
@@ -14,7 +14,8 @@ module Coactive
|
|
14
14
|
|
15
15
|
class_methods do
|
16
16
|
def context(*names, **options)
|
17
|
-
self._contexts =
|
17
|
+
self._contexts = _contexts.reject { |var| names.include?(var.name) }
|
18
|
+
self._contexts += names.map { |name| Variable.new(name, options) }
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
data/lib/coactive/version.rb
CHANGED
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.
|
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-
|
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
|