im-kayac 0.0.5 → 0.1.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/.gitignore +16 -0
- data/Gemfile +4 -0
- data/History.txt +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +1 -25
- data/im-kayac.gemspec +21 -0
- data/lib/im-kayac.rb +5 -36
- data/lib/im-kayac/main.rb +10 -0
- data/lib/im-kayac/message.rb +42 -0
- data/lib/im-kayac/version.rb +3 -0
- data/sample/password.rb +9 -0
- data/sample/secret_key.rb +9 -0
- data/sample/simple.rb +9 -0
- metadata +29 -45
- data/.gemtest +0 -0
- data/Manifest.txt +0 -15
- data/README.rdoc +0 -52
- data/examples/password.rb +0 -8
- data/examples/sig.rb +0 -12
- data/examples/simple.rb +0 -8
data/.gitignore
ADDED
data/Gemfile
ADDED
data/History.txt
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2011-2013 Sho Hashimoto
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
im-kayac
|
2
|
+
========
|
3
|
+
rubygem for [im.kayac.com](http://im.kayac.com)
|
4
|
+
|
5
|
+
* http://github.com/shokai/ruby-im-kayac
|
6
|
+
|
7
|
+
|
8
|
+
Install
|
9
|
+
-------
|
10
|
+
|
11
|
+
% gem install im-kayac
|
12
|
+
|
13
|
+
|
14
|
+
Registration
|
15
|
+
------------
|
16
|
+
please registrate on http://im.kayac.com
|
17
|
+
|
18
|
+
|
19
|
+
Usage
|
20
|
+
-----
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require 'im-kayac'
|
24
|
+
ImKayac.to('username').post('hello world')
|
25
|
+
```
|
26
|
+
|
27
|
+
password
|
28
|
+
```ruby
|
29
|
+
ImKayac.to('username').password('your-password').post('hello')
|
30
|
+
```
|
31
|
+
|
32
|
+
secret key
|
33
|
+
```ruby
|
34
|
+
ImKayac.to('username').secret('your-key').post('hello')
|
35
|
+
```
|
36
|
+
|
37
|
+
|
38
|
+
Sample
|
39
|
+
------
|
40
|
+
https://github.com/shokai/ruby-im-kayac/tree/master/sample
|
41
|
+
|
42
|
+
|
43
|
+
Contributing
|
44
|
+
------------
|
45
|
+
|
46
|
+
1. Fork it
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -1,25 +1 @@
|
|
1
|
-
require
|
2
|
-
gem 'hoe', '>= 2.1.0'
|
3
|
-
require 'hoe'
|
4
|
-
require 'fileutils'
|
5
|
-
require './lib/im-kayac'
|
6
|
-
|
7
|
-
Hoe.plugin :newgem
|
8
|
-
# Hoe.plugin :website
|
9
|
-
# Hoe.plugin :cucumberfeatures
|
10
|
-
|
11
|
-
# Generate all the Rake tasks
|
12
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
-
$hoe = Hoe.spec 'im-kayac' do
|
14
|
-
self.developer 'Sho Hashimoto', 'hashimoto@shokai.org'
|
15
|
-
self.rubyforge_name = self.name # TODO this is default value
|
16
|
-
self.extra_deps = [['json']]
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
require 'newgem/tasks'
|
21
|
-
Dir['tasks/**/*.rake'].each { |t| load t }
|
22
|
-
|
23
|
-
# TODO - want other tests/tasks run by default? Add them to the list
|
24
|
-
# remove_task :default
|
25
|
-
# task :default => [:spec, :features]
|
1
|
+
require "bundler/gem_tasks"
|
data/im-kayac.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'im-kayac/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "im-kayac"
|
7
|
+
gem.version = ImKayac::VERSION
|
8
|
+
gem.authors = ["Sho Hashimoto"]
|
9
|
+
gem.email = ["hashimoto@shokai.org"]
|
10
|
+
gem.description = %q{post message http://im.kayac.com}
|
11
|
+
gem.summary = gem.description
|
12
|
+
gem.homepage = "https://github.com/shokai/ruby-im-kayac"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/).reject{|i| i=="Gemfile.lock" }
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
gem.add_dependency "json"
|
20
|
+
gem.add_dependency "httparty"
|
21
|
+
end
|
data/lib/im-kayac.rb
CHANGED
@@ -2,43 +2,12 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
require '
|
6
|
-
require 'net/http'
|
5
|
+
require 'httparty'
|
7
6
|
require 'json'
|
7
|
+
require 'digest/sha1'
|
8
|
+
require 'im-kayac/version'
|
9
|
+
require 'im-kayac/message'
|
10
|
+
require 'im-kayac/main'
|
8
11
|
|
9
12
|
module ImKayac
|
10
|
-
|
11
|
-
VERSION = '0.0.5'
|
12
|
-
|
13
|
-
def ImKayac.post(user, message, opts = {})
|
14
|
-
uri = URI.parse("http://im.kayac.com/api/post/#{user}")
|
15
|
-
params = {:message => URI.encode(message)}
|
16
|
-
opts = {} unless opts
|
17
|
-
|
18
|
-
# http://im.kayac.com/#docs
|
19
|
-
# keys of "opts" are [:handler, :password, :sig]
|
20
|
-
opts.each{|k,v|
|
21
|
-
params[k] = v
|
22
|
-
}
|
23
|
-
query = params.map{|k,v| "#{k}=#{v}"}.join('&')
|
24
|
-
message.gsub!(/&/, '_')
|
25
|
-
res = nil
|
26
|
-
Net::HTTP.start(uri.host, uri.port){|http|
|
27
|
-
http_res = http.post(uri.path, query)
|
28
|
-
res = JSON.parse(http_res.body)
|
29
|
-
}
|
30
|
-
unless res['result'].to_s == 'posted' and res['error'].to_s == ''
|
31
|
-
error = res['error'].to_s
|
32
|
-
if error.size > 0
|
33
|
-
raise Error.new(error)
|
34
|
-
else
|
35
|
-
raise Error.new('unknown error')
|
36
|
-
end
|
37
|
-
end
|
38
|
-
return res
|
39
|
-
end
|
40
|
-
|
41
|
-
class Error < StandardError
|
42
|
-
end
|
43
|
-
|
44
13
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module ImKayac
|
2
|
+
|
3
|
+
class Message
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@to = nil
|
7
|
+
@secret = nil
|
8
|
+
@password = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def to(name)
|
12
|
+
@to = name
|
13
|
+
return self
|
14
|
+
end
|
15
|
+
|
16
|
+
def secret(str)
|
17
|
+
@secret = str
|
18
|
+
return self
|
19
|
+
end
|
20
|
+
|
21
|
+
def password(str)
|
22
|
+
@password = str
|
23
|
+
return self
|
24
|
+
end
|
25
|
+
|
26
|
+
def post(message)
|
27
|
+
params = {:message => message}
|
28
|
+
params[:sig] = Digest::SHA1.hexdigest "#{message}#{@secret}" if @secret
|
29
|
+
params[:password] = @password if @password
|
30
|
+
|
31
|
+
res = HTTParty.post "http://im.kayac.com/api/post/#{@to}", :body => params
|
32
|
+
raise Error.new "response error (#{res.code})" unless res.code == 200
|
33
|
+
data = JSON.parse res.body
|
34
|
+
unless data['result'].to_s == 'posted' and res['error'].to_s == ''
|
35
|
+
raise Error.new(data['error'] || 'unknown error')
|
36
|
+
end
|
37
|
+
data
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/sample/password.rb
ADDED
data/sample/simple.rb
ADDED
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: im-kayac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 21
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 5
|
10
|
-
version: 0.0.5
|
5
|
+
version: 0.1.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Sho Hashimoto
|
@@ -15,8 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
13
|
+
date: 2013-03-13 00:00:00 Z
|
20
14
|
dependencies:
|
21
15
|
- !ruby/object:Gem::Dependency
|
22
16
|
name: json
|
@@ -26,44 +20,44 @@ dependencies:
|
|
26
20
|
requirements:
|
27
21
|
- - ">="
|
28
22
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 0
|
32
23
|
version: "0"
|
33
24
|
type: :runtime
|
34
25
|
version_requirements: *id001
|
35
26
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
27
|
+
name: httparty
|
37
28
|
prerelease: false
|
38
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
30
|
none: false
|
40
31
|
requirements:
|
41
32
|
- - ">="
|
42
33
|
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
- 2
|
46
|
-
- 9
|
47
|
-
- 4
|
48
|
-
version: 2.9.4
|
49
|
-
type: :development
|
34
|
+
version: "0"
|
35
|
+
type: :runtime
|
50
36
|
version_requirements: *id002
|
51
|
-
description:
|
37
|
+
description: post message http://im.kayac.com
|
52
38
|
email:
|
53
39
|
- hashimoto@shokai.org
|
54
40
|
executables: []
|
55
41
|
|
56
42
|
extensions: []
|
57
43
|
|
58
|
-
extra_rdoc_files:
|
59
|
-
|
60
|
-
- Manifest.txt
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
61
46
|
files:
|
47
|
+
- .gitignore
|
48
|
+
- Gemfile
|
62
49
|
- History.txt
|
63
|
-
-
|
64
|
-
- README.
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
65
52
|
- Rakefile
|
53
|
+
- im-kayac.gemspec
|
66
54
|
- lib/im-kayac.rb
|
55
|
+
- lib/im-kayac/main.rb
|
56
|
+
- lib/im-kayac/message.rb
|
57
|
+
- lib/im-kayac/version.rb
|
58
|
+
- sample/password.rb
|
59
|
+
- sample/secret_key.rb
|
60
|
+
- sample/simple.rb
|
67
61
|
- script/console
|
68
62
|
- script/destroy
|
69
63
|
- script/generate
|
@@ -71,18 +65,12 @@ files:
|
|
71
65
|
- spec/spec.opts
|
72
66
|
- spec/spec_helper.rb
|
73
67
|
- tasks/rspec.rake
|
74
|
-
|
75
|
-
- examples/sig.rb
|
76
|
-
- examples/simple.rb
|
77
|
-
- .gemtest
|
78
|
-
has_rdoc: true
|
79
|
-
homepage: http://github.com/shokai/ruby-im-kayac
|
68
|
+
homepage: https://github.com/shokai/ruby-im-kayac
|
80
69
|
licenses: []
|
81
70
|
|
82
71
|
post_install_message:
|
83
|
-
rdoc_options:
|
84
|
-
|
85
|
-
- README.rdoc
|
72
|
+
rdoc_options: []
|
73
|
+
|
86
74
|
require_paths:
|
87
75
|
- lib
|
88
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -90,25 +78,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
78
|
requirements:
|
91
79
|
- - ">="
|
92
80
|
- !ruby/object:Gem::Version
|
93
|
-
hash: 3
|
94
|
-
segments:
|
95
|
-
- 0
|
96
81
|
version: "0"
|
97
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
83
|
none: false
|
99
84
|
requirements:
|
100
85
|
- - ">="
|
101
86
|
- !ruby/object:Gem::Version
|
102
|
-
hash: 3
|
103
|
-
segments:
|
104
|
-
- 0
|
105
87
|
version: "0"
|
106
88
|
requirements: []
|
107
89
|
|
108
|
-
rubyforge_project:
|
109
|
-
rubygems_version: 1.
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.8.17
|
110
92
|
signing_key:
|
111
93
|
specification_version: 3
|
112
|
-
summary:
|
113
|
-
test_files:
|
114
|
-
|
94
|
+
summary: post message http://im.kayac.com
|
95
|
+
test_files:
|
96
|
+
- spec/im-kayac_spec.rb
|
97
|
+
- spec/spec.opts
|
98
|
+
- spec/spec_helper.rb
|
data/.gemtest
DELETED
File without changes
|
data/Manifest.txt
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
Manifest.txt
|
3
|
-
README.rdoc
|
4
|
-
Rakefile
|
5
|
-
lib/im-kayac.rb
|
6
|
-
script/console
|
7
|
-
script/destroy
|
8
|
-
script/generate
|
9
|
-
spec/im-kayac_spec.rb
|
10
|
-
spec/spec.opts
|
11
|
-
spec/spec_helper.rb
|
12
|
-
tasks/rspec.rake
|
13
|
-
examples/password.rb
|
14
|
-
examples/sig.rb
|
15
|
-
examples/simple.rb
|
data/README.rdoc
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
= im-kayac
|
2
|
-
|
3
|
-
* http://github.com/shokai/ruby-im-kayac
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
|
7
|
-
* post message http://im.kayac.com/
|
8
|
-
|
9
|
-
== REGISTRATION:
|
10
|
-
|
11
|
-
* please registrate on http://im.kayac.com/
|
12
|
-
|
13
|
-
== SYNOPSIS:
|
14
|
-
|
15
|
-
require 'rubygems'
|
16
|
-
require 'im-kayac'
|
17
|
-
|
18
|
-
begin
|
19
|
-
p ImKayac.post("username", "hello world")
|
20
|
-
rescue => e
|
21
|
-
STDERR.puts e
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
== INSTALL:
|
26
|
-
|
27
|
-
* gem install im-kayac
|
28
|
-
|
29
|
-
== LICENSE:
|
30
|
-
|
31
|
-
(The MIT License)
|
32
|
-
|
33
|
-
Copyright (c) 2010 Sho Hashimoto
|
34
|
-
|
35
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
36
|
-
a copy of this software and associated documentation files (the
|
37
|
-
'Software'), to deal in the Software without restriction, including
|
38
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
39
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
40
|
-
permit persons to whom the Software is furnished to do so, subject to
|
41
|
-
the following conditions:
|
42
|
-
|
43
|
-
The above copyright notice and this permission notice shall be
|
44
|
-
included in all copies or substantial portions of the Software.
|
45
|
-
|
46
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
47
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
48
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
49
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
50
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
51
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
52
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/examples/password.rb
DELETED
data/examples/sig.rb
DELETED