observer 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test.yml +13 -9
- data/lib/observer.rb +26 -1
- data/observer.gemspec +11 -8
- metadata +8 -7
- data/lib/observer/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c117cdd3260db5f033e7d706cf819f19dc036ce7cefb4dfdc0728ce382644716
|
4
|
+
data.tar.gz: 959948ed0029b8c62186c393bc1dbcd2d31c9b1c134287704d0c59e2a62fa9b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 070c86e9a76bfc0adcdd991d36494e65cdfc16708c1dc81baf4269f02980c6103f7abe3de2903ce2923e2fdea99d964dae69f8b42e768c5398b42a86c809c67d
|
7
|
+
data.tar.gz: 35966edd21bda158a75c8f65bd16e5833190686afcabf21392b6e09e897ad03681b442c9bdd1622d19b06dd6710cf041a099fcd89c7b5933b352fbae05270818
|
data/.github/workflows/test.yml
CHANGED
@@ -1,24 +1,28 @@
|
|
1
|
-
name:
|
1
|
+
name: test
|
2
2
|
|
3
3
|
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
|
-
|
6
|
+
ruby-versions:
|
7
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
8
|
+
with:
|
9
|
+
engine: cruby
|
10
|
+
min_version: 2.4
|
11
|
+
|
12
|
+
test:
|
13
|
+
needs: ruby-versions
|
7
14
|
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
8
15
|
strategy:
|
9
16
|
matrix:
|
10
|
-
ruby:
|
17
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
11
18
|
os: [ ubuntu-latest, macos-latest ]
|
12
19
|
runs-on: ${{ matrix.os }}
|
13
20
|
steps:
|
14
|
-
- uses: actions/checkout@
|
21
|
+
- uses: actions/checkout@v4
|
15
22
|
- name: Set up Ruby
|
16
23
|
uses: ruby/setup-ruby@v1
|
17
24
|
with:
|
18
25
|
ruby-version: ${{ matrix.ruby }}
|
19
|
-
|
20
|
-
run: |
|
21
|
-
gem install bundler --no-document
|
22
|
-
bundle install
|
26
|
+
bundler-cache: true # Run "bundle install", and cache the result automatically.
|
23
27
|
- name: Run test
|
24
|
-
run: rake test
|
28
|
+
run: bundle exec rake test
|
data/lib/observer.rb
CHANGED
@@ -111,7 +111,32 @@
|
|
111
111
|
# Current price: 112
|
112
112
|
# Current price: 79
|
113
113
|
# --- Sun Jun 09 00:10:25 CDT 2002: Price below 80: 79
|
114
|
+
#
|
115
|
+
# === Usage with procs
|
116
|
+
#
|
117
|
+
# The +#notify_observers+ method can also be used with +proc+s by using
|
118
|
+
# the +:call+ as +func+ parameter.
|
119
|
+
#
|
120
|
+
# The following example illustrates the use of a lambda:
|
121
|
+
#
|
122
|
+
# require 'observer'
|
123
|
+
#
|
124
|
+
# class Ticker
|
125
|
+
# include Observable
|
126
|
+
#
|
127
|
+
# def run
|
128
|
+
# # logic to retrieve the price (here 77.0)
|
129
|
+
# changed
|
130
|
+
# notify_observers(77.0)
|
131
|
+
# end
|
132
|
+
# end
|
133
|
+
#
|
134
|
+
# ticker = Ticker.new
|
135
|
+
# warner = ->(price) { puts "New price received: #{price}" }
|
136
|
+
# ticker.add_observer(warner, :call)
|
137
|
+
# ticker.run
|
114
138
|
module Observable
|
139
|
+
VERSION = "0.1.2"
|
115
140
|
|
116
141
|
#
|
117
142
|
# Add +observer+ as an observer on this object. So that it will receive
|
@@ -194,7 +219,7 @@ module Observable
|
|
194
219
|
if defined? @observer_state and @observer_state
|
195
220
|
if defined? @observer_peers
|
196
221
|
@observer_peers.each do |k, v|
|
197
|
-
k.
|
222
|
+
k.__send__(v, *arg)
|
198
223
|
end
|
199
224
|
end
|
200
225
|
@observer_state = false
|
data/observer.gemspec
CHANGED
@@ -1,19 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
name = File.basename(__FILE__, ".gemspec")
|
4
|
+
version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
|
5
|
+
break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
|
6
|
+
/^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
|
7
|
+
end rescue nil
|
5
8
|
end
|
6
9
|
|
7
10
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
9
|
-
spec.version =
|
11
|
+
spec.name = name
|
12
|
+
spec.version = version
|
10
13
|
spec.authors = ["Yukihiro Matsumoto"]
|
11
14
|
spec.email = ["matz@ruby-lang.org"]
|
12
15
|
|
13
16
|
spec.summary = %q{Implementation of the Observer object-oriented design pattern.}
|
14
17
|
spec.description = spec.summary
|
15
18
|
spec.homepage = "https://github.com/ruby/observer"
|
16
|
-
spec.
|
19
|
+
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
17
20
|
|
18
21
|
spec.metadata["homepage_uri"] = spec.homepage
|
19
22
|
spec.metadata["source_code_uri"] = spec.homepage
|
@@ -21,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
21
24
|
# Specify which files should be added to the gem when it is released.
|
22
25
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
26
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
+
`git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
28
|
end
|
26
29
|
spec.bindir = "exe"
|
27
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: observer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yukihiro Matsumoto
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Implementation of the Observer object-oriented design pattern.
|
14
14
|
email:
|
@@ -17,6 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".github/dependabot.yml"
|
20
21
|
- ".github/workflows/test.yml"
|
21
22
|
- ".gitignore"
|
22
23
|
- Gemfile
|
@@ -26,15 +27,15 @@ files:
|
|
26
27
|
- bin/console
|
27
28
|
- bin/setup
|
28
29
|
- lib/observer.rb
|
29
|
-
- lib/observer/version.rb
|
30
30
|
- observer.gemspec
|
31
31
|
homepage: https://github.com/ruby/observer
|
32
32
|
licenses:
|
33
|
+
- Ruby
|
33
34
|
- BSD-2-Clause
|
34
35
|
metadata:
|
35
36
|
homepage_uri: https://github.com/ruby/observer
|
36
37
|
source_code_uri: https://github.com/ruby/observer
|
37
|
-
post_install_message:
|
38
|
+
post_install_message:
|
38
39
|
rdoc_options: []
|
39
40
|
require_paths:
|
40
41
|
- lib
|
@@ -49,8 +50,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
50
|
- !ruby/object:Gem::Version
|
50
51
|
version: '0'
|
51
52
|
requirements: []
|
52
|
-
rubygems_version: 3.
|
53
|
-
signing_key:
|
53
|
+
rubygems_version: 3.5.0.dev
|
54
|
+
signing_key:
|
54
55
|
specification_version: 4
|
55
56
|
summary: Implementation of the Observer object-oriented design pattern.
|
56
57
|
test_files: []
|
data/lib/observer/version.rb
DELETED