ice_rocket 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ice_rocket.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Chris Oliver
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,58 @@
1
+ # IceRocket
2
+
3
+ A rubygem for accessing the IceRocket API written by Chris Oliver
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ice_rocket', '~> 0.0.2'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ice_rocket
18
+
19
+ ## Usage
20
+
21
+ Using the IceRocket API is as simple as creating a search object and
22
+ then fetching pages of results:
23
+
24
+ search = IceRocket::Search.new("new york", :sourceid => "YOURSOURCEID", :dl => Date.today - 2, :dh => Date.today, :per_page => 50)
25
+ results = search.fetch :page => 3
26
+
27
+ results["rss"]["channel"]["totalResults"] # 13760
28
+ results["rss"]["channel"]["startIndex"] # 101 = (page * per_page) + 1
29
+ results["rss"]["channel"]["item"].length # 50
30
+
31
+ There are a number of parameters and more readable equivalents that you
32
+ can use with the Search object:
33
+
34
+ :sourceid - Your source ID key
35
+ :dh or :date_high - Upper limit of the date filter
36
+ :dl or :date_low - Lower limit of the date filter
37
+ :lng or :language - Language ("en", "de", etc)
38
+ :n or :per_page - Number of items per page. Must be less than or equal to 50
39
+
40
+ search = IceRocket::Search.new("new york", :sourceid => "YOURSOURCEID", :dl => Date.today - 2, :dh => Date.today, :per_page => 50)
41
+
42
+ The fetch method also takes the following:
43
+
44
+ :p or :page - The page number to retrieve
45
+
46
+ results = search.fetch :page => 3
47
+
48
+ If you would like to add debugging messages to IceRocket:
49
+
50
+ IceRocket::Search.debug_output $stderr
51
+
52
+ ## Contributing
53
+
54
+ 1. Fork it
55
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
56
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
57
+ 4. Push to the branch (`git push origin my-new-feature`)
58
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/ice_rocket/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Chris Oliver"]
6
+ gem.email = ["excid3@gmail.com"]
7
+ gem.description = %q{A Rubygem for the IceRocket API}
8
+ gem.summary = %q{A Rubygem for the IceRocket API}
9
+ gem.homepage = "https://github.com/excid3/ice_rocket"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "ice_rocket"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = IceRocket::VERSION
17
+
18
+ gem.add_dependency 'httparty', '~> 0.8.1'
19
+ end
@@ -0,0 +1,39 @@
1
+ require "ice_rocket/version"
2
+ require "httparty"
3
+
4
+ module IceRocket
5
+ class Search
6
+ include HTTParty
7
+ #debug_output $stderr
8
+
9
+ base_uri 'www.icerocket.com'
10
+ default_params :api => '1'
11
+
12
+ attr_accessor :options
13
+
14
+ def initialize(search_term, options={})
15
+ opts = {
16
+ :q => search_term,
17
+ :dh => options[:dh] || options[:date_high],
18
+ :dl => options[:dl] || options[:date_low],
19
+ :lng => options[:lng] || options[:language],
20
+ :n => options[:n] || options[:per_page] || 10,
21
+ :sourceid => options[:sourceid]
22
+ }
23
+
24
+ opts[:dh] = opts[:dh].strftime("%m/%d/%Y") if opts[:dh]
25
+ opts[:dl] = opts[:dl].strftime("%m/%d/%Y") if opts[:dl]
26
+
27
+ self.options = opts
28
+ end
29
+
30
+ def fetch(options={})
31
+ self.class.get('/search', params(options))
32
+ end
33
+
34
+ def params(options={})
35
+ { :query => self.options.merge( :p => options[:p] || options[:page] || 1 ) }
36
+ end
37
+ end
38
+ end
39
+
@@ -0,0 +1,3 @@
1
+ module IceRocket
2
+ VERSION = "0.0.3"
3
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ice_rocket
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Chris Oliver
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.8.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.1
30
+ description: A Rubygem for the IceRocket API
31
+ email:
32
+ - excid3@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - ice_rocket.gemspec
43
+ - lib/ice_rocket.rb
44
+ - lib/ice_rocket/version.rb
45
+ homepage: https://github.com/excid3/ice_rocket
46
+ licenses: []
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 1.8.24
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: A Rubygem for the IceRocket API
69
+ test_files: []