notepadqq_api 0.1.2 → 0.1.3

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: f52c91e83b7359a8c37b067f2862e161b0ce5ad2
4
- data.tar.gz: 0cc88eecc6f04dcf76ad5b81f6598c32638f0231
3
+ metadata.gz: e092a63573088f2db1e41de45d9ec066bd1121c5
4
+ data.tar.gz: b3fb8067ef1b9c5a9dccd9bdba4bf4c91ddcbf7e
5
5
  SHA512:
6
- metadata.gz: cefc711dcd60dd87108be54cc633f6c4b0b05eae2db24632bcbc9415b8f6b057cdee90d3e335ee68e452d77522e8d60c5190c47cf6a3601f509c195f20ec14c9
7
- data.tar.gz: ff1739bb8a424a39a2db387fa510f63a5f3c2ade62e39c3b33fbc5a0750044b6c71b3d4610d48db7acd5cc7461be50d0fd7bb8b51470e38d27a602a65d2b3588
6
+ metadata.gz: 8fb3048fecd2eff830a0fff6bc7f842d2d0d098a22f7cfccb805646dd1fe5f7f10b07fa3a59b27837ec53f47bad655ab1a202cf21b7f153d395d234f085a7821
7
+ data.tar.gz: 1cd22f92840a3a695063f6ad74247722e419693eb380e1b3af2e560386918434a2c5733c413606d1e982f01f626e8c4c8af0fe709ac9db84d4b1c5328efbc569
@@ -17,12 +17,14 @@ class NotepadqqApi
17
17
  end
18
18
 
19
19
  def ==(other)
20
- other.class <= Stub && id == other.id
20
+ other.class <= Stub &&
21
+ id == other.id &&
22
+ messageInterpreter == other.messageInterpreter
21
23
  end
22
24
 
23
25
  protected
24
26
 
25
- attr_reader :id
27
+ attr_reader :id, :messageInterpreter
26
28
 
27
29
  end
28
30
 
data/lib/notepadqq_api.rb CHANGED
@@ -29,6 +29,35 @@ class NotepadqqApi
29
29
 
30
30
  end
31
31
 
32
+ # Execute a block for every new window.
33
+ # This is preferable to the "newWindow" event of Notepadqq, because it could
34
+ # happen that the extension isn't ready soon enough to receive the
35
+ # "newWindow" event for the first Window. This method, instead, ensures that
36
+ # the passed block will be called once and only once for each current or
37
+ # future window.
38
+ def onWindowCreated(&callback)
39
+ capturedWindows = []
40
+
41
+ # Invoke the callback for every currently open window
42
+ notepadqq.windows.each do |window|
43
+ unless capturedWindows.include? window
44
+ capturedWindows.push window
45
+ callback.call(window)
46
+ end
47
+ end
48
+
49
+ # Each time a new window gets opened, invoke the callback.
50
+ # When Notepadqq is starting and initializing all the extensions,
51
+ # we might not be fast enough to receive this event: this is why
52
+ # we manually invoked the callback for every currently open window.
53
+ notepadqq.on(:newWindow) do |window|
54
+ unless capturedWindows.include? window
55
+ capturedWindows.push window
56
+ callback.call(window)
57
+ end
58
+ end
59
+ end
60
+
32
61
  # Returns an instance of Notepadqq
33
62
  def notepadqq
34
63
  @nqq ||= Stubs::Notepadqq.new(@messageInterpreter, NQQ_STUB_ID);
@@ -0,0 +1,52 @@
1
+ require 'test/unit'
2
+ require 'notepadqq_api/stubs'
3
+
4
+ class StubsTest < Test::Unit::TestCase
5
+
6
+ def test_comparison
7
+
8
+ # Different class
9
+
10
+ assert_equal NotepadqqApi::Stubs::Notepadqq.new(nil, 7),
11
+ NotepadqqApi::Stubs::Stub.new(nil, 7)
12
+
13
+ assert_equal NotepadqqApi::Stubs::Stub.new(nil, 7),
14
+ NotepadqqApi::Stubs::Notepadqq.new(nil, 7)
15
+
16
+ assert_equal NotepadqqApi::Stubs::Stub.new(nil, 7),
17
+ NotepadqqApi::Stubs::Stub.new(nil, 7)
18
+
19
+ assert_equal NotepadqqApi::Stubs::Notepadqq.new(nil, 7),
20
+ NotepadqqApi::Stubs::Notepadqq.new(nil, 7)
21
+
22
+ # Different id
23
+
24
+ assert_not_equal NotepadqqApi::Stubs::Notepadqq.new(nil, 1),
25
+ NotepadqqApi::Stubs::Stub.new(nil, 2)
26
+
27
+ assert_not_equal NotepadqqApi::Stubs::Stub.new(nil, 1),
28
+ NotepadqqApi::Stubs::Notepadqq.new(nil, 2)
29
+
30
+ assert_not_equal NotepadqqApi::Stubs::Stub.new(nil, 1),
31
+ NotepadqqApi::Stubs::Stub.new(nil, 2)
32
+
33
+ assert_not_equal NotepadqqApi::Stubs::Notepadqq.new(nil, 1),
34
+ NotepadqqApi::Stubs::Notepadqq.new(nil, 2)
35
+
36
+ # Different channel
37
+
38
+ assert_not_equal NotepadqqApi::Stubs::Notepadqq.new("test", 7),
39
+ NotepadqqApi::Stubs::Stub.new(nil, 7)
40
+
41
+ assert_not_equal NotepadqqApi::Stubs::Stub.new("test", 7),
42
+ NotepadqqApi::Stubs::Notepadqq.new(nil, 7)
43
+
44
+ assert_not_equal NotepadqqApi::Stubs::Stub.new("test", 7),
45
+ NotepadqqApi::Stubs::Stub.new(nil, 7)
46
+
47
+ assert_not_equal NotepadqqApi::Stubs::Notepadqq.new("test", 7),
48
+ NotepadqqApi::Stubs::Notepadqq.new(nil, 7)
49
+
50
+ end
51
+
52
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notepadqq_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniele Di Sarli
@@ -49,7 +49,8 @@ files:
49
49
  - lib/notepadqq_api/message_interpreter.rb
50
50
  - lib/notepadqq_api/stubs.rb
51
51
  - test/test_message_interpreter.rb
52
- homepage: http://rubygems.org/gems/hola
52
+ - test/test_stubs.rb
53
+ homepage: https://rubygems.org/gems/notepadqq_api
53
54
  licenses:
54
55
  - MIT
55
56
  metadata: {}