ricky-quote 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +28 -0
- data/LICENSE +21 -0
- data/README.md +62 -0
- data/fixtures/rickygervais.txt +44 -0
- data/lib/rack/ricky_quote.rb +44 -0
- data/lib/rack/version.rb +3 -0
- data/lib/rack_ricky_quote.rb +2 -0
- data/ricky-quote.gemspec +25 -0
- data/spec/ricky_quote_spec.rb +56 -0
- data/spec/spec_helper.rb +1 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9f5f2236771550cfdf5e3c3e56bc801579f5fa5e
|
4
|
+
data.tar.gz: 827d9c4e823c163ad78da1dbc3fff7c82eecfa5e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 400b62f908aaa22be0e1ef25434bfa7c6f4f4e1da8346377c2378864485b66edc5dae24c04bb88a2070faa3a844cac601c1c106c1e32829943b167a69fc02ffe
|
7
|
+
data.tar.gz: 60de301a9c74d1c7cc3e98f8c21c7beea5c2e82946337b6f4fe6cf112ffaa51ecf3a0ed00a0d64e6025de58094ab13ef0cff2202ef947571a7a11f261e0bb4db
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ricky-quote (0.0.1)
|
5
|
+
rack
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.2.5)
|
11
|
+
rack (1.5.2)
|
12
|
+
rake (10.3.2)
|
13
|
+
rspec (2.14.1)
|
14
|
+
rspec-core (~> 2.14.0)
|
15
|
+
rspec-expectations (~> 2.14.0)
|
16
|
+
rspec-mocks (~> 2.14.0)
|
17
|
+
rspec-core (2.14.8)
|
18
|
+
rspec-expectations (2.14.5)
|
19
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
20
|
+
rspec-mocks (2.14.6)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
ruby
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
rake
|
27
|
+
ricky-quote!
|
28
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Chad W Pry
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
Practice: Rack Middleware
|
2
|
+
=========================
|
3
|
+
|
4
|
+
A practice designed to learn more about Rack middleware and
|
5
|
+
[Ricky Gervais Quotes](http://www.rickygervaisquotes.com/).
|
6
|
+
|
7
|
+
|
8
|
+
### Goal
|
9
|
+
|
10
|
+
Rack is a minimal and modular interface for developing web applicatons.
|
11
|
+
Rack middleware is a extension that sits between an HTTP request and an
|
12
|
+
application, thus the middleware term. You goal is to create a Rack
|
13
|
+
middleware that serves random quotes. The middleware, when complete, can
|
14
|
+
be inserted into an existing application to provide a fun set of quotes.
|
15
|
+
A sample fixture has been added for quotes by
|
16
|
+
[Ricky Gervais](http://www.rickygervaisquotes.com/).
|
17
|
+
|
18
|
+
|
19
|
+
### Expectations
|
20
|
+
|
21
|
+
* Use Bundler for gem dependencies
|
22
|
+
* Adhere to the standards of Rack and middleware
|
23
|
+
* Code is tested with RSpec
|
24
|
+
* Quotes come from examples in fixtures directory
|
25
|
+
|
26
|
+
|
27
|
+
### Request/Response
|
28
|
+
|
29
|
+
Request: /quote
|
30
|
+
|
31
|
+
Response Body: -example quote-
|
32
|
+
|
33
|
+
Format: text/plain
|
34
|
+
|
35
|
+
|
36
|
+
### Testing
|
37
|
+
|
38
|
+
As mentioned, write all tests with the Rspec framework. A testing harness
|
39
|
+
should execute using the following command.
|
40
|
+
|
41
|
+
$ rspec spec
|
42
|
+
|
43
|
+
_Do not test with an HTTP web interface, only test the library methods
|
44
|
+
and how they would respond if embedded in a web application._
|
45
|
+
|
46
|
+
|
47
|
+
### Links / Dependencies
|
48
|
+
|
49
|
+
These links are provided as a helper to find information. These are not the
|
50
|
+
only sources, so look for more if they do not give a full explanation.
|
51
|
+
|
52
|
+
[Bundler](http://bundler.io/)
|
53
|
+
|
54
|
+
[Rack](http://rack.github.io/)
|
55
|
+
|
56
|
+
[RSpec](http://rspec.info/)
|
57
|
+
|
58
|
+
|
59
|
+
### Extra credit ideas
|
60
|
+
|
61
|
+
* Setup continuous integration with Magnum CI, Travis CI, or Semaphore
|
62
|
+
* Integrate quotes via an online API
|
@@ -0,0 +1,44 @@
|
|
1
|
+
Being on the edge isn’t as safe, but the view is better.
|
2
|
+
Beliefs don't change facts. Facts, if you're reasonable, should change your beliefs
|
3
|
+
I've never worked out what the moral of Humpty Dumpty is. I can only think of: Don't sit on a wall, if you're an egg.
|
4
|
+
Just because you're offended, doesn't mean you're right.
|
5
|
+
You won't burn in hell. But be nice anyway.
|
6
|
+
The only route to success is hard work. If you didn't work hard I don't think it counts as success.
|
7
|
+
On Karl: For a simple man, you retain an awful lot of knowledge. It's just all rubbish.
|
8
|
+
Some of you are really smart. You know who you are. Some of you are really thick. Unfortunately, you don't know who you are.
|
9
|
+
Piracy doesn't kill music, boy bands do.
|
10
|
+
Being an Atheist, do you say bless you when somebody sneezes? No. I say 'cover your mouth you dirty cunt'
|
11
|
+
Had an idea for celebrity big brother.Leave them in there for months and when they come out let them know it wasn't televised.
|
12
|
+
I pay full tax and I love it. I wouldn't be where I am today without free education & the NHS.
|
13
|
+
Thank you God for making me an Atheist.
|
14
|
+
I fucking love twitter now. I'm still not sure of the point, or how it will end, but its fun trying to work it out. Just like life really.
|
15
|
+
The word Mong means Downs syndrome about as much as the word Gay means happy.
|
16
|
+
Enjoy life. Have fun. Be kind. Have worth. Have friends. Be honest. Laugh. Die with dignity. Make the most of it. It's all we've got.
|
17
|
+
If you are threatened or offended by people disagreeing, challenging or even ridiculing your faith, your faith can't be that strong.
|
18
|
+
It seems to be true, particularly in middle America, that those most militant about using up fossil fuels, don't actually believe in fossils.
|
19
|
+
Whether you believe that life evolved over billions of years or God made everything, you can't justify torturing an animal for a shampoo.
|
20
|
+
There are good atheists and bad atheists. There are good believers and bad believers. A cunt is a cunt and no god has ever changed that.
|
21
|
+
Say what you want about the Amish....because they're not on Twitter.
|
22
|
+
Next time someone is critical of you, just consider their life, and smile quietly to yourself.
|
23
|
+
As a comedian, you have to decide whether to give the masses what they want, or whether to give them something much better.
|
24
|
+
Everyone has the right to believe in anything they want. And everyone else has the right to find it fucking ridiculous.
|
25
|
+
Got a proper job at 28. Gave it up to try comedy at 38. Decided to get fit and healthy at 48. It's never too late. But do it now.
|
26
|
+
Your critics want you to be as unhappy, unfulfilled and unimportant as they are. Let your happiness eat them up from inside.
|
27
|
+
Force your children to read The Bible. If they are smart and kind it will put them off religion for life.
|
28
|
+
I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens.
|
29
|
+
We have to stop this recent culture of people telling us they're offended and expecting us to give a fuck.
|
30
|
+
A Christian telling an atheist he is going to Hell is about as scary as a small child telling an adult they wont get any presents from Santa.
|
31
|
+
Your God is the best God. In fact, he's the only God. All other Gods are ridiculous, made up rubbish. Not yours though. Yours is real.
|
32
|
+
This 'Sandy' who's on TV all the time and is blowing the entire east coast, I assume she's a Kardashian right?
|
33
|
+
You have options. You can either continue to be miserable or you can just stop being angry at everyone and accept the way things are. Allow yourself to live.
|
34
|
+
I've never regretted turning money down. I don't do anything for the money. It bores me.
|
35
|
+
The truth doesn't hurt. Whatever it is, it doesn't hurt. It's better to know the truth.
|
36
|
+
It's going to be a night of partying and heavy drinking. Or as Charlie Sheen calls it: Breakfast.
|
37
|
+
Where there's a will - there's a relative!
|
38
|
+
People confuse the subject of the joke with the target of the joke, and they're very rarely the same.
|
39
|
+
Honour is a gift a man gives himself. You can be as good as anyone that ever lived. If you can read, you can learn everything that anyone ever learned. But you've got to want it.
|
40
|
+
There's no difference between fame and infamy now. There's a new school of professional famous people that don't do anything. They don't create anything.
|
41
|
+
People who criticise you have usually never achieved anywhere near what you have. Most of them would be too scared to even try. Keep going.
|
42
|
+
Saying 'Atheism is a belief system', is like saying 'not going skiing, is a hobby.'
|
43
|
+
The American version of The Office is better than the UK version. How does that make you feel? - Really fucking rich.
|
44
|
+
We Shouldn't even need the word 'atheism'. If people didn't invent ridiculous imaginary Gods, rational people wouldn't have to deny them.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Rack
|
2
|
+
class Quote
|
3
|
+
attr_reader :app, :env, :options
|
4
|
+
|
5
|
+
def initialize(app, options={})
|
6
|
+
@app = app
|
7
|
+
@options = options
|
8
|
+
@phrases = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
dup.call!(env)
|
13
|
+
end
|
14
|
+
|
15
|
+
def call!(env)
|
16
|
+
before
|
17
|
+
@env = env
|
18
|
+
status, headers, @response = @app.call(@env)
|
19
|
+
@response.write random_phrase if @env['PATH_INFO'] == '/quote'
|
20
|
+
after || @response
|
21
|
+
end
|
22
|
+
|
23
|
+
def before
|
24
|
+
end
|
25
|
+
|
26
|
+
def after
|
27
|
+
end
|
28
|
+
|
29
|
+
def request
|
30
|
+
Rack::Request.new(@env)
|
31
|
+
end
|
32
|
+
|
33
|
+
def response
|
34
|
+
Rack::Response.new(@response)
|
35
|
+
end
|
36
|
+
|
37
|
+
def random_phrase
|
38
|
+
::File.open("fixtures/rickygervais.txt").each_line do |line|
|
39
|
+
@phrases << line.chomp
|
40
|
+
end
|
41
|
+
@phrases.shuffle.first
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/rack/version.rb
ADDED
data/ricky-quote.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rack/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.authors = ["Dave Kerr", "Chad W Pry"]
|
8
|
+
gem.email = ["davek09@gmail.com, chad.pry@gmail.com"]
|
9
|
+
gem.description = %q{provides a simple endpoint for your rails app to deliver a fun set of quotes}
|
10
|
+
gem.summary = %q{provides a simple endpoint for your rails app to deliver a fun set of quotes}
|
11
|
+
gem.name = "ricky-quote"
|
12
|
+
gem.version = RickyQuote::VERSION
|
13
|
+
gem.date = '2014-09-16'
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.homepage = "https://github.com/davek09/practice-quote-middleware"
|
17
|
+
gem.license = 'MIT'
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
|
21
|
+
# deps
|
22
|
+
gem.add_development_dependency("rake")
|
23
|
+
gem.add_development_dependency("rspec")
|
24
|
+
gem.add_dependency('rack')
|
25
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rack::Quote do
|
4
|
+
|
5
|
+
subject { Rack::Quote.new(blank_app) }
|
6
|
+
let(:blank_app) { lambda{|env| [200, {}, 'Hi there.']} }
|
7
|
+
|
8
|
+
before do
|
9
|
+
subject.stub(:dup).and_return(subject)
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
it "responds to call method" do
|
14
|
+
expect(subject).to respond_to(:call)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "responds to app method" do
|
18
|
+
expect(subject).to respond_to(:app)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "responds to random_phrase method" do
|
22
|
+
expect(subject).to respond_to(:random_phrase)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should access the request" do
|
26
|
+
subject.call({})
|
27
|
+
expect(subject.request).to be_an_instance_of Rack::Request
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should call through to the app" do
|
31
|
+
expect(subject.call({})).to eq('Hi there.')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be able to access the response" do
|
35
|
+
subject.call({})
|
36
|
+
expect(subject.response).to be_an_instance_of Rack::Response
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should persist options passed at initialization" do
|
40
|
+
expect(Rack::Quote.new(blank_app, {:abc => true}).options[:abc]).to be_true
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'callbacks' do
|
44
|
+
it 'should call #before' do
|
45
|
+
expect(subject).to receive(:before)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should call #after' do
|
49
|
+
expect(subject).to receive(:after)
|
50
|
+
end
|
51
|
+
|
52
|
+
after{ subject.call!({}) }
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rack_ricky_quote'
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ricky-quote
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dave Kerr
|
8
|
+
- Chad W Pry
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rack
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
description: provides a simple endpoint for your rails app to deliver a fun set of
|
57
|
+
quotes
|
58
|
+
email:
|
59
|
+
- davek09@gmail.com, chad.pry@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE
|
68
|
+
- README.md
|
69
|
+
- fixtures/rickygervais.txt
|
70
|
+
- lib/rack/ricky_quote.rb
|
71
|
+
- lib/rack/version.rb
|
72
|
+
- lib/rack_ricky_quote.rb
|
73
|
+
- ricky-quote.gemspec
|
74
|
+
- spec/ricky_quote_spec.rb
|
75
|
+
- spec/spec_helper.rb
|
76
|
+
homepage: https://github.com/davek09/practice-quote-middleware
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.2.2
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: provides a simple endpoint for your rails app to deliver a fun set of quotes
|
100
|
+
test_files:
|
101
|
+
- spec/ricky_quote_spec.rb
|
102
|
+
- spec/spec_helper.rb
|