i_heart_quotes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format nested
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@iheartquotes
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - ruby-head
5
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :gemcutter
2
+
3
+ gemspec
4
+
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # i_heart_quots ![Travis Status](https://secure.travis-ci.org/robertodecurnex/i_heart_quotes.png?branch=master) ![Dependecies Status](https://gemnasium.com/robertodecurnex/i_heart_quotes.png)
2
+
3
+ I <3 Quotes Client
4
+
5
+ ## Overview
6
+
7
+ This is a ruby client to interact with the [I <3 Quotes](http://iheartquotes.com) [API](http://iheartquotes.com/api).
8
+
9
+ (Working on Ruby 1.9.X - Let me know if you need the 1.8.X version)
10
+
11
+ ## Authors
12
+
13
+ Roberto Decurnex (nex.development@gmail.com)
14
+
15
+ ## Install
16
+
17
+ If you are using Bundler you can easily add the following line to your Gemfile:
18
+
19
+ gem 'i_heart_quotes'
20
+
21
+ Or you can just install it as a ruby gem by running:
22
+
23
+ $ gem install i_heart_quotes
24
+
25
+ ## Download
26
+
27
+ You can also clone the project with Git by running:
28
+ $ git clone git://github.com/robertodecurnex/rack-jsonp-middlewarei
29
+
30
+ ## Usage Example
31
+
32
+ ### Getting a random quote
33
+
34
+ require 'i_heart_quotes'
35
+
36
+ fortune = IHeartQuotes::Client.random
37
+
38
+ fortune.quote #=> "One's never alone with a rubber duck."
39
+
40
+ fortune.source #=> "hitchhiker"
41
+
42
+ fortune.tags #=> ["hitchhiker"]
43
+
44
+ fortune.link #=> "http://iheartquotes.com/fortune/show/7934"
45
+
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ task :default => [:spec]
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'i_heart_quotes'
3
+ s.version = '0.1.0'
4
+ s.date = '2012-03-06'
5
+ s.summary = 'I <3 Quotes Client'
6
+ s.authors = ['Roberto Decurnex']
7
+ s.email = 'nex.development@gmail.com'
8
+ s.homepage = 'http://github.com/robertodecurnex/i_heart_quotes'
9
+
10
+ s.platform = Gem::Platform::RUBY
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
14
+ s.require_paths = ['lib']
15
+
16
+ s.add_development_dependency 'rspec'
17
+ s.add_development_dependency 'rake'
18
+
19
+ s.add_runtime_dependency 'httparty'
20
+ end
21
+
data/lib/fortune.rb ADDED
@@ -0,0 +1,6 @@
1
+ class Fortune #:nodoc
2
+
3
+ # Fortune Class Definition - Quik patch to prevent the JSON parser to blow up when trying to get_const('Fortune')
4
+
5
+ end
6
+
@@ -0,0 +1,21 @@
1
+ module IHeartQuotes
2
+
3
+ # I <3 Quotes Client
4
+ class Client
5
+
6
+ # Random call API path
7
+ RANDOM_PATH = '/api/v1/random?format=json'
8
+
9
+ include HTTParty
10
+
11
+ self.base_uri 'http://iheartquotes.com'
12
+ self.format :json
13
+
14
+ def self.random
15
+ return Fortune.new(self.get(RANDOM_PATH))
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
@@ -0,0 +1,28 @@
1
+ module IHeartQuotes
2
+
3
+ # Fortune (Quote) Representation
4
+ class Fortune
5
+
6
+ # Quote Body
7
+ attr_reader :quote
8
+
9
+ # Related Tags
10
+ attr_reader :tags
11
+
12
+ # Link to the 'I <3 Quotes' Quote Page
13
+ attr_reader :link
14
+
15
+ # Where the quote comes from
16
+ attr_reader :source
17
+
18
+ def initialize(params={})
19
+ @tags = params['tags']
20
+ @quote = params['quote']
21
+ @link = params['link']
22
+ @source = params['source']
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
@@ -0,0 +1,9 @@
1
+ require 'httparty'
2
+
3
+ require_relative 'i_heart_quotes/fortune'
4
+ require_relative 'i_heart_quotes/client'
5
+
6
+ module IHeartQuotes
7
+
8
+ end
9
+
@@ -0,0 +1,9 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe IHeartQuotes::Client do
4
+
5
+ it 'should return a random Fortune when requested' do
6
+ IHeartQuotes::Client.random.should be_an_instance_of IHeartQuotes::Fortune
7
+ end
8
+
9
+ end
@@ -0,0 +1,29 @@
1
+ describe IHeartQuotes::Fortune do
2
+
3
+ before :all do
4
+ @fortune = IHeartQuotes::Client.random
5
+ end
6
+
7
+ it 'should respond to quote with the quote body as string' do
8
+ @fortune.quote.should be_an_instance_of String
9
+ @fortune.quote.should_not be_empty
10
+ end
11
+
12
+ it 'should respond to link with an url to the fortune page' do
13
+ @fortune.link.should =~ /http:\/\/iheartquotes\.com\/fortune\/show\/\d+/
14
+ end
15
+
16
+ it 'should respond to tags with an array of tags' do
17
+ @fortune.tags.should be_an_instance_of Array
18
+ @fortune.tags.each do |tag|
19
+ tag.should be_an_instance_of String
20
+ tag.should_not be_empty
21
+ end
22
+ end
23
+
24
+ it 'should respond to source with the quote source' do
25
+ @fortune.source.should be_an_instance_of String
26
+ @fortune.source.should_not be_empty
27
+ end
28
+
29
+ end
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'i_heart_quotes'
4
+ require 'fortune'
5
+
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i_heart_quotes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Roberto Decurnex
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-06 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &22770300 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *22770300
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &22769860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *22769860
36
+ - !ruby/object:Gem::Dependency
37
+ name: httparty
38
+ requirement: &22805000 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *22805000
47
+ description:
48
+ email: nex.development@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .rspec
55
+ - .rvmrc
56
+ - .travis.yml
57
+ - Gemfile
58
+ - README.md
59
+ - Rakefile
60
+ - i_heart_quotes.gemspec
61
+ - lib/fortune.rb
62
+ - lib/i_heart_quotes.rb
63
+ - lib/i_heart_quotes/client.rb
64
+ - lib/i_heart_quotes/fortune.rb
65
+ - spec/i_heart_quotes/client_spec.rb
66
+ - spec/i_heart_quotes/fortune_spec.rb
67
+ - spec/spec_helper.rb
68
+ homepage: http://github.com/robertodecurnex/i_heart_quotes
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 1.8.15
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: I <3 Quotes Client
92
+ test_files: []