ezcomet 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *~
19
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ezcomet.gemspec
4
+ gemspec
5
+ gem 'curb'
6
+ gem 'json'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jin-Sih Lin
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,38 @@
1
+ # Ezcomet Ruby SDK
2
+
3
+ EZComet is the best realtime web message pushing solution.
4
+
5
+ This gem is Ezcomet Ruby SDK.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'ezcomet'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ezcomet
20
+
21
+ ## Usage (Sample Code)
22
+
23
+ #!/usr/bin/env ruby
24
+ require 'ezcomet'
25
+
26
+ puts Ezcomet.push 'Your API Key', 'User Name', 'Channel Name', 'Test Message'
27
+ puts Ezcomet.flush 'Your API Key', 'User Name', 'Channel Name'
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
36
+
37
+ ## LICENSE
38
+ The MIT License
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/ezcomet_test ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ezcomet'
4
+
5
+ puts Ezcomet.push 'Your API Key', 'User Name', 'Channel Name', 'Test Message'
6
+ puts Ezcomet.flush 'Your API Key', 'User Name', 'Channel Name'
data/ezcomet.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ezcomet/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "ezcomet"
8
+ gem.version = Ezcomet::VERSION
9
+ gem.authors = ["Jin-Sih Lin"]
10
+ gem.email = ["linpct@gmail.com"]
11
+ gem.description = %q{EZComet is the best realtime web message pushing solution. And this is ezcomet ruby sdk.}
12
+ gem.summary = %q{Ezcomet Ruby SDK}
13
+ gem.homepage = "https://github.com/pct/ezcomet"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
data/lib/ezcomet.rb ADDED
@@ -0,0 +1,30 @@
1
+ require "ezcomet/version"
2
+ require 'curb'
3
+ require 'json'
4
+
5
+ module Ezcomet
6
+ @ezcomet_write_url = 'http://api.ezcomet.com/write'
7
+
8
+ def self.push(api_key, user_name, channel, msg)
9
+ data = {:qname => "#{user_name}-#{channel}", :api_key => api_key, :msg => msg}
10
+
11
+ http = Curl.post @ezcomet_write_url, data
12
+ ret = JSON.parse http.body_str
13
+
14
+ return false if 'ok' != ret['code']
15
+ ret['tick']
16
+
17
+ end
18
+
19
+ def self.flush(api_key, user_name, channel)
20
+ data = {:qname => "#{user_name}-#{channel}", :api_key => api_key, :flush => 1}
21
+
22
+ http = Curl.post @ezcomet_write_url, data
23
+ ret = JSON.parse http.body_str
24
+
25
+ return false if 'ok' != ret['code']
26
+ ret['code']
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,3 @@
1
+ module Ezcomet
2
+ VERSION = "0.0.1"
3
+ end
data/test.sh ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ ruby -Ilib ./bin/ezcomet_test
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ezcomet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jin-Sih Lin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-12 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: EZComet is the best realtime web message pushing solution. And this is
15
+ ezcomet ruby sdk.
16
+ email:
17
+ - linpct@gmail.com
18
+ executables:
19
+ - ezcomet_test
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - .gitignore
24
+ - Gemfile
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - bin/ezcomet_test
29
+ - ezcomet.gemspec
30
+ - lib/ezcomet.rb
31
+ - lib/ezcomet/version.rb
32
+ - test.sh
33
+ homepage: https://github.com/pct/ezcomet
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 1.8.23
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Ezcomet Ruby SDK
57
+ test_files: []