turbo_test_events 0.1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 763670827941a86571a9b52e08c0a18ce702362f74b42f6b50844d1efaf5e43c
4
+ data.tar.gz: 1a3bbb82912992521932bdfac2a53996d28a4647ab875a48492aff533095c127
5
+ SHA512:
6
+ metadata.gz: 0cc0a45368152019873f035c27ffec48cd8d1ca84607dc28ee5fd6a94c4fdb28803b79d21a5970e16b236e72c907b711241f3d8d0f0adc5cf69138d5434b32c5
7
+ data.tar.gz: cf2250239f2963581b395edd43a74e1b1fb82c685c067ff1ebea65e7aae4c1e53d39e35d74278aeab156d8f8b704c877a6381ce804b9e31f6fce0ccd537a324f
@@ -0,0 +1,42 @@
1
+ name: Tests
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ name: >-
8
+ Ruby: ${{ matrix.ruby }}
9
+
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ ruby: [ '2.4', '2.5', '2.6', '2.7' ]
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+
18
+ - name: Set up Ruby
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby }}
22
+
23
+ - name: Install dependencies
24
+ env:
25
+ BUNDLE_GEMFILE: GemfileCI
26
+ run: |
27
+ bundle config path vendor/bundle
28
+ bundle install --binstubs --jobs 4 --retry 3
29
+
30
+ - name: Run tests
31
+ env:
32
+ BUNDLE_GEMFILE: GemfileCI
33
+ run: |
34
+ bundle exec rake
35
+
36
+ - name: Coveralls
37
+ if: ${{ matrix.ruby == '2.7' }}
38
+ env:
39
+ BUNDLE_GEMFILE: GemfileCI
40
+ COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
41
+ run: |
42
+ bundle exec rake coveralls:push
data/.gitignore ADDED
@@ -0,0 +1,66 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ *.gem
11
+ *.rbc
12
+ /.config
13
+ /coverage/
14
+ /InstalledFiles
15
+ /pkg/
16
+ /spec/reports/
17
+ /spec/examples.txt
18
+ /test/tmp/
19
+ /test/version_tmp/
20
+ /tmp/
21
+
22
+ # Used by dotenv library to load environment variables.
23
+ # .env
24
+
25
+ ## Specific to RubyMotion:
26
+ .dat*
27
+ .repl_history
28
+ build/
29
+ *.bridgesupport
30
+ build-iPhoneOS/
31
+ build-iPhoneSimulator/
32
+
33
+ .DS_Store
34
+
35
+ ## Specific to RubyMotion (use of CocoaPods):
36
+ #
37
+ # We recommend against adding the Pods directory to your .gitignore. However
38
+ # you should judge for yourself, the pros and cons are mentioned at:
39
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
40
+ #
41
+ # vendor/Pods/
42
+
43
+ ## Documentation cache and generated files:
44
+ /.yardoc/
45
+ /_yardoc/
46
+ /doc/
47
+ /rdoc/
48
+
49
+ ## Environment normalization:
50
+ /.bundle/
51
+ /vendor/bundle
52
+ /lib/bundler/man/
53
+
54
+ # for a library or gem, you might want to ignore these files since the code is
55
+ # intended to run in multiple environments; otherwise, check them in:
56
+ # Gemfile.lock
57
+ # .ruby-version
58
+ # .ruby-gemset
59
+
60
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
61
+ .rvmrc
62
+
63
+ #SAM artifacts
64
+ /packaged.yaml
65
+
66
+ .byebug_history
data/.rubocop.yml ADDED
@@ -0,0 +1,41 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ DisplayStyleGuide: true
4
+ ExtraDetails: true
5
+ NewCops: enable
6
+ TargetRubyVersion: 2.7
7
+ Exclude:
8
+ - Gemfile
9
+ - "**/*.gemfile"
10
+ - bin/*
11
+ - "*.gemspec"
12
+
13
+ Layout/LineLength:
14
+ Enabled: true
15
+ AutoCorrect: false
16
+ Max: 100
17
+
18
+ Metrics/BlockLength:
19
+ Exclude:
20
+ - test/**/*_test.rb
21
+
22
+ Metrics/ClassLength:
23
+ Exclude:
24
+ - test/**/*
25
+ - lib/tasks/*
26
+
27
+ Metrics/MethodLength:
28
+ Max: 10
29
+
30
+ Style/ClassAndModuleChildren:
31
+ Exclude:
32
+ - test/**/*
33
+
34
+ Style/Documentation:
35
+ Enabled: false
36
+
37
+ Style/StringLiterals:
38
+ Enabled: true
39
+ EnforcedStyle: double_quotes
40
+ ConsistentQuotesInMultiline: true
41
+
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at marcessindi@icloud.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in turbo_test_events.gemspec
4
+ gemspec
5
+
6
+ eval_gemfile(File.expand_path("Gemfile.common", __dir__))
7
+
8
+ gem "simplecov", "~> 0.18.5"
data/Gemfile.common ADDED
@@ -0,0 +1,3 @@
1
+ gem "rubocop"
2
+ gem "byebug"
3
+ gem "mocha"
data/Gemfile.lock ADDED
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ turbo_test_events (0.1.0.3)
5
+ concurrent-ruby (~> 1.1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.1)
11
+ byebug (11.1.3)
12
+ concurrent-ruby (1.1.7)
13
+ docile (1.3.2)
14
+ minitest (5.14.1)
15
+ mocha (1.11.2)
16
+ parallel (1.19.2)
17
+ parser (2.7.1.4)
18
+ ast (~> 2.4.1)
19
+ rainbow (3.0.0)
20
+ rake (13.0.1)
21
+ regexp_parser (1.7.1)
22
+ rexml (3.2.4)
23
+ rubocop (0.89.0)
24
+ parallel (~> 1.10)
25
+ parser (>= 2.7.1.1)
26
+ rainbow (>= 2.2.2, < 4.0)
27
+ regexp_parser (>= 1.7)
28
+ rexml
29
+ rubocop-ast (>= 0.1.0, < 1.0)
30
+ ruby-progressbar (~> 1.7)
31
+ unicode-display_width (>= 1.4.0, < 2.0)
32
+ rubocop-ast (0.3.0)
33
+ parser (>= 2.7.1.4)
34
+ ruby-progressbar (1.10.1)
35
+ simplecov (0.18.5)
36
+ docile (~> 1.1)
37
+ simplecov-html (~> 0.11)
38
+ simplecov-html (0.12.2)
39
+ unicode-display_width (1.7.0)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ byebug
46
+ minitest (~> 5.14.1)
47
+ mocha
48
+ rake (~> 13.0)
49
+ rubocop
50
+ simplecov (~> 0.18.5)
51
+ turbo_test_events!
52
+
53
+ BUNDLED WITH
54
+ 2.1.4
data/GemfileCI ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in turbo_test_ruby_refinements.gemspec
4
+ gemspec
5
+
6
+ eval_gemfile(File.expand_path("Gemfile.common", __dir__))
7
+
8
+ gem "simplecov", "~> 0.16.1"
9
+ gem "coveralls"
data/GemfileCI.lock ADDED
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ turbo_test_events (0.1.0.3)
5
+ concurrent-ruby (~> 1.1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.1)
11
+ byebug (11.1.3)
12
+ concurrent-ruby (1.1.7)
13
+ coveralls (0.8.23)
14
+ json (>= 1.8, < 3)
15
+ simplecov (~> 0.16.1)
16
+ term-ansicolor (~> 1.3)
17
+ thor (>= 0.19.4, < 2.0)
18
+ tins (~> 1.6)
19
+ docile (1.3.2)
20
+ json (2.3.1)
21
+ minitest (5.14.1)
22
+ mocha (1.11.2)
23
+ parallel (1.19.2)
24
+ parser (2.7.1.4)
25
+ ast (~> 2.4.1)
26
+ rainbow (3.0.0)
27
+ rake (13.0.1)
28
+ regexp_parser (1.7.1)
29
+ rexml (3.2.4)
30
+ rubocop (0.89.0)
31
+ parallel (~> 1.10)
32
+ parser (>= 2.7.1.1)
33
+ rainbow (>= 2.2.2, < 4.0)
34
+ regexp_parser (>= 1.7)
35
+ rexml
36
+ rubocop-ast (>= 0.1.0, < 1.0)
37
+ ruby-progressbar (~> 1.7)
38
+ unicode-display_width (>= 1.4.0, < 2.0)
39
+ rubocop-ast (0.3.0)
40
+ parser (>= 2.7.1.4)
41
+ ruby-progressbar (1.10.1)
42
+ simplecov (0.16.1)
43
+ docile (~> 1.1)
44
+ json (>= 1.8, < 3)
45
+ simplecov-html (~> 0.10.0)
46
+ simplecov-html (0.10.2)
47
+ sync (0.5.0)
48
+ term-ansicolor (1.7.1)
49
+ tins (~> 1.0)
50
+ thor (1.0.1)
51
+ tins (1.25.0)
52
+ sync
53
+ unicode-display_width (1.7.0)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ byebug
60
+ coveralls
61
+ minitest (~> 5.14.1)
62
+ mocha
63
+ rake (~> 13.0)
64
+ rubocop
65
+ simplecov (~> 0.16.1)
66
+ turbo_test_events!
67
+
68
+ BUNDLED WITH
69
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Marcos Essindi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,44 @@
1
+ # Adapted from https://github.com/zspencer/make-many-rubies/blob/master/Makefile
2
+
3
+ # Allows running (and re-running) of tests against several ruby versions,
4
+ # assuming you use rbenv instead of rvm.
5
+
6
+ # Uses pattern rules (task-$:) and automatic variables ($*).
7
+ # Pattern rules: http://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_10.html#SEC98
8
+ # Automatic variables: http://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_10.html#SEC101
9
+
10
+ # Rbenv-friendly version identifiers for supported Rubys
11
+ 24_version = 2.4.10
12
+ 25_version = 2.5.8
13
+ 26_version = 2.6.6
14
+ 27_version = 2.7.1
15
+
16
+ # The ruby version for use in a given rule.
17
+ # Requires a matched pattern rule and a supported ruby version.
18
+ #
19
+ # Given a pattern rule defined as "install-ruby-%"
20
+ # When the rule is ran as "install-ruby-193"
21
+ # Then the inner addsuffix call evaluates to "193_version"
22
+ # And given_ruby_version becomes "1.9.3-p551"
23
+ given_ruby_version = $($(addsuffix _version, $*))
24
+
25
+ # Instruct rbenv on which Ruby version to use when running a command.
26
+ # Requires a pattern rule and a supported ruby version.
27
+ #
28
+ # Given a pattern rule defined as "test-%"
29
+ # When the rule is ran as "test-187"
30
+ # Then with_given_ruby becomes "RBENV_VERSION=1.8.7-p375"
31
+ with_given_ruby = RBENV_VERSION=$(given_ruby_version)
32
+
33
+
34
+ # Runs tests for all supported ruby versions.
35
+ test: test-24 test-25 test-26 test-27
36
+ test_24: test-24
37
+ test_25: test-25
38
+ test_26: test-26
39
+ test_27: test-27
40
+
41
+ # Runs tests against a specific ruby version
42
+ test-%:
43
+ $(with_given_ruby) bundle install
44
+ $(with_given_ruby) bundle exec rake
data/README.md ADDED
@@ -0,0 +1,102 @@
1
+ ![Tests](https://github.com/dunkelbraun/turbo_test_events/workflows/Tests/badge.svg?branch=main)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/cdac75678956e034e298/maintainability)](https://codeclimate.com/github/dunkelbraun/turbo_test_events/maintainability)
3
+ [![Coverage Status](https://coveralls.io/repos/github/dunkelbraun/turbo_test_events/badge.svg?branch=main)](https://coveralls.io/github/dunkelbraun/turbo_test_events?branch=main)
4
+
5
+ # TurboTestEvents
6
+
7
+ TurboTestEvents is a minimal event framework for Ruby based on Observable.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'turbo_test_events'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install turbo_test_events
24
+
25
+ ## Usage
26
+
27
+ ### Publish an event
28
+
29
+ ```ruby
30
+ payload = {created_at: Time.now}
31
+ TurboTest::EventRegistry["event_1"].publish(payload)
32
+ ```
33
+
34
+ ### Subscribe to an event
35
+
36
+ Implement subscriber class with the update callback method:
37
+
38
+ ```ruby
39
+ class Subscriber
40
+ def update(event_payload)
41
+ # Process event
42
+ end
43
+ end
44
+ ```
45
+
46
+ Create a subscriber and subscribe it to the event:
47
+
48
+ ```ruby
49
+ subscriber = Subscriber.new
50
+ TurboTest::EventRegistry["event_1"].subscribe(subscriber)
51
+ ```
52
+
53
+ You can have a custom update callback method with:
54
+
55
+ ```ruby
56
+ TurboTest::EventRegistry["event_1"].subscribe(subscriber, :method_name)
57
+
58
+ class CustomSubscriber
59
+ def method_name(event_payload)
60
+ # Process event
61
+ end
62
+ end
63
+ ```
64
+
65
+ ### Unsubscribe from an event
66
+
67
+ ```ruby
68
+ TurboTest::EventRegistry["event_1"].unsubscribe(subscriber)
69
+ ```
70
+
71
+ ### Unsubscribe all subscribers from an event
72
+
73
+ ```ruby
74
+ TurboTest::EventRegistry["event_1"].unsubscribe_all
75
+ ```
76
+
77
+
78
+ ## Multithreading Notes
79
+ - You can publish events from different threads.
80
+ - You can add and remove subscribers in different threads.
81
+ - There are no guarantees about the thread that will execute the subscriber callback.
82
+ - You should synchronize any internal data of the subscriber when modifying it.
83
+ - You should synchronize any data of the event payload when modifying it.
84
+
85
+ ## Development
86
+
87
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
88
+
89
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
90
+
91
+ ## Contributing
92
+
93
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dunkelbraun/turbo_test_events. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/dunkelbraun/turbo_test_events/blob/master/CODE_OF_CONDUCT.md).
94
+
95
+
96
+ ## License
97
+
98
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
99
+
100
+ ## Code of Conduct
101
+
102
+ Everyone interacting in the TurboTestEvents project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dunkelbraun/turbo_test_events/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ ENV["TESTOPTS"] = "#{ENV['TESTOPTS']} --verbose"
7
+
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.libs << "test"
10
+ t.libs << "lib"
11
+ t.test_files = FileList["test/**/*_test.rb"]
12
+ end
13
+
14
+ task default: :test
15
+
16
+ if ENV["CI"]
17
+ require "coveralls/rake/task"
18
+ Coveralls::RakeTask.new
19
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "turbo_test_events"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "observer"
4
+ require "concurrent"
5
+
6
+ module TurboTest
7
+ class Event
8
+ include Observable
9
+
10
+ def initialize
11
+ @observer_peers = Concurrent::Map.new
12
+ end
13
+
14
+ def publish(*arg)
15
+ changed
16
+ notify_observers(*arg)
17
+ end
18
+
19
+ alias subscribe add_observer
20
+ undef :add_observer
21
+
22
+ alias unsubscribe delete_observer
23
+ undef :delete_observer
24
+
25
+ alias unsubscribe_all delete_observers
26
+ undef :delete_observers
27
+ end
28
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "singleton"
4
+ require "forwardable"
5
+ require "concurrent"
6
+
7
+ module TurboTest
8
+ class EventRegistry
9
+ include Singleton
10
+
11
+ @instance = nil
12
+
13
+ def initialize
14
+ @events = Concurrent::Map.new
15
+ end
16
+
17
+ def register(event_name)
18
+ @events[event_name] ||= Event.new
19
+ end
20
+ alias [] register
21
+
22
+ class << self
23
+ extend Forwardable
24
+ def_delegators :instance, :register, :[]
25
+
26
+ private
27
+
28
+ # :nocov:
29
+ remove_method :instance if RUBY_VERSION < "2.7"
30
+ # :nocov:
31
+
32
+ def instance
33
+ @instance || Mutex.new.synchronize { @instance ||= new }
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TurboTest
4
+ module Events
5
+ VERSION = "0.1.0.3"
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "turbo_test_events/version"
4
+ require_relative "turbo_test_events/event"
5
+ require_relative "turbo_test_events/event_registry"
@@ -0,0 +1,30 @@
1
+ require_relative 'lib/turbo_test_events/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "turbo_test_events"
5
+ spec.version = TurboTest::Events::VERSION
6
+ spec.authors = ["Marcos Essindi"]
7
+ spec.email = ["marcessindi@icloud.com"]
8
+
9
+ spec.summary = "Minimal event framework based on Observable."
10
+ spec.homepage = "https://github.com/dunkelbraun/turbo_test_events"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "https://github.com/dunkelbraun/turbo_test_events"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "rake", "~> 13.0"
27
+ spec.add_development_dependency "minitest", "~> 5.14.1"
28
+
29
+ spec.add_dependency "concurrent-ruby", "~> 1.1.0"
30
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: turbo_test_events
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Marcos Essindi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 5.14.1
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 5.14.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: concurrent-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.1.0
55
+ description:
56
+ email:
57
+ - marcessindi@icloud.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".github/workflows/tests.yml"
63
+ - ".gitignore"
64
+ - ".rubocop.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - Gemfile.common
68
+ - Gemfile.lock
69
+ - GemfileCI
70
+ - GemfileCI.lock
71
+ - LICENSE.txt
72
+ - Makefile
73
+ - README.md
74
+ - Rakefile
75
+ - bin/console
76
+ - bin/setup
77
+ - lib/turbo_test_events.rb
78
+ - lib/turbo_test_events/event.rb
79
+ - lib/turbo_test_events/event_registry.rb
80
+ - lib/turbo_test_events/version.rb
81
+ - turbo_test_events.gemspec
82
+ homepage: https://github.com/dunkelbraun/turbo_test_events
83
+ licenses:
84
+ - MIT
85
+ metadata:
86
+ homepage_uri: https://github.com/dunkelbraun/turbo_test_events
87
+ source_code_uri: https://github.com/dunkelbraun/turbo_test_events
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.4.0
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.0.3
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Minimal event framework based on Observable.
107
+ test_files: []