informator 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 88050d195612b6c522dd73ce402377bb0eef1205
4
- data.tar.gz: ad5e5fad66364bcbde46b4db64a827e6348d1419
3
+ metadata.gz: 341da250ea78c55d21c12821a7cc8e91af9ed07b
4
+ data.tar.gz: dfa16302f4547fe123631d9dae3737fb960ca448
5
5
  SHA512:
6
- metadata.gz: 2d14dc46cf3956d2605b9b5ca01e47596c42985c14aa2c98f28d19ef75af5109efe1dc2cd47bbec0ed2ea9113da7b96b458327eb44ea9940c2d84b8765a4d4ab
7
- data.tar.gz: 9949843cdfd102984541ccd34e3cf7238e63d499279fd23f0c452adce57942d512ab8c4be8f6109a860603ad2917da6acdffecb10aecbf2d2365d6d78cc12aeb
6
+ metadata.gz: 21f6b276db2537b24a2012be0b9b03fc6522e760c80daf8aaef7cdf5f4e335677588712df378b33f1b6cc009e183be84a8f500c44651215776fd49d9ad55c25e
7
+ data.tar.gz: 1d19b1c9e78ec72579d1b931906302d2a5bb5f0a2e14a8b845f5f71b814933ee11c514c891b5858e7672b0bf47ee213c4e9e53e5d377d14556b7f43c50498021
data/informator.gemspec CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.required_ruby_version = "~> 2.1"
20
20
 
21
+ gem.add_runtime_dependency "equalizer", "~> 0.0"
22
+
21
23
  gem.add_development_dependency "hexx-rspec", "~> 0.4"
22
24
 
23
25
  end # Gem::Specification
data/lib/informator.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require "equalizer"
4
+
3
5
  require_relative "informator/event"
4
6
  require_relative "informator/subscriber"
5
7
  require_relative "informator/reporter"
@@ -10,14 +10,14 @@ module Informator
10
10
  # between various objects into unified format.
11
11
  #
12
12
  # @example
13
- # event = Event.new :success, "bingo!", foo: :bar
13
+ # event = Event[:success, "bingo!", foo: :bar]
14
14
  # # => #<Event @type=:success, @messages=["bingo!"], @data={ :foo => :bar }>
15
15
  # event.frozen?
16
16
  # # => true
17
17
  #
18
18
  class Event
19
19
 
20
- include Comparable
20
+ include Equalizer.new(:type, :data)
21
21
 
22
22
  # @!attribute [r] type
23
23
  #
@@ -38,7 +38,7 @@ module Informator
38
38
  attr_reader :messages
39
39
 
40
40
  # @!scope class
41
- # @!method new(type, messages, data)
41
+ # @!method [](type, messages, data)
42
42
  # Builds the event
43
43
  #
44
44
  # @param [#to_sym] type
@@ -46,6 +46,9 @@ module Informator
46
46
  # @param [Hash] data
47
47
  #
48
48
  # @return [Informator::Event]
49
+ def self.[](*args)
50
+ new(*args)
51
+ end
49
52
 
50
53
  # @private
51
54
  def initialize(type, *messages, **data)
@@ -55,26 +58,6 @@ module Informator
55
58
  freeze
56
59
  end
57
60
 
58
- # Compares the event to another one by their types and data
59
- #
60
- # @param [Object] other
61
- #
62
- # @return [Boolean]
63
- #
64
- def ==(other)
65
- other.is_a?(self.class) && other.value.eql?(value)
66
- end
67
-
68
- protected
69
-
70
- # Returns value to compare events by
71
- #
72
- # @return [Array]
73
- #
74
- def value
75
- [type, data]
76
- end
77
-
78
61
  end # class Event
79
62
 
80
63
  end # module Informator
@@ -21,7 +21,7 @@ module Informator
21
21
  #
22
22
  class Subscriber
23
23
 
24
- include Comparable
24
+ include Equalizer.new(:object, :callback)
25
25
 
26
26
  # @!attribute [r] object
27
27
  #
@@ -63,26 +63,6 @@ module Informator
63
63
  event
64
64
  end
65
65
 
66
- # Compares the subscriber to another one by their objects and callbacks
67
- #
68
- # @param [Object] other
69
- #
70
- # @return [Boolean]
71
- #
72
- def ==(other)
73
- other.instance_of?(self.class) ? other.value.eql?(value) : false
74
- end
75
-
76
- protected
77
-
78
- # Returns value to compare subscribers by
79
- #
80
- # @return [Array]
81
- #
82
- def value
83
- [object, callback]
84
- end
85
-
86
66
  end # class Subscriber
87
67
 
88
68
  end # module Informator
@@ -4,6 +4,6 @@ module Informator
4
4
 
5
5
  # The semantic version of the module.
6
6
  # @see http://semver.org/ Semantic versioning 2.0
7
- VERSION = "0.0.1".freeze
7
+ VERSION = "0.0.2".freeze
8
8
 
9
9
  end # module Informator
@@ -8,11 +8,21 @@ describe Informator::Event do
8
8
 
9
9
  describe ".new" do
10
10
 
11
- it { is_expected.to be_kind_of Comparable }
12
11
  it { is_expected.to be_frozen }
13
12
 
14
13
  end # describe .new
15
14
 
15
+ describe ".[]" do
16
+
17
+ before { allow(described_class).to receive(:new) }
18
+
19
+ it "builds the event" do
20
+ expect(described_class).to receive(:new).with(:foo, :bar, :baz)
21
+ described_class[:foo, :bar, :baz]
22
+ end
23
+
24
+ end # describe .new
25
+
16
26
  describe "#type" do
17
27
 
18
28
  subject { event.type }
@@ -10,7 +10,6 @@ describe Informator::Subscriber do
10
10
 
11
11
  describe ".new" do
12
12
 
13
- it { is_expected.to be_kind_of Comparable }
14
13
  it { is_expected.to be_frozen }
15
14
 
16
15
  end # describe .new
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: informator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-23 00:00:00.000000000 Z
11
+ date: 2015-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: equalizer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: hexx-rspec
15
29
  requirement: !ruby/object:Gem::Requirement