quote 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.markdown +31 -0
  2. data/bin/quote +36 -0
  3. data/lib/quote.rb +31 -0
  4. data/lib/quotes.json +39 -0
  5. metadata +65 -0
@@ -0,0 +1,31 @@
1
+ ## Quotes ##
2
+
3
+ Maintain and quote your awesome quotes from movies, games and other sources from command line.
4
+
5
+ ## Usage ##
6
+
7
+ ### Quoting ###
8
+
9
+ To get a random quote:
10
+ <code>quote</code>
11
+
12
+ To search for a specific quote check usage:
13
+ <code>quote -h</code>
14
+
15
+ ### Adding quote ###
16
+
17
+ WIP
18
+
19
+ ### Deleting quote(s) ###
20
+
21
+ WIP
22
+
23
+ ## To-do ##
24
+
25
+ * Full text searching
26
+ * Allowing to spawn quote server
27
+ * Move quotes from json to nosql store
28
+
29
+
30
+
31
+
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'quote'
4
+ require 'getoptlong'
5
+
6
+ USAGE = <<-EOU
7
+ To get a random quote type: #{'quote'.green}\nOr search for a random quote using one or many of following criteria:
8
+ #{'quote --theme/-t <argument>'.green} to search for a match in themes (ex. 'movie')
9
+ #{'quote --quote/-q <argument>'.green} to search for a match in quote itself (ex. 'kick ass and chew gum')
10
+ #{'quote --context/-c <argument>'.green} to search for a match in context quote was originated (ex. 'pulp fiction')
11
+ #{'quote --source/-s <argument>'.green} to search for a match in originator of the quote (ex. 'the dude')
12
+ #{'quote --help/-h'.green} to see this message
13
+ EOU
14
+
15
+ opts = GetoptLong.new(['--help', '-h', GetoptLong::NO_ARGUMENT],
16
+ ['--source','-s', GetoptLong::REQUIRED_ARGUMENT],
17
+ ['--context','-c', GetoptLong::REQUIRED_ARGUMENT],
18
+ ['--quote','-q', GetoptLong::REQUIRED_ARGUMENT],
19
+ ['--theme','-t', GetoptLong::REQUIRED_ARGUMENT])
20
+ criteria = {}
21
+ begin
22
+ opts.each do |flag, arg|
23
+ if flag == '--help'
24
+ puts USAGE; exit(0)
25
+ else
26
+ criteria[flag.gsub('--','')] = arg
27
+ end
28
+ end
29
+ rescue GetoptLong::InvalidOption => e
30
+ puts "Please type quote -h for usage"
31
+ exit(0)
32
+ rescue GetoptLong::MissingArgument => e
33
+ puts "You do need to pass an argument for matching"
34
+ exit(0)
35
+ end
36
+ puts Quote.say(criteria)
@@ -0,0 +1,31 @@
1
+ require 'yajl'
2
+ require 'colored'
3
+ require 'ruby-debug'
4
+
5
+ module ArrayExtensions
6
+ def where(criteria ={})
7
+ result = self
8
+ criteria.each do |cr_key, cr_value|
9
+ result = result.select do |hash|
10
+ hash[cr_key].to_s.match(/#{cr_value}/i)
11
+ end
12
+ end
13
+ result
14
+ end
15
+ end
16
+ Array.send(:include, ArrayExtensions)
17
+
18
+ module Quote
19
+ def self.say(criteria = {})
20
+ quotes = Yajl::Parser.parse(File.new(File.dirname(__FILE__) + '/quotes.json'))
21
+ quote(random_select(quotes.where(criteria)))
22
+ end
23
+
24
+ def self.random_select(enumerable)
25
+ enumerable[rand(enumerable.size)]
26
+ end
27
+
28
+ def self.quote(entry)
29
+ "#{entry['theme']}: \"#{entry['quote'].green}\" - #{entry['source'].red}, #{entry['context'].red}."
30
+ end
31
+ end
@@ -0,0 +1,39 @@
1
+ [
2
+ {"source":"The Wolf","context":"Pulp Fiction","quote":"That's thirty minutes away. I'll be there in ten.","theme":"movies"},
3
+ {"source":"peasant","quote":"We found a witch, may we burn her?","context":"Warcraft III: Reign of Chaos","theme":"games"},
4
+ {"quote":"It's time to kick ass and chew bubblegum.","context":"Duke Nukem 3D","source":"Duke Nukem","theme":"games"},
5
+ {"quote":"The first rule of Fight Club is: you do not talk about Fight Club. The second rule of Fight Club is: you DO NOT talk about Fight Club.","context":"Fight Club","source":"Tyler Durden", "theme":"movies"},
6
+ {"quote":"Your 'best'? Losers always whine about their best. Winners go home and fuck the prom queen.","context":"The Rock",
7
+ "source":"John Mason","theme":"movies"},
8
+ {"quote":"See that thing on my belt? Grab it! Whatever you do, don’t let go.","context":"Batman", "source":"Batman","theme":"movies"},
9
+ {"quote":"My momma always said, ‘Life was like a box of chocolates. You never know what you’re gonna get.", "context":"Forrest Gump", "source":"Forrest Gump", "theme":"movies"},
10
+ {"quote":"Ray, next time someone asks you if you’re a god, you say YES!","context":"Ghostbusters","source":"Winston Zeddemore",
11
+ "theme":"movies"},
12
+ {"quote":"Well, I've been listening to my gut since I was 14 years old, and frankly speaking, I've come to the conclusion that my guts have shit for brains.","context":"High Fidelity","source":"Rob","theme":"movies"},
13
+ {"quote":"People are so stupid. I can't bear to live around them any more.","context":"Imaginary Heroes","source":"Tim Travis","theme":"movies"},
14
+ {"quote":"That's what I love about these high school girls, man. I get older, they stay the same age.","context":"Dazed and Confused","source":"Wooderson","theme":"movies"},
15
+ {"quote":"This is what happens when you fuck a stranger in the ass.","context":"The Big Lebowski","source":"Walter Sobchak","theme":"movies"},
16
+ {"quote":"They’ve done studies, you know. Sixty percent of the time, it works every time.","context":"Anchorman","source":"Brian Fantana","theme":"movies"},
17
+ {"quote":"This is so bad it’s gone past good and back to bad again.","context":"Ghost World","source":"Enid","theme":"movies"},
18
+ {"quote":"Go that way, really fast. If something gets in your way, turn.","context":"Better Off Dead","source":"Charles De Mar","theme":"movies"},
19
+ {"quote":"Put. That coffee. Down. Coffee's for closers only.","context":"Glengarry Glen Ross","source":"Blake","theme":"movies"},
20
+ {"quote":"Good? Bad? I'm the guy with the gun.","context":"Army of Darkness","source":"Ash","theme":"movies"},
21
+ {"quote":"AK-47, the very best there is. When you absolutely, positively got to kill every motherfucker in the room, accept no substitutes.","context":"Jackie Brown","source":"Ordell Robbie","theme":"movies"},
22
+ {"quote":"Are you gonna bark all day, little doggy, or are you gonna bite?","context":"Reservoir Dogs","source":"Mr. Blonde","theme":"movies"},
23
+ {"quote":"There are two types of people in the world - those with a gun, and those who dig. Now dig!","context":"The Good, the Bad, and the Ugly","source":"Blondie","theme":"movies"},
24
+ {"quote":"If you try to run, I've got six little friends and they can all run faster than you can.","context":"From Dusk Til Dawn","source":"Seth","theme":"movies"},
25
+ {"quote":"Sounds like you've had a hard life. Good thing it's over.","context":"The Condemned","source":"Jack Conrad","theme":"movies"},
26
+ {"quote":"Are you gonna do something? Or just stand there and bleed?","context":"Tombstone","source":"Wyatt Earp","theme":"movies"},
27
+ {"quote":"Ever notice how you come across somebody once in a while you shouldn't have f'ed with? That's me.","context":"Grand Torino","source":"Walt Kowalski","theme":"movies"},
28
+ {"quote":"I love the smell of napalm in the morning","context":"Apocalypse now","source":"Kilgore","theme":"movies"},
29
+ {"quote":"I could be the walrus. I'd still have to bum rides off people","context":"Ferris Bueller's Day Off","source":"Ferris","theme":"movies"},
30
+ {"quote":"You either die a hero, or live long enough to see yourself become the villain.","context":"The Dark Knight","source":"Harvey Dent","theme":"movies"},
31
+ {"quote":"If you hold back anything, I'll kill ya. If you bend the truth or I think you're bending the truth, I'll kill ya. If you forget anything, I'll kill ya. In fact, you're gonna have to work very hard to stay alive, Nick. Now, do you understand everything I've just said? 'Cause if you don't, I'll kill ya! Now, Mr Bubble and Squeak, you may enlighten me.","context":"Lock, Stock and Two Smoking Barrels","source":"Rory Breaker","theme":"movies"},
32
+ {"quote":"I do know your reputation. So I choose my words very carefully. You tell Harry to go fuck himself.","context":"Lock, Stock and Two Smoking Barrels","source":"JD","theme":"movies"},
33
+ {"quote":"You should never underestimate the predictability of stupidity.","context":"Snatch","source":"Bullet Tooth Tony","theme":"movies"},
34
+ {"quote":"In the quiet words of the Virgin Mary... come again? ","context":"Snatch","source":"Brick Top","theme":"movies"},
35
+ {"quote":" Yes, London. You know: fish, chips, cup 'o tea, bad food, worse weather, Mary fucking Poppins... LONDON. ","context":"Snatch","source":"Avi","theme":"movies"},
36
+ {"quote":"Heavy is good, heavy is reliable. If it doesn't work you can always hit them with it. ","context":"Snatch","source":"Boris 'The Blade' Yurinov","theme":"movies"},
37
+ {"quote":"Oh, I'm sorry, did I break your concentration? ","context":"Pulp Fiction","source":"Jules","theme":"movies"},
38
+ {"quote":" If I'm curt with you it's because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.","context":"Pulp Fiction","source":"The Wolf","theme":"movies"}
39
+ ]
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quote
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - tjbladez
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-09-07 00:00:00 -05:00
18
+ default_executable: bin/quote
19
+ dependencies: []
20
+
21
+ description: Awesome quotes - maintain them, get them conviniently from command line
22
+ email: tjbladez@gmail.com
23
+ executables:
24
+ - quote
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - bin/quote
31
+ - lib/quote.rb
32
+ - lib/quotes.json
33
+ - README.markdown
34
+ has_rdoc: true
35
+ homepage: http://github.com/tjbladez/quote
36
+ licenses: []
37
+
38
+ post_install_message: You are now ready to enjoy and maintain your quotes
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ segments:
48
+ - 0
49
+ version: "0"
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.3.6
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Awesome quotes from different sources
64
+ test_files: []
65
+