Mange-git-remote-monitor 0.1.1 → 0.1.2

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.
@@ -0,0 +1,46 @@
1
+ # The MIT License
2
+ # Copyright © 2009 Magnus Bergmark
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+
22
+ require File.dirname(__FILE__) + '/../spec_helper'
23
+
24
+ describe GitRemoteMonitor::Notifier do
25
+
26
+ it "should get the preferred notifier" do
27
+ notifier = mock("Notifier plugin")
28
+ notifier.should_receive(:new)
29
+ GitRemoteMonitor::Notifiers.should_receive(:preferred_notifier).and_return(notifier)
30
+ GitRemoteMonitor::Notifier.new
31
+ end
32
+
33
+ it "should generate a proper status object and send it to the notifier plugin when being told to" do
34
+ monitor = mock("Monitor")
35
+ status = mock("Status")
36
+ notifier = mock("Notifier plugin")
37
+ notifier_class = mock("Notifier plugin class", :new => notifier)
38
+ GitRemoteMonitor::Notifiers.stub!(:preferred_notifier => notifier_class)
39
+
40
+ notifier.should_receive(:send_notification!).with(status)
41
+ GitRemoteMonitor::Status.should_receive(:new).with(monitor, "foo", 1, 42).and_return(status)
42
+
43
+ GitRemoteMonitor::Notifier.new.notify_commits(monitor, "foo", 1, 42)
44
+ end
45
+
46
+ end
@@ -0,0 +1,49 @@
1
+ # The MIT License
2
+ # Copyright © 2009 Magnus Bergmark
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+
22
+ require File.dirname(__FILE__) + '/../../spec_helper'
23
+
24
+ describe "Base plugin" do
25
+ it "should raise error when asked if it's available" do
26
+ lambda {
27
+ GitRemoteMonitor::Notifiers::Base.available?
28
+ }.should raise_error
29
+ end
30
+
31
+ it "should raise error when its being initialized" do
32
+ lambda {
33
+ GitRemoteMonitor::Notifiers::Base.new
34
+ }.should raise_error
35
+ end
36
+
37
+ describe "subclass without notification implementation" do
38
+ before(:all) do
39
+ class SubClass < GitRemoteMonitor::Notifiers::Base; def initialize; end; end;
40
+ @instance = SubClass.new
41
+ end
42
+
43
+ it "should raise error when asked to notify" do
44
+ lambda {
45
+ @instance.send_notification!(mock("Status"))
46
+ }.should raise_error
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,113 @@
1
+ # The MIT License
2
+ # Copyright © 2009 Magnus Bergmark
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+
22
+ require File.dirname(__FILE__) + '/../../spec_helper'
23
+
24
+ # Pre-define Meow for systems without it installed
25
+ class ::Meow; end
26
+
27
+ describe "Meow notifier plugin" do
28
+ it "should be available when the gem is installed and loadable" do
29
+ GitRemoteMonitor::Notifiers::Meow.should_receive(:require).with('meow').and_return(true)
30
+ GitRemoteMonitor::Notifiers::Meow.available?.should be_true
31
+ end
32
+
33
+ it "should be available when the gem is installed and loadable" do
34
+ GitRemoteMonitor::Notifiers::Meow.should_receive(:require).with('meow').and_raise(LoadError)
35
+ GitRemoteMonitor::Notifiers::Meow.available?.should be_false
36
+ end
37
+
38
+ describe "instance" do
39
+ before(:each) do
40
+ meow_instance = mock("Meow gem")
41
+ Meow.should_receive(:new).with("git-remote-monitor").and_return(meow_instance)
42
+
43
+ @instance = GitRemoteMonitor::Notifiers::Meow.new
44
+ @instance.instance_eval { @meow = meow_instance }
45
+
46
+ @meow = meow_instance
47
+ end
48
+
49
+ it "should send notifications correctly when a message is generated" do
50
+ status = mock("Status object")
51
+ @instance.should_receive(:get_message).with(status).and_return("A message")
52
+ @instance.should_receive(:notification_title).with(status).and_return("Title")
53
+ @instance.should_receive(:notification_icon).with(status).and_return("icon")
54
+ @instance.should_receive(:notification_type).with(status).and_return("type")
55
+
56
+ @meow.should_receive(:notify).with("Title", "A message", :icon => "icon", :note_type => "type")
57
+ @instance.send_notification!(status)
58
+ end
59
+
60
+ it "should not send notifications when a message isn't generated" do
61
+ status = mock("Status object")
62
+ @instance.should_receive(:get_message).with(status).and_return(nil)
63
+ @meow.should_not_receive(:notify)
64
+
65
+ @instance.send_notification!(status)
66
+ end
67
+
68
+ it "should use a correct message type" do
69
+ status = mock("Status object", :type => :foobar)
70
+ @instance.send(:notification_type, status).should == "Foobar"
71
+ end
72
+
73
+ it "should format message title" do
74
+ status = mock("Status object", :name => 'repo', :branch_name => 'master')
75
+ @instance.send(:notification_title, status).should == "repo (master)"
76
+ end
77
+
78
+ it "should use correct image path" do
79
+ status = mock("Status object")
80
+ GitRemoteMonitor.stub!(:root => '/root')
81
+ @instance.send(:notification_icon, status).should == "/root/images/git-logo.png"
82
+ end
83
+
84
+ describe "generating message body" do
85
+ before(:each) do
86
+ @status = mock("Status object", :remote_commits => 12, :local_commits => 1)
87
+ end
88
+
89
+ it "should raise error when the status type is unknown" do
90
+ @status.stub!(:type => :unknown)
91
+ lambda {
92
+ @instance.send(:get_message, @status)
93
+ }.should raise_error
94
+ end
95
+
96
+ it "should work with diverged status" do
97
+ @status.stub!(:type => :diverged)
98
+ @instance.send(:get_message, @status).should == "Diverged! Remote has 12 new commit(s), and you have 1 commit(s) to push."
99
+ end
100
+
101
+ it "should work with remote changes" do
102
+ @status.stub!(:type => :remote)
103
+ @instance.send(:get_message, @status).should == "Remote got updated! Now 12 commit(s) in front of you."
104
+ end
105
+
106
+ it "should not return anything if the changes are local" do
107
+ @status.stub!(:type => :local)
108
+ @instance.send(:get_message, @status).should be_nil
109
+ end
110
+ end
111
+
112
+ end
113
+ end
@@ -0,0 +1,54 @@
1
+ # The MIT License
2
+ # Copyright © 2009 Magnus Bergmark
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+
22
+ require File.dirname(__FILE__) + '/../spec_helper'
23
+
24
+ describe GitRemoteMonitor::Notifiers do
25
+
26
+ it "should have a list of plugins" do
27
+ GitRemoteMonitor::Notifiers.notifier_plugins.should be_kind_of(Array)
28
+ end
29
+
30
+ describe "with a list of plugins" do
31
+ before(:each) do
32
+ @plugins = [
33
+ mock("Unavailable plugin 1", :available? => false),
34
+ mock("Available plugin 1", :available? => true),
35
+ mock("Available plugin 2", :available? => true),
36
+ mock("Unavailable plugin 2", :available? => false)
37
+ ]
38
+ @first_available = @plugins[1]
39
+ @second_available = @plugins[2]
40
+ GitRemoteMonitor::Notifiers.stub!(:notifier_plugins => @plugins)
41
+ end
42
+
43
+ it "should build a list of available plugins" do
44
+ GitRemoteMonitor::Notifiers.available_notifiers.should have(2).items
45
+ GitRemoteMonitor::Notifiers.available_notifiers.first.should == @first_available
46
+ end
47
+
48
+ it "should select a preferred plugin by looking at the first available one" do
49
+ @second_available.should_not_receive(:available?)
50
+ GitRemoteMonitor::Notifiers.preferred_notifier.should == @first_available
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,57 @@
1
+ # The MIT License
2
+ # Copyright © 2009 Magnus Bergmark
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+
22
+ require File.dirname(__FILE__) + '/../spec_helper'
23
+
24
+ describe GitRemoteMonitor::Status do
25
+ describe "instance" do
26
+ before(:each) do
27
+ @monitor = mock("Monitor", :name => "Name", :directory => "/home")
28
+ @instance = GitRemoteMonitor::Status.new(@monitor, "branch", 0, 2)
29
+ end
30
+
31
+ it "should get name through monitor" do
32
+ @instance.name.should == "Name"
33
+ end
34
+
35
+ it "should get directory through monitor" do
36
+ @instance.directory.should == "/home"
37
+ end
38
+
39
+ describe "type detect" do
40
+ it "should recognize type local" do
41
+ @instance.stub!(:remote_commits => 0, :local_commits => 2)
42
+ @instance.type.should == :local
43
+ end
44
+
45
+ it "should recognize type remote" do
46
+ @instance.stub!(:remote_commits => 1, :local_commits => 0)
47
+ @instance.type.should == :remote
48
+ end
49
+
50
+ it "should recognize type diverged" do
51
+ @instance.stub!(:remote_commits => 5, :local_commits => 2)
52
+ @instance.type.should == :diverged
53
+ end
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,37 @@
1
+ # The MIT License
2
+ # Copyright © 2009 Magnus Bergmark
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+
22
+ require 'spec_helper'
23
+
24
+ describe GitRemoteMonitor do
25
+
26
+ describe "root constant" do
27
+ it "should point to an actual directory" do
28
+ File.directory?(GitRemoteMonitor.root).should be_true
29
+ end
30
+
31
+ it "should point to the gem root" do
32
+ full_path = File.join(GitRemoteMonitor.root, 'lib', 'git_remote_monitor.rb')
33
+ File.exist?(full_path).should be_true
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --format progress
3
+ --reverse
@@ -1,9 +1,33 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'spec/rails'
1
+ # The MIT License
2
+ # Copyright © 2009 Magnus Bergmark
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
4
21
 
5
22
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
- require 'git_remote_monitor'
23
+
24
+ begin
25
+ require 'git_remote_monitor'
26
+ rescue LoadError # This happens when we are called through programs such as autospec
27
+ lib_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
28
+ $LOAD_PATH.unshift(lib_path)
29
+ require 'git_remote_monitor'
30
+ end
7
31
 
8
32
  Spec::Runner.configure do |config|
9
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Mange-git-remote-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Bergmark
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-03 00:00:00 -08:00
12
+ date: 2009-04-20 00:00:00 -07:00
13
13
  default_executable: git-remote-monitor
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: meow
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -30,7 +31,7 @@ extensions: []
30
31
  extra_rdoc_files: []
31
32
 
32
33
  files:
33
- - HISTORY
34
+ - HISTORY.markdown
34
35
  - LICENSE
35
36
  - Rakefile
36
37
  - README
@@ -41,9 +42,23 @@ files:
41
42
  - lib/git_remote_monitor/git_wrapper.rb
42
43
  - lib/git_remote_monitor/monitor.rb
43
44
  - lib/git_remote_monitor/notifier.rb
45
+ - lib/git_remote_monitor/notifiers
46
+ - lib/git_remote_monitor/notifiers/base.rb
47
+ - lib/git_remote_monitor/notifiers/meow.rb
48
+ - lib/git_remote_monitor/notifiers.rb
49
+ - lib/git_remote_monitor/status.rb
44
50
  - lib/git_remote_monitor.rb
45
51
  - spec/git_remote_monitor
46
52
  - spec/git_remote_monitor/git_wrapper_spec.rb
53
+ - spec/git_remote_monitor/monitor_spec.rb
54
+ - spec/git_remote_monitor/notifier_spec.rb
55
+ - spec/git_remote_monitor/notifiers
56
+ - spec/git_remote_monitor/notifiers/base_spec.rb
57
+ - spec/git_remote_monitor/notifiers/meow_spec.rb
58
+ - spec/git_remote_monitor/notifiers_spec.rb
59
+ - spec/git_remote_monitor/status_spec.rb
60
+ - spec/git_remote_monitor_spec.rb
61
+ - spec/spec.opts
47
62
  - spec/spec_helper.rb
48
63
  has_rdoc: true
49
64
  homepage: http://github.com/Mange/git-remote-monitor