self-notifo 0.2.0
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.
- data/LICENSE +20 -0
- data/README.rdoc +49 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/generators/self_notifo/USAGE +5 -0
- data/generators/self_notifo/self_notifo_generator.rb +7 -0
- data/generators/self_notifo/templates/self-notifo.yml +4 -0
- data/lib/self-notifo.rb +41 -0
- data/self-notifo.gemspec +57 -0
- data/spec/self_notifo_spec.rb +7 -0
- data/spec/spec_helper.rb +15 -0
- metadata +126 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009 Gaelian Ditchburn
|
|
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,49 @@
|
|
|
1
|
+
= self-notifo
|
|
2
|
+
|
|
3
|
+
The self-notifo gem allows you to send Notifo (http://notifo.com) notifications to your own Notifo account from your Rails app.
|
|
4
|
+
|
|
5
|
+
== Installation
|
|
6
|
+
$ gem install self-notifo
|
|
7
|
+
|
|
8
|
+
== Usage
|
|
9
|
+
Sign up for a Notifo account (it's free). Take note of your API Username and API Secret (find on your account settings page on the Notifo site)
|
|
10
|
+
|
|
11
|
+
cd into your Rails app and run:
|
|
12
|
+
|
|
13
|
+
./script/generate self_notifo NOTIFO_USERNAME NOTIFO_API_SECRET "Label Describing Your Application"
|
|
14
|
+
|
|
15
|
+
This will generate a file called self-notifo.yml in your config directory (you may wish to add this file to .gitignore or equivalent).
|
|
16
|
+
|
|
17
|
+
When you want to send a notification from your Rails app:
|
|
18
|
+
|
|
19
|
+
SelfNotifo(:msg => "My message.")
|
|
20
|
+
|
|
21
|
+
Optional parameters can be added:
|
|
22
|
+
|
|
23
|
+
SelfNotifo.new(:msg => "My message.", :title => "My Notification Title", :uri => "http://some.com")
|
|
24
|
+
|
|
25
|
+
You can also override the settings in self-notifo.yml:
|
|
26
|
+
|
|
27
|
+
SelfNotifo.new(:msg => "My message.", :title => "My Notification Title", :uri => "http://some.com", :label => 'My Label' :username => 'USERNAME', :api_secret => 'API_SECRET')
|
|
28
|
+
|
|
29
|
+
See https://api.notifo.com/docs/notifications for more info on the Notifo API.
|
|
30
|
+
|
|
31
|
+
== Dependencies
|
|
32
|
+
|
|
33
|
+
John Nunemaker's awesome httparty[http://github.com/jnunemaker/httparty].
|
|
34
|
+
|
|
35
|
+
Ruby on Rails, version 2.3.6 or newer.
|
|
36
|
+
|
|
37
|
+
== Note on Patches/Pull Requests
|
|
38
|
+
|
|
39
|
+
* Fork the project.
|
|
40
|
+
* Make your feature addition or bug fix.
|
|
41
|
+
* Add tests for it. This is important so I don't break it in a
|
|
42
|
+
future version unintentionally.
|
|
43
|
+
* Commit, do not mess with rakefile, version, or history.
|
|
44
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
|
45
|
+
* Send me a pull request. Bonus points for topic branches.
|
|
46
|
+
|
|
47
|
+
== Copyright
|
|
48
|
+
|
|
49
|
+
Copyright (c) 2010 Gaelian Ditchburn. See LICENSE for details.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake'
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'jeweler'
|
|
6
|
+
Jeweler::Tasks.new do |gem|
|
|
7
|
+
gem.name = "self-notifo"
|
|
8
|
+
gem.summary = %Q{Send yourself real-time notifications from your Rails app using Notifo.}
|
|
9
|
+
gem.description = %Q{The self-notifo gem sends notifications to your own Notifo account from your Rails application.}
|
|
10
|
+
gem.email = "gaelian.ditchburn@gmail.com"
|
|
11
|
+
gem.homepage = "http://github.com/gaelian/self-notifo"
|
|
12
|
+
gem.authors = ["Gaelian Ditchburn"]
|
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
|
14
|
+
gem.add_dependency('httparty', '>= 0.6.1')
|
|
15
|
+
gem.add_dependency('rails', '>= 2.3.6')
|
|
16
|
+
gem.files = Dir["{lib,generators}/**/*"] + %w{ Rakefile self-notifo.gemspec VERSION }
|
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
|
18
|
+
end
|
|
19
|
+
Jeweler::GemcutterTasks.new
|
|
20
|
+
rescue LoadError
|
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
require 'spec/rake/spectask'
|
|
25
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
|
26
|
+
spec.libs << 'lib' << 'spec'
|
|
27
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
|
31
|
+
spec.libs << 'lib' << 'spec'
|
|
32
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
33
|
+
spec.rcov = true
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
task :spec => :check_dependencies
|
|
37
|
+
|
|
38
|
+
task :default => :spec
|
|
39
|
+
|
|
40
|
+
require 'rake/rdoctask'
|
|
41
|
+
Rake::RDocTask.new do |rdoc|
|
|
42
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
43
|
+
|
|
44
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
45
|
+
rdoc.title = "self-notifo #{version}"
|
|
46
|
+
rdoc.rdoc_files.include('README*')
|
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
48
|
+
end
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.2.0
|
data/lib/self-notifo.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
require 'yaml'
|
|
3
|
+
|
|
4
|
+
class SelfNotifo
|
|
5
|
+
include HTTParty
|
|
6
|
+
format :json
|
|
7
|
+
|
|
8
|
+
# Pass in a hash when creating a new instance:
|
|
9
|
+
# SelfNotifo.new(:msg => "My message.")
|
|
10
|
+
# Optional parameters can be added:
|
|
11
|
+
# SelfNotifo.new(:msg => "My message.", :label => "My Label", :title => "My Title", :uri => "http://some-relevant-address.com")
|
|
12
|
+
# The message label defaults to the value set in self-notifo.yml
|
|
13
|
+
def initialize(params)
|
|
14
|
+
begin
|
|
15
|
+
config = YAML.load_file("#{Rails.root}/config/self-notifo.yml")
|
|
16
|
+
username = config['auth']['username']
|
|
17
|
+
api_secret = config['auth']['api_secret']
|
|
18
|
+
params[:label] = config['label'] if params[:label].blank?
|
|
19
|
+
rescue Errno::ENOENT
|
|
20
|
+
if params[:username].blank? && params[:api_secret].blank?
|
|
21
|
+
raise 'Config file "self-notifo.yml" not found, have you generated it?'
|
|
22
|
+
else
|
|
23
|
+
username = params[:username]
|
|
24
|
+
api_secret = params[:api_secret]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
self.class.basic_auth username, api_secret
|
|
28
|
+
send_notification(params)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def logger
|
|
34
|
+
RAILS_DEFAULT_LOGGER
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def send_notification(params)
|
|
38
|
+
r = self.class.post('https://api.notifo.com/v1/send_notification', { :body => { :msg => params[:msg], :label => params[:label], :title => params[:title], :uri => params[:uri] } })
|
|
39
|
+
logger.info "self-notifo: sent notification, response was: " + r.parsed_response.inspect
|
|
40
|
+
end
|
|
41
|
+
end
|
data/self-notifo.gemspec
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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{self-notifo}
|
|
8
|
+
s.version = "0.2.0"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Gaelian Ditchburn"]
|
|
12
|
+
s.date = %q{2010-09-18}
|
|
13
|
+
s.description = %q{The self-notifo gem sends notifications to your own Notifo account from your Rails application.}
|
|
14
|
+
s.email = %q{gaelian.ditchburn@gmail.com}
|
|
15
|
+
s.extra_rdoc_files = [
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"README.rdoc"
|
|
18
|
+
]
|
|
19
|
+
s.files = [
|
|
20
|
+
"Rakefile",
|
|
21
|
+
"VERSION",
|
|
22
|
+
"generators/self_notifo/USAGE",
|
|
23
|
+
"generators/self_notifo/self_notifo_generator.rb",
|
|
24
|
+
"generators/self_notifo/templates/self-notifo.yml",
|
|
25
|
+
"lib/self-notifo.rb",
|
|
26
|
+
"self-notifo.gemspec"
|
|
27
|
+
]
|
|
28
|
+
s.homepage = %q{http://github.com/gaelian/self-notifo}
|
|
29
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
|
30
|
+
s.require_paths = ["lib"]
|
|
31
|
+
s.rubygems_version = %q{1.3.7}
|
|
32
|
+
s.summary = %q{Send yourself real-time notifications from your Rails app using Notifo.}
|
|
33
|
+
s.test_files = [
|
|
34
|
+
"spec/self_notifo_spec.rb",
|
|
35
|
+
"spec/spec_helper.rb"
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
if s.respond_to? :specification_version then
|
|
39
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
40
|
+
s.specification_version = 3
|
|
41
|
+
|
|
42
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
43
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
|
44
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.6.1"])
|
|
45
|
+
s.add_runtime_dependency(%q<rails>, [">= 2.3.6"])
|
|
46
|
+
else
|
|
47
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
|
48
|
+
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
|
49
|
+
s.add_dependency(%q<rails>, [">= 2.3.6"])
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
|
53
|
+
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
|
54
|
+
s.add_dependency(%q<rails>, [">= 2.3.6"])
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe SelfNotifo, "#initialize" do
|
|
4
|
+
it "should raise exception when required parameters are not found" do
|
|
5
|
+
expect{ SelfNotifo.new(:msg => "Test message.") }.to raise_error(RuntimeError)
|
|
6
|
+
end
|
|
7
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
|
+
require 'self-notifo'
|
|
4
|
+
require 'spec'
|
|
5
|
+
require 'spec/autorun'
|
|
6
|
+
|
|
7
|
+
Spec::Runner.configure do |config|
|
|
8
|
+
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module Rails
|
|
12
|
+
def self.root
|
|
13
|
+
''
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: self-notifo
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 23
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 2
|
|
9
|
+
- 0
|
|
10
|
+
version: 0.2.0
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Gaelian Ditchburn
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2010-09-18 00:00:00 +10:00
|
|
19
|
+
default_executable:
|
|
20
|
+
dependencies:
|
|
21
|
+
- !ruby/object:Gem::Dependency
|
|
22
|
+
name: rspec
|
|
23
|
+
prerelease: false
|
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 13
|
|
30
|
+
segments:
|
|
31
|
+
- 1
|
|
32
|
+
- 2
|
|
33
|
+
- 9
|
|
34
|
+
version: 1.2.9
|
|
35
|
+
type: :development
|
|
36
|
+
version_requirements: *id001
|
|
37
|
+
- !ruby/object:Gem::Dependency
|
|
38
|
+
name: httparty
|
|
39
|
+
prerelease: false
|
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
hash: 5
|
|
46
|
+
segments:
|
|
47
|
+
- 0
|
|
48
|
+
- 6
|
|
49
|
+
- 1
|
|
50
|
+
version: 0.6.1
|
|
51
|
+
type: :runtime
|
|
52
|
+
version_requirements: *id002
|
|
53
|
+
- !ruby/object:Gem::Dependency
|
|
54
|
+
name: rails
|
|
55
|
+
prerelease: false
|
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
hash: 15
|
|
62
|
+
segments:
|
|
63
|
+
- 2
|
|
64
|
+
- 3
|
|
65
|
+
- 6
|
|
66
|
+
version: 2.3.6
|
|
67
|
+
type: :runtime
|
|
68
|
+
version_requirements: *id003
|
|
69
|
+
description: The self-notifo gem sends notifications to your own Notifo account from your Rails application.
|
|
70
|
+
email: gaelian.ditchburn@gmail.com
|
|
71
|
+
executables: []
|
|
72
|
+
|
|
73
|
+
extensions: []
|
|
74
|
+
|
|
75
|
+
extra_rdoc_files:
|
|
76
|
+
- LICENSE
|
|
77
|
+
- README.rdoc
|
|
78
|
+
files:
|
|
79
|
+
- Rakefile
|
|
80
|
+
- VERSION
|
|
81
|
+
- generators/self_notifo/USAGE
|
|
82
|
+
- generators/self_notifo/self_notifo_generator.rb
|
|
83
|
+
- generators/self_notifo/templates/self-notifo.yml
|
|
84
|
+
- lib/self-notifo.rb
|
|
85
|
+
- self-notifo.gemspec
|
|
86
|
+
- LICENSE
|
|
87
|
+
- README.rdoc
|
|
88
|
+
- spec/self_notifo_spec.rb
|
|
89
|
+
- spec/spec_helper.rb
|
|
90
|
+
has_rdoc: true
|
|
91
|
+
homepage: http://github.com/gaelian/self-notifo
|
|
92
|
+
licenses: []
|
|
93
|
+
|
|
94
|
+
post_install_message:
|
|
95
|
+
rdoc_options:
|
|
96
|
+
- --charset=UTF-8
|
|
97
|
+
require_paths:
|
|
98
|
+
- lib
|
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
|
+
none: false
|
|
101
|
+
requirements:
|
|
102
|
+
- - ">="
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
hash: 3
|
|
105
|
+
segments:
|
|
106
|
+
- 0
|
|
107
|
+
version: "0"
|
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
|
+
none: false
|
|
110
|
+
requirements:
|
|
111
|
+
- - ">="
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
hash: 3
|
|
114
|
+
segments:
|
|
115
|
+
- 0
|
|
116
|
+
version: "0"
|
|
117
|
+
requirements: []
|
|
118
|
+
|
|
119
|
+
rubyforge_project:
|
|
120
|
+
rubygems_version: 1.3.7
|
|
121
|
+
signing_key:
|
|
122
|
+
specification_version: 3
|
|
123
|
+
summary: Send yourself real-time notifications from your Rails app using Notifo.
|
|
124
|
+
test_files:
|
|
125
|
+
- spec/self_notifo_spec.rb
|
|
126
|
+
- spec/spec_helper.rb
|