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.
@@ -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
- require 'rake/testtask'
21
- Rake::TestTask.new(:test) do |test|
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.1
1
+ 0.2.0
@@ -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
- puts n2.notify_all(users, :text => "Tell everyone").each {|resp| puts resp }
41
+ n2.notify_all(users, :text => "Tell everyone")
@@ -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 notify_api_key(key=nil)
15
- return @api_key unless key
16
- @api_key = key
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 initialize
20
- yield self if block_given?
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
@@ -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
@@ -1,3 +1 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'lib', 'ruby-libnio')
2
- gem 'rspec'
3
- require 'spec/autorun'
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.1.1
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-01-31 00:00:00 -08:00
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
- - ruby-libnio.gemspec
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/libnio-spec.rb
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
@@ -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
-
@@ -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
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'ruby-libnio'
8
-
9
- class Test::Unit::TestCase
10
- end
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestRubyLibnio < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end