spaced 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5ef69eb8f535a9dc505eaeecae109a756337df1a64d602bc0d9ede0f06714eb
4
- data.tar.gz: a8731824808507cadc9a1362a004870919ab5e51be233439fe3fe4d77aeb1a89
3
+ metadata.gz: e95fb65f0b0ade8bf4647182fc469ea8bba03a155879601b9909211b8f28f887
4
+ data.tar.gz: 3eaf53745ff8e07bc2d2641a7c6efa6329297bc23d5636bd31b30f5ea343f131
5
5
  SHA512:
6
- metadata.gz: cfdc46fedd7c789836c16849e9fc58372f765f1d5e78c60640ca3d8c0b24b2da2a3fc7080fc0ce0a060f3826d9e2e46688781c53ce7120836cb24595eab6436d
7
- data.tar.gz: ffd8dcd6d1214381a0aecee9df96eeb65ffd099b216d19118ea0b1ef3e5576020f54995bdc317e75704a24871209cc7ed60cc154b7598d2d2ba4fcc366d0deed
6
+ metadata.gz: c97886f379866f01e28e7234c38cc66fdb812407d4e2a35207db9eb92587fad7d5e8b4bd286d073198f305de96bea819fae81d6d6dd448d1a4dc02775ebe4126
7
+ data.tar.gz: f316314d0c88cc6016f17b6d83634154cfa66c32427eace1c90217c87d07deabd71d3a58e8185a3c92fe097bb7313190cab1e1c2cd3bf53f4242f3488253c216
data/Gemfile.lock CHANGED
@@ -1,50 +1,63 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spaced (0.8.0)
4
+ spaced (0.9.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.2)
10
- json (2.10.1)
11
- language_server-protocol (3.17.0.4)
9
+ addressable (2.8.9)
10
+ public_suffix (>= 2.0.2, < 8.0)
11
+ ast (2.4.3)
12
+ bigdecimal (4.0.1)
13
+ json (2.18.1)
14
+ json-schema (6.1.0)
15
+ addressable (~> 2.8)
16
+ bigdecimal (>= 3.1, < 5)
17
+ language_server-protocol (3.17.0.5)
12
18
  lint_roller (1.1.0)
13
- parallel (1.26.3)
14
- parser (3.3.7.1)
19
+ mcp (0.8.0)
20
+ json-schema (>= 4.1)
21
+ parallel (1.27.0)
22
+ parser (3.3.10.2)
15
23
  ast (~> 2.4.1)
16
24
  racc
25
+ prism (1.9.0)
26
+ public_suffix (7.0.5)
17
27
  racc (1.8.1)
18
28
  rainbow (3.1.1)
19
- regexp_parser (2.10.0)
20
- rubocop (1.72.1)
29
+ regexp_parser (2.11.3)
30
+ rubocop (1.85.0)
21
31
  json (~> 2.3)
22
32
  language_server-protocol (~> 3.17.0.2)
23
33
  lint_roller (~> 1.1.0)
34
+ mcp (~> 0.6)
24
35
  parallel (~> 1.10)
25
36
  parser (>= 3.3.0.2)
26
37
  rainbow (>= 2.2.2, < 4.0)
27
38
  regexp_parser (>= 2.9.3, < 3.0)
28
- rubocop-ast (>= 1.38.0, < 2.0)
39
+ rubocop-ast (>= 1.49.0, < 2.0)
29
40
  ruby-progressbar (~> 1.7)
30
41
  unicode-display_width (>= 2.4.0, < 4.0)
31
- rubocop-ast (1.38.0)
32
- parser (>= 3.3.1.0)
33
- rubocop-minitest (0.37.1)
42
+ rubocop-ast (1.49.0)
43
+ parser (>= 3.3.7.2)
44
+ prism (~> 1.7)
45
+ rubocop-minitest (0.39.1)
34
46
  lint_roller (~> 1.1)
35
- rubocop (>= 1.72.1, < 2.0)
47
+ rubocop (>= 1.75.0, < 2.0)
36
48
  rubocop-ast (>= 1.38.0, < 2.0)
37
49
  ruby-progressbar (1.13.0)
38
- sus (0.32.0)
39
- unicode-display_width (3.1.4)
40
- unicode-emoji (~> 4.0, >= 4.0.4)
41
- unicode-emoji (4.0.4)
50
+ sus (0.35.2)
51
+ unicode-display_width (3.2.0)
52
+ unicode-emoji (~> 4.1)
53
+ unicode-emoji (4.2.0)
42
54
 
43
55
  PLATFORMS
44
56
  arm64-darwin-21
45
57
  arm64-darwin-22
46
58
  arm64-darwin-23
47
59
  arm64-darwin-24
60
+ arm64-darwin-25
48
61
  x86_64-linux
49
62
 
50
63
  DEPENDENCIES
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Spaced
2
2
 
3
- Spaced is a super simple and convenient way to isolate and namespace a collection of related methods into any class.
3
+ Spaced is a super simple and convenient way to isolate and namespace a collection of related instance methods into any class.
4
4
 
5
5
  ## Usage
6
6
 
@@ -27,6 +27,22 @@ class User
27
27
 
28
28
  # Or pass a predefined class, which should subclass `Spaced::Base`.
29
29
  namespace :facebook, Facebook::Api
30
+
31
+ class Facebook::Api < Spaced::Base
32
+ def create(msg)
33
+ api.create_post msg
34
+ end
35
+
36
+ def read(id)
37
+ api.read_post id
38
+ end
39
+
40
+ private
41
+
42
+ def api
43
+ @api ||= FacebookClient.new(api_token: parent.api_token)
44
+ end
45
+ end
30
46
  end
31
47
 
32
48
  user = User.new
@@ -84,6 +100,32 @@ user.tweet? # Will call the `#tweet?` method on `:tweet` namespace.
84
100
  user.tweet! # Will call the `#tweet!` method on `:tweet` namespace.
85
101
  ```
86
102
 
103
+ ## Setter methods
104
+
105
+ You can also define a `#_=` setter method in your namespace:
106
+
107
+ ```ruby
108
+ namespace :tweet do
109
+ def _=(value)
110
+ update_tweet value
111
+ end
112
+ end
113
+ user = User.new
114
+ user.tweet = 'updated content' # Will call the `#_=` method.
115
+ ```
116
+
117
+ As with bang and predicate methods, you can use a named setter instead:
118
+
119
+ ```ruby
120
+ namespace :tweet do
121
+ def tweet=(value)
122
+ update_tweet value
123
+ end
124
+ end
125
+ user = User.new
126
+ user.tweet = 'updated content' # Will call the `#tweet=` method on `:tweet` namespace.
127
+ ```
128
+
87
129
  ## Installation
88
130
 
89
131
  Add this line to your application's Gemfile:
data/fixtures/user.rb CHANGED
@@ -19,6 +19,10 @@ class User
19
19
  def sister?
20
20
  true
21
21
  end
22
+
23
+ def sister=(value)
24
+ value
25
+ end
22
26
  end
23
27
 
24
28
  namespace :mother do
@@ -29,5 +33,9 @@ class User
29
33
  def _?(*, **)
30
34
  true
31
35
  end
36
+
37
+ def _=(value)
38
+ value
39
+ end
32
40
  end
33
41
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spaced
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.0"
5
5
  end
data/lib/spaced.rb CHANGED
@@ -70,6 +70,22 @@ module Spaced
70
70
  caller
71
71
  end
72
72
  end
73
+
74
+ if methods.include?(:_=)
75
+ module_eval <<-RUBY, __FILE__, __LINE__ + 1
76
+ def #{name}=(value); #{name}._=(value); end # def user=; user._=; end
77
+ RUBY
78
+ elsif methods.include?(:"#{name}=")
79
+ module_eval <<-RUBY, __FILE__, __LINE__ + 1
80
+ def #{name}=(value); #{name}.#{name}=(value); end # def user=; user.user=; end
81
+ RUBY
82
+ else
83
+ define_method :"#{name}=" do |_value|
84
+ raise NoMethodError,
85
+ "undefined method `#{name}=' for #<#{klass}>. Have you defined `#{klass}#_=` or `#{klass}##{name}=`?",
86
+ caller
87
+ end
88
+ end
73
89
  end
74
90
  end
75
91
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spaced
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Moss
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  email:
13
13
  - joel@developwithstyle.com
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  requirements: []
52
- rubygems_version: 3.6.3
52
+ rubygems_version: 4.0.3
53
53
  specification_version: 4
54
54
  summary: Super simple and convenient way to isolate and namespace a collection of
55
55
  related methods