track_tweets 0.0.3

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.
@@ -0,0 +1,20 @@
1
+ Copyright 2011 AIMBULANCE
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.
@@ -0,0 +1,28 @@
1
+ = Track tweets API
2
+
3
+ == Install
4
+
5
+ gem 'track_tweets'
6
+
7
+ == Configuration
8
+
9
+ TrackTweets.setup do |config|
10
+ config.username = 'demo'
11
+ config.password = 'demo'
12
+ config.format = :json
13
+ config.api_version = 'v1'
14
+ config.group_id = 'your group id'
15
+ end
16
+
17
+ == Usage
18
+
19
+ group = TrackTweets::Group.create(
20
+ :name => 'McDonals Euro Kids',
21
+ :timeout => 2 * 60 * 60, # 2 hours
22
+ :delay => 50 * 60) # 50 minutes
23
+
24
+
25
+ TrackTweets::Group.destroy(group.id)
26
+
27
+
28
+ Copyright (c) 2011 Aimbulance, released under the MIT license
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'rdoc/task'
5
+
6
+ require 'rake/testtask'
7
+
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.libs << 'lib'
10
+ t.libs << 'test'
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = false
13
+ end
14
+
15
+ task :default => :test
16
+
17
+ RDoc::Task.new do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'Track Tweets Client'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README.rdoc')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
@@ -0,0 +1,26 @@
1
+ module TrackTweets
2
+ autoload :Client, 'track_tweets/client'
3
+ autoload :Group, 'track_tweets/group'
4
+ autoload :TrackItem, 'track_tweets/track_item'
5
+
6
+ mattr_accessor :username
7
+ @@username = 'demo'
8
+
9
+ mattr_accessor :password
10
+ @@password = 'demo'
11
+
12
+ mattr_accessor :format
13
+ @@format = :json
14
+
15
+ mattr_accessor :api_version
16
+ @@api_version = 'v1'
17
+
18
+ mattr_accessor :group_id
19
+ @@group_id = nil
20
+
21
+ def self.setup
22
+ yield self
23
+ end
24
+ end
25
+
26
+ require 'track_tweets/version'
@@ -0,0 +1,36 @@
1
+ require "httparty"
2
+ require "ostruct"
3
+ require "json"
4
+
5
+ module TrackTweets
6
+ class Client < OpenStruct
7
+ include ::HTTParty
8
+
9
+ base_uri File.join("http://tracktweets.aimbulance.com", "api", TrackTweets.api_version)
10
+ basic_auth TrackTweets.username, TrackTweets.password
11
+ format TrackTweets.format
12
+
13
+ class << self
14
+
15
+ protected
16
+
17
+ def resource(response)
18
+ if response && [200, 201].include?(response.code)
19
+ body = post_parse(response.parsed_response)
20
+ new(body)
21
+ else
22
+ nil
23
+ end
24
+ end
25
+
26
+ def post_parse(body)
27
+ return body unless body.is_a?(String)
28
+
29
+ case format
30
+ when :json then JSON.parse(body)
31
+ when :xml then Nokogiri::XML.parse(body)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,25 @@
1
+ module TrackTweets
2
+ class Group < Client
3
+ class << self
4
+ def create(attributtes)
5
+ resource post("/groups.#{format}", :body => { :group => attributtes })
6
+ end
7
+
8
+ def all(options = {})
9
+ resource get("/groups.#{format}", :query => options)
10
+ end
11
+
12
+ def find(id, options = {})
13
+ resource get("/groups/#{id}.#{format}", :query => options)
14
+ end
15
+
16
+ def destroy(id)
17
+ resource delete("/groups/#{id}.#{format}")
18
+ end
19
+
20
+ def clear_track_tweets(id)
21
+ resource delete("/groups/#{id}/track_items/all.#{format}")
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module TrackTweets
2
+ class TrackItem < Client
3
+ class << self
4
+ def create(group_id, attributtes)
5
+ resource post("/groups/#{group_id}/track_items.#{format}", :body => { :track_item => attributtes })
6
+ end
7
+
8
+ def all(group_id, options = {})
9
+ resource get("/groups/#{group_id}/track_items.#{format}", :query => options)
10
+ end
11
+
12
+ def find(id, options = {})
13
+ resource get("/track_items/#{id}.#{format}", :query => options)
14
+ end
15
+
16
+ def destroy(id)
17
+ resource delete("/track_items/#{id}.#{format}")
18
+ end
19
+
20
+ def tweets(id, options = {})
21
+ resource get("/track_items/#{id}/tweets.#{format}", :query => options)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module TrackTweets
2
+ VERSION = '0.0.3'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: track_tweets
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
11
+ platform: ruby
12
+ authors:
13
+ - Igor Galeta
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-16 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: httparty
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 19
30
+ segments:
31
+ - 0
32
+ - 7
33
+ - 8
34
+ version: 0.7.8
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: json
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
+ - 1
48
+ - 5
49
+ - 3
50
+ version: 1.5.3
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: API for track_tweets service (monitoring tweet stats)
54
+ email: galeta.igor@gmail.com
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - README.rdoc
61
+ files:
62
+ - lib/track_tweets/group.rb
63
+ - lib/track_tweets/client.rb
64
+ - lib/track_tweets/version.rb
65
+ - lib/track_tweets/track_item.rb
66
+ - lib/track_tweets.rb
67
+ - MIT-LICENSE
68
+ - Rakefile
69
+ - README.rdoc
70
+ has_rdoc: true
71
+ homepage: https://github.com/galetahub/track_tweets_client
72
+ licenses: []
73
+
74
+ post_install_message:
75
+ rdoc_options: []
76
+
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ requirements: []
98
+
99
+ rubyforge_project: track_tweets
100
+ rubygems_version: 1.6.2
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: API for track_tweets service
104
+ test_files: []
105
+