ricky-quote 0.0.5 → 0.0.6
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 +4 -4
- data/Gemfile.lock +1 -1
- data/config.ru +3 -0
- data/lib/rack/quote_importer.rb +15 -0
- data/lib/rack/ricky_quote.rb +20 -31
- data/lib/rack/version.rb +1 -1
- data/lib/rack_ricky_quote.rb +1 -1
- data/spec/ricky_quote_spec.rb +7 -45
- metadata +3 -2
- data/lib/rack/rickygervais.txt +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbc304c437e78d2ea1a04ebed4ff0df07a6b3eb8
|
4
|
+
data.tar.gz: 083e08b466ea14db63f690f8a7840bca1a33742c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1732b3c0ef2b096cb64e0f933c68eddbeb28bb08ba3fa0d323d040e62044cf33cdacd9ed55466599c65537c7a2dc4f2b44ea34ad67912eac60c224e04536c64a
|
7
|
+
data.tar.gz: b6f2f24840d10e91ef527bb9f875e7a8e38316d5e9bd4a719610418d261f89944f80c9f42e35376ae09a3b46d6d58af961736becc8184ce9921396ae3b9996c3
|
data/Gemfile.lock
CHANGED
data/config.ru
ADDED
data/lib/rack/ricky_quote.rb
CHANGED
@@ -1,44 +1,33 @@
|
|
1
1
|
module Rack
|
2
2
|
class Quote
|
3
|
-
attr_reader :app, :env, :options
|
3
|
+
# attr_reader :app, :env, :options
|
4
|
+
HEADERS = {'Content-Type' => 'text/plain'}
|
4
5
|
|
5
|
-
def initialize(app, options={})
|
6
|
-
@app = app
|
7
|
-
@
|
8
|
-
@phrases = []
|
6
|
+
def initialize(app=nil, options={})
|
7
|
+
@app = app
|
8
|
+
@phrases = QuoteImporter.new
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(env)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
@env = env
|
18
|
-
status, headers, @response = @app.call(@env)
|
19
|
-
@response.write "Something" if @env['PATH_INFO'] == '/quote'
|
20
|
-
after || @response
|
21
|
-
end
|
22
|
-
|
23
|
-
def before
|
24
|
-
end
|
12
|
+
if env['PATH_INFO'] == '/quote'
|
13
|
+
quote = @phrases.random
|
14
|
+
else
|
15
|
+
quote = ""
|
16
|
+
end
|
25
17
|
|
26
|
-
|
27
|
-
|
18
|
+
if @app
|
19
|
+
status, headers, response = @app.call(env)
|
20
|
+
else
|
21
|
+
status, headers, response = 200, {"Content-Type" => "text/plain"}, []
|
22
|
+
end
|
28
23
|
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
response_body = ""
|
25
|
+
response.each { |res| response_body += res }
|
26
|
+
response_body += quote
|
32
27
|
|
33
|
-
|
34
|
-
Rack::Response.new(@response)
|
35
|
-
end
|
28
|
+
headers["Content-Length"] = response_body.length.to_s
|
36
29
|
|
37
|
-
|
38
|
-
::File.open("rickygervais.txt").each_line do |line|
|
39
|
-
@phrases << line.chomp
|
40
|
-
end
|
41
|
-
@phrases.shuffle.first
|
30
|
+
[status, headers, [response_body]]
|
42
31
|
end
|
43
32
|
end
|
44
33
|
end
|
data/lib/rack/version.rb
CHANGED
data/lib/rack_ricky_quote.rb
CHANGED
data/spec/ricky_quote_spec.rb
CHANGED
@@ -2,55 +2,17 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Rack::Quote do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
before do
|
9
|
-
subject.stub(:dup).and_return(subject)
|
10
|
-
end
|
11
|
-
|
5
|
+
ricky_quote = Rack::Quote.new
|
6
|
+
quote = QuoteImporter.new.random
|
12
7
|
|
13
8
|
it "responds to call method" do
|
14
|
-
expect(
|
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
|
9
|
+
expect(ricky_quote).to respond_to(:call)
|
28
10
|
end
|
29
11
|
|
30
|
-
it "
|
31
|
-
|
12
|
+
it "returns a quote string" do
|
13
|
+
env = {"REQUEST_METHOD" => "GET", "PATH_INFO" => "/quote"}
|
14
|
+
result = ricky_quote.call(env)
|
15
|
+
expect(result[2][0]).to be_an_instance_of String
|
32
16
|
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
17
|
|
56
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ricky-quote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Kerr
|
@@ -66,9 +66,10 @@ files:
|
|
66
66
|
- Gemfile.lock
|
67
67
|
- LICENSE
|
68
68
|
- README.md
|
69
|
+
- config.ru
|
69
70
|
- fixtures/rickygervais.txt
|
71
|
+
- lib/rack/quote_importer.rb
|
70
72
|
- lib/rack/ricky_quote.rb
|
71
|
-
- lib/rack/rickygervais.txt
|
72
73
|
- lib/rack/version.rb
|
73
74
|
- lib/rack_ricky_quote.rb
|
74
75
|
- ricky-quote.gemspec
|
data/lib/rack/rickygervais.txt
DELETED
@@ -1,44 +0,0 @@
|
|
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.
|