ruby-libnio 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -0
- data/Rakefile +3 -33
- data/VERSION +1 -1
- data/examples/simple.rb +1 -1
- data/lib/ruby-libnio.rb +31 -10
- data/spec/libnio_spec.rb +47 -0
- data/spec/spec_helper.rb +0 -2
- metadata +4 -9
- data/ruby-libnio.gemspec +0 -60
- data/spec/libnio-spec.rb +0 -16
- data/test/helper.rb +0 -10
- data/test/test_ruby-libnio.rb +0 -7
data/README.rdoc
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
Library for writing Notify.io(http://notify.io) applications
|
4
4
|
|
5
|
+
== Note
|
6
|
+
Version 2.0 of ruby-libnio gives your mixing class the ability to take parameters during initialization. Previously only the initialization method provided by LibNio was called. If your notification class needs to store store when it is initialized, then upgrade to v2.0.
|
7
|
+
|
5
8
|
== Dependencies
|
6
9
|
|
7
10
|
You'll need the HTTParty gem
|
@@ -63,6 +66,10 @@ Lastly, it is possible to send the same notification to a number of users:
|
|
63
66
|
|
64
67
|
This will return an array of the responses codes from the Notify.io API.
|
65
68
|
|
69
|
+
== Shoutouts
|
70
|
+
|
71
|
+
Thanks to Rob Olson for his help in aliasing the initialize method for mixing classes.
|
72
|
+
|
66
73
|
|
67
74
|
== Note on Patches/Pull Requests
|
68
75
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'rake'
|
2
|
+
require 'spec/rake/spectask'
|
3
3
|
|
4
4
|
begin
|
5
5
|
require 'jeweler'
|
@@ -17,36 +17,6 @@ rescue LoadError
|
|
17
17
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
test.libs << 'lib' << 'test'
|
23
|
-
test.pattern = 'test/**/test_*.rb'
|
24
|
-
test.verbose = true
|
25
|
-
end
|
26
|
-
|
27
|
-
begin
|
28
|
-
require 'rcov/rcovtask'
|
29
|
-
Rcov::RcovTask.new do |test|
|
30
|
-
test.libs << 'test'
|
31
|
-
test.pattern = 'test/**/test_*.rb'
|
32
|
-
test.verbose = true
|
33
|
-
end
|
34
|
-
rescue LoadError
|
35
|
-
task :rcov do
|
36
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
task :test => :check_dependencies
|
41
|
-
|
42
|
-
task :default => :test
|
43
|
-
|
44
|
-
require 'rake/rdoctask'
|
45
|
-
Rake::RDocTask.new do |rdoc|
|
46
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
-
|
48
|
-
rdoc.rdoc_dir = 'rdoc'
|
49
|
-
rdoc.title = "ruby-libnio #{version}"
|
50
|
-
rdoc.rdoc_files.include('README*')
|
51
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
20
|
+
Spec::Rake::SpecTask.new do |t|
|
21
|
+
t.spec_opts = ["--color"]
|
52
22
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/examples/simple.rb
CHANGED
@@ -38,4 +38,4 @@ puts n2.notify(userhash_1, :text => "message text", :title => "New Title", :stic
|
|
38
38
|
userhash_2 = "5add5f77c09f4c639293e7254a1faf77"
|
39
39
|
users = [userhash_1, userhash_2]
|
40
40
|
|
41
|
-
|
41
|
+
n2.notify_all(users, :text => "Tell everyone")
|
data/lib/ruby-libnio.rb
CHANGED
@@ -1,23 +1,43 @@
|
|
1
|
+
require 'rubygems'
|
1
2
|
require 'httparty'
|
2
3
|
|
3
4
|
module LibNio
|
4
|
-
|
5
|
+
|
5
6
|
attr_accessor :title, :icon, :link, :sticky
|
6
|
-
|
7
|
+
|
7
8
|
def self.included(base)
|
8
|
-
base.extend ClassMethods
|
9
9
|
base.send(:include, HTTParty)
|
10
10
|
base.send(:base_uri, 'api.notify.io')
|
11
|
+
base.class_eval do
|
12
|
+
base.extend ClassMethods
|
13
|
+
|
14
|
+
__overwrite_initialize__
|
15
|
+
|
16
|
+
def self.method_added(name)
|
17
|
+
return if name != :initialize || @_overwrote_initialize
|
18
|
+
|
19
|
+
@_overwrote_initialize = true
|
20
|
+
__overwrite_initialize__
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
11
24
|
end
|
12
25
|
|
13
26
|
module ClassMethods
|
14
|
-
def
|
15
|
-
|
16
|
-
|
27
|
+
def __overwrite_initialize__
|
28
|
+
class_eval do
|
29
|
+
alias_method :original_initialize, :initialize
|
30
|
+
|
31
|
+
def initialize(*args)
|
32
|
+
yield(self) if block_given?
|
33
|
+
original_initialize(*args)
|
34
|
+
end
|
35
|
+
end
|
17
36
|
end
|
18
|
-
|
19
|
-
def
|
20
|
-
|
37
|
+
|
38
|
+
def notify_api_key(key = nil)
|
39
|
+
return @api_key if key.nil?
|
40
|
+
@api_key = key
|
21
41
|
end
|
22
42
|
end
|
23
43
|
|
@@ -47,6 +67,7 @@ module LibNio
|
|
47
67
|
end
|
48
68
|
responses
|
49
69
|
end
|
50
|
-
|
70
|
+
|
51
71
|
private :api_key
|
72
|
+
|
52
73
|
end
|
data/spec/libnio_spec.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
2
|
+
|
3
|
+
describe LibNio do
|
4
|
+
before(:each) do
|
5
|
+
@klass = Class.new
|
6
|
+
@klass.instance_eval { include LibNio }
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should mix in HTTParty" do
|
10
|
+
@klass.include?(HTTParty).should == true
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set the base uri" do
|
14
|
+
@klass.base_uri.should == 'http://api.notify.io'
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "when mixing class takes params for initialization" do
|
18
|
+
before(:each) do
|
19
|
+
class C
|
20
|
+
include LibNio
|
21
|
+
|
22
|
+
attr_accessor :name, :val
|
23
|
+
|
24
|
+
def initialize(n, v)
|
25
|
+
@name = n
|
26
|
+
@val = v
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
@c = C.new("joe", 4) do |c|
|
31
|
+
c.title = "test"
|
32
|
+
c.link = "http://test.net"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should handle the block initialization" do
|
37
|
+
@c.title.should == "test"
|
38
|
+
@c.link.should == "http://test.net"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should call the mixing class' initialize with the correct parameters" do
|
42
|
+
@c.name.should == "joe"
|
43
|
+
@c.val.should == 4
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-libnio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hunter Gillane
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-09 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,11 +40,8 @@ files:
|
|
40
40
|
- VERSION
|
41
41
|
- examples/simple.rb
|
42
42
|
- lib/ruby-libnio.rb
|
43
|
-
-
|
44
|
-
- spec/libnio-spec.rb
|
43
|
+
- spec/libnio_spec.rb
|
45
44
|
- spec/spec_helper.rb
|
46
|
-
- test/helper.rb
|
47
|
-
- test/test_ruby-libnio.rb
|
48
45
|
has_rdoc: true
|
49
46
|
homepage: http://github.com/pinecon3/ruby-libnio
|
50
47
|
licenses: []
|
@@ -74,8 +71,6 @@ signing_key:
|
|
74
71
|
specification_version: 3
|
75
72
|
summary: helps you write applications that can send notifications to Notify.io
|
76
73
|
test_files:
|
77
|
-
- spec/
|
74
|
+
- spec/libnio_spec.rb
|
78
75
|
- spec/spec_helper.rb
|
79
|
-
- test/helper.rb
|
80
|
-
- test/test_ruby-libnio.rb
|
81
76
|
- examples/simple.rb
|
data/ruby-libnio.gemspec
DELETED
@@ -1,60 +0,0 @@
|
|
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{ruby-libnio}
|
8
|
-
s.version = "0.1.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Hunter Gillane"]
|
12
|
-
s.date = %q{2010-01-31}
|
13
|
-
s.description = %q{helps you write applications that can send notifications to Notify.io}
|
14
|
-
s.email = %q{hunter.gillane@gmail.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
|
-
"examples/simple.rb",
|
27
|
-
"lib/ruby-libnio.rb",
|
28
|
-
"ruby-libnio.gemspec",
|
29
|
-
"spec/libnio-spec.rb",
|
30
|
-
"spec/spec_helper.rb",
|
31
|
-
"test/helper.rb",
|
32
|
-
"test/test_ruby-libnio.rb"
|
33
|
-
]
|
34
|
-
s.homepage = %q{http://github.com/pinecon3/ruby-libnio}
|
35
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
-
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.5}
|
38
|
-
s.summary = %q{helps you write applications that can send notifications to Notify.io}
|
39
|
-
s.test_files = [
|
40
|
-
"spec/libnio-spec.rb",
|
41
|
-
"spec/spec_helper.rb",
|
42
|
-
"test/helper.rb",
|
43
|
-
"test/test_ruby-libnio.rb",
|
44
|
-
"examples/simple.rb"
|
45
|
-
]
|
46
|
-
|
47
|
-
if s.respond_to? :specification_version then
|
48
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
-
s.specification_version = 3
|
50
|
-
|
51
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
52
|
-
s.add_runtime_dependency(%q<httparty>, [">= 0.4.5"])
|
53
|
-
else
|
54
|
-
s.add_dependency(%q<httparty>, [">= 0.4.5"])
|
55
|
-
end
|
56
|
-
else
|
57
|
-
s.add_dependency(%q<httparty>, [">= 0.4.5"])
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
data/spec/libnio-spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
2
|
-
|
3
|
-
describe LibNio do
|
4
|
-
before(:each) do
|
5
|
-
@klass = Class.new
|
6
|
-
@klass.instance_eval { include LibNio }
|
7
|
-
end
|
8
|
-
c
|
9
|
-
it "should mix in HTTParty" do
|
10
|
-
@klass.include?(HTTParty).should == true
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should set the base uri" do
|
14
|
-
@klass.base_uri.should == 'http://api.notify.io'
|
15
|
-
end
|
16
|
-
end
|
data/test/helper.rb
DELETED