orangewire_sender 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +63 -0
- data/VERSION +1 -0
- data/lib/orangewire/errors.rb +5 -0
- data/lib/orangewire_sender.rb +44 -0
- data/orangewire_sender.gemspec +63 -0
- data/test/integration/test_orangewire_integration.rb +29 -0
- data/test/teststrap.rb +12 -0
- data/test/unit/test_orangewire_sender.rb +47 -0
- metadata +126 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Joshua Davison
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= orangewire_sender
|
2
|
+
|
3
|
+
Sends messages to The Orangewire
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
Set OrangewireSender.host_url to the url for your Orangewire console.
|
8
|
+
|
9
|
+
OrangewireSender.host_url = "http://localhost:3000"
|
10
|
+
OrangewireSender.login = "username"
|
11
|
+
OrangewireSender.password = "password"
|
12
|
+
|
13
|
+
Call
|
14
|
+
|
15
|
+
OrangewireSender.notify("headline", "summary text")
|
16
|
+
|
17
|
+
== Copyright
|
18
|
+
|
19
|
+
Copyright (c) 2010 Joshua Davison. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "orangewire_sender"
|
8
|
+
gem.summary = %Q{Sends messages to The Orangewire}
|
9
|
+
gem.description = %Q{Sends messages to The Orangewire}
|
10
|
+
gem.email = "josh@stringbot.com"
|
11
|
+
gem.homepage = "http://github.com/stringbot/orangewire_sender"
|
12
|
+
gem.authors = ["Joshua Davison"]
|
13
|
+
gem.add_dependency "rest-client", ">= 0"
|
14
|
+
gem.add_development_dependency "riot", ">= 0.10.13"
|
15
|
+
gem.add_development_dependency "rr", ">= 0.10.10"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
namespace :test do
|
25
|
+
Rake::TestTask.new(:unit) do |test|
|
26
|
+
test.libs << 'lib' << 'test'
|
27
|
+
test.pattern = 'test/unit/test_*.rb'
|
28
|
+
test.verbose = true
|
29
|
+
end
|
30
|
+
|
31
|
+
Rake::TestTask.new(:integration) do |test|
|
32
|
+
test.libs << 'libs' << 'test'
|
33
|
+
test.pattern = 'test/integration/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
require 'rcov/rcovtask'
|
40
|
+
Rcov::RcovTask.new do |test|
|
41
|
+
test.libs << 'test'
|
42
|
+
test.pattern = 'test/**/test_*.rb'
|
43
|
+
test.verbose = true
|
44
|
+
end
|
45
|
+
rescue LoadError
|
46
|
+
task :rcov do
|
47
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
task :test => :check_dependencies
|
52
|
+
|
53
|
+
task :default => 'test:unit'
|
54
|
+
|
55
|
+
require 'rake/rdoctask'
|
56
|
+
Rake::RDocTask.new do |rdoc|
|
57
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
58
|
+
|
59
|
+
rdoc.rdoc_dir = 'rdoc'
|
60
|
+
rdoc.title = "orangewire_sender #{version}"
|
61
|
+
rdoc.rdoc_files.include('README*')
|
62
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
63
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.0
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'restclient'
|
3
|
+
require 'orangewire/errors'
|
4
|
+
|
5
|
+
class OrangewireSender
|
6
|
+
@@host_url = nil
|
7
|
+
@@login = nil
|
8
|
+
@@password = nil
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def notify(headline, summary)
|
12
|
+
begin
|
13
|
+
resource.post({ :headline => headline, :summary => summary, :login => @@login, :password => @@password })
|
14
|
+
rescue Orangewire::Base => b
|
15
|
+
raise b
|
16
|
+
rescue
|
17
|
+
raise Orangewire::ConnectionError, "Error posting to #{@@host_url}", $@
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def resource
|
22
|
+
raise Orangewire::ConfigError, "Please set host_url, login and password" unless valid_config?
|
23
|
+
@resource ||= RestClient::Resource.new("#{@@host_url}/notifications")
|
24
|
+
end
|
25
|
+
|
26
|
+
def host_url=(url)
|
27
|
+
@@host_url = url
|
28
|
+
end
|
29
|
+
|
30
|
+
def login=(login)
|
31
|
+
@@login = login
|
32
|
+
end
|
33
|
+
|
34
|
+
def password=(password)
|
35
|
+
@@password = password
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def valid_config?
|
40
|
+
@@host_url && @@login && @@password
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{orangewire_sender}
|
8
|
+
s.version = "1.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Joshua Davison"]
|
12
|
+
s.date = %q{2010-11-15}
|
13
|
+
s.description = %q{Sends messages to The Orangewire}
|
14
|
+
s.email = %q{josh@stringbot.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/orangewire/errors.rb",
|
27
|
+
"lib/orangewire_sender.rb",
|
28
|
+
"orangewire_sender.gemspec",
|
29
|
+
"test/integration/test_orangewire_integration.rb",
|
30
|
+
"test/teststrap.rb",
|
31
|
+
"test/unit/test_orangewire_sender.rb"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://github.com/stringbot/orangewire_sender}
|
34
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.7}
|
37
|
+
s.summary = %q{Sends messages to The Orangewire}
|
38
|
+
s.test_files = [
|
39
|
+
"test/integration/test_orangewire_integration.rb",
|
40
|
+
"test/teststrap.rb",
|
41
|
+
"test/unit/test_orangewire_sender.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<riot>, [">= 0.10.13"])
|
51
|
+
s.add_development_dependency(%q<rr>, [">= 0.10.10"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
54
|
+
s.add_dependency(%q<riot>, [">= 0.10.13"])
|
55
|
+
s.add_dependency(%q<rr>, [">= 0.10.10"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
59
|
+
s.add_dependency(%q<riot>, [">= 0.10.13"])
|
60
|
+
s.add_dependency(%q<rr>, [">= 0.10.10"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
require 'rest_client'
|
3
|
+
|
4
|
+
class Riot::Situation
|
5
|
+
|
6
|
+
def ow_index
|
7
|
+
response = RestClient.get 'http://localhost:3000/notifications'
|
8
|
+
Nokogiri::HTML(response)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "OrangewireSender" do
|
13
|
+
|
14
|
+
setup do
|
15
|
+
# TODO initialize orangewire server instance before each test
|
16
|
+
OrangewireSender.host_url = "http://localhost:3000"
|
17
|
+
OrangewireSender.login = "test@testing.com"
|
18
|
+
OrangewireSender.password = "tester"
|
19
|
+
|
20
|
+
summary = "SUMMARY: #{Time.now.to_s}"
|
21
|
+
OrangewireSender.notify("Test Headline", summary)
|
22
|
+
summary
|
23
|
+
end
|
24
|
+
|
25
|
+
asserts "appropriately contains text of first notification's summary" do
|
26
|
+
html = ow_index
|
27
|
+
html.css(".notification .summary").first.text == topic
|
28
|
+
end
|
29
|
+
end
|
data/test/teststrap.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'riot'
|
3
|
+
require 'riot/rr'
|
4
|
+
require 'ruby-debug'
|
5
|
+
require 'nokogiri' # TODO how do i just make this a dep for testers but not users
|
6
|
+
|
7
|
+
Riot.verbose
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
11
|
+
require 'orangewire_sender'
|
12
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "OrangewireSender" do
|
4
|
+
setup { OrangewireSender }
|
5
|
+
|
6
|
+
asserts_topic "class exists"
|
7
|
+
|
8
|
+
context "with a legit config" do
|
9
|
+
hookup do
|
10
|
+
OrangewireSender.host_url = "http://fakehost.hxx"
|
11
|
+
OrangewireSender.login = "login"
|
12
|
+
OrangewireSender.password = "password"
|
13
|
+
end
|
14
|
+
|
15
|
+
context "sending messages" do
|
16
|
+
setup do
|
17
|
+
mock.any_instance_of(RestClient::Resource).post(anything) { "post was called" }
|
18
|
+
topic.notify("hey", "ya")
|
19
|
+
end
|
20
|
+
asserts_topic("return value from mock").equals "post was called"
|
21
|
+
end
|
22
|
+
|
23
|
+
context "except for host_url" do
|
24
|
+
hookup { topic.host_url = nil }
|
25
|
+
asserts("notify") { topic.notify("hey", "ya") }.raises(Orangewire::ConfigError, /host_url/)
|
26
|
+
end
|
27
|
+
|
28
|
+
context "except for login" do
|
29
|
+
hookup { topic.login = nil }
|
30
|
+
asserts("notify") { topic.notify("what", "now") }.raises(Orangewire::ConfigError, /login/)
|
31
|
+
end
|
32
|
+
|
33
|
+
context "except for password" do
|
34
|
+
hookup { topic.password = nil }
|
35
|
+
asserts("notify") { topic.notify("no", "dice") }.raises(Orangewire::ConfigError, /password/)
|
36
|
+
end
|
37
|
+
|
38
|
+
context "connecting to bad endpoint" do
|
39
|
+
hookup { topic.host_url = "http://foo.gaz" }
|
40
|
+
asserts("nofify") { topic.notify("what", "up") }.raises(Orangewire::ConnectionError, /Error posting to http:\/\/foo\.gaz/)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end
|
47
|
+
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: orangewire_sender
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 1.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Joshua Davison
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-15 00:00:00 -06:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rest-client
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: riot
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 45
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 10
|
47
|
+
- 13
|
48
|
+
version: 0.10.13
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rr
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 35
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
- 10
|
63
|
+
- 10
|
64
|
+
version: 0.10.10
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
description: Sends messages to The Orangewire
|
68
|
+
email: josh@stringbot.com
|
69
|
+
executables: []
|
70
|
+
|
71
|
+
extensions: []
|
72
|
+
|
73
|
+
extra_rdoc_files:
|
74
|
+
- LICENSE
|
75
|
+
- README.rdoc
|
76
|
+
files:
|
77
|
+
- .document
|
78
|
+
- .gitignore
|
79
|
+
- LICENSE
|
80
|
+
- README.rdoc
|
81
|
+
- Rakefile
|
82
|
+
- VERSION
|
83
|
+
- lib/orangewire/errors.rb
|
84
|
+
- lib/orangewire_sender.rb
|
85
|
+
- orangewire_sender.gemspec
|
86
|
+
- test/integration/test_orangewire_integration.rb
|
87
|
+
- test/teststrap.rb
|
88
|
+
- test/unit/test_orangewire_sender.rb
|
89
|
+
has_rdoc: true
|
90
|
+
homepage: http://github.com/stringbot/orangewire_sender
|
91
|
+
licenses: []
|
92
|
+
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options:
|
95
|
+
- --charset=UTF-8
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
116
|
+
requirements: []
|
117
|
+
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 1.3.7
|
120
|
+
signing_key:
|
121
|
+
specification_version: 3
|
122
|
+
summary: Sends messages to The Orangewire
|
123
|
+
test_files:
|
124
|
+
- test/integration/test_orangewire_integration.rb
|
125
|
+
- test/teststrap.rb
|
126
|
+
- test/unit/test_orangewire_sender.rb
|