im-kayac 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in im-kayac.gemspec
4
+ gemspec
@@ -1,3 +1,7 @@
1
+ === 0.1.0 2013-03-14
2
+
3
+ * new API
4
+
1
5
  === 0.0.5 2011-04-27
2
6
 
3
7
  * gem install json
@@ -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.
@@ -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 'rubygems'
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"
@@ -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
@@ -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 'uri'
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,10 @@
1
+ module ImKayac
2
+
3
+ class Error < StandardError
4
+ end
5
+
6
+ def self.to(name)
7
+ Message.new.to(name)
8
+ end
9
+
10
+ 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
@@ -0,0 +1,3 @@
1
+ module ImKayac
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
3
+ require 'im-kayac'
4
+
5
+ begin
6
+ p ImKayac.to('username').password('your-password').post('hello world')
7
+ rescue => e
8
+ STDERR.puts e
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
3
+ require 'im-kayac'
4
+
5
+ begin
6
+ p ImKayac.to('username').secret('your-key').post('hello world')
7
+ rescue => e
8
+ STDERR.puts e
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
3
+ require 'im-kayac'
4
+
5
+ begin
6
+ p ImKayac.to('username').post('hello world')
7
+ rescue => e
8
+ STDERR.puts e
9
+ end
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
- segments:
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: 2011-04-27 00:00:00 +09:00
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: hoe
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
- hash: 35
44
- segments:
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: "* post message http://im.kayac.com/"
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
- - History.txt
60
- - Manifest.txt
44
+ extra_rdoc_files: []
45
+
61
46
  files:
47
+ - .gitignore
48
+ - Gemfile
62
49
  - History.txt
63
- - Manifest.txt
64
- - README.rdoc
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
- - examples/password.rb
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
- - --main
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: im-kayac
109
- rubygems_version: 1.6.2
90
+ rubyforge_project:
91
+ rubygems_version: 1.8.17
110
92
  signing_key:
111
93
  specification_version: 3
112
- summary: "* post message http://im.kayac.com/"
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
@@ -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
@@ -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.
@@ -1,8 +0,0 @@
1
- require 'rubygems'
2
- require 'im-kayac'
3
-
4
- begin
5
- p ImKayac.post("username", "hello world", {:password => 'your-password'})
6
- rescue => e
7
- STDERR.puts e
8
- end
@@ -1,12 +0,0 @@
1
- require 'rubygems'
2
- require 'im-kayac'
3
- require 'digest/sha1'
4
-
5
- message = 'hello world'
6
- sig = Digest::SHA1.hexdigest(message + 'your-sig')
7
-
8
- begin
9
- p ImKayac.post("username", message, {:sig => sig})
10
- rescue => e
11
- STDERR.puts e
12
- end
@@ -1,8 +0,0 @@
1
- require 'rubygems'
2
- require 'im-kayac'
3
-
4
- begin
5
- p ImKayac.post("username", "hello world")
6
- rescue => e
7
- STDERR.puts e
8
- end