wikiquote 1.0.0
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.
- data/Rakefile +8 -0
- data/bin/wikiquote +5 -0
- data/lib/wikiquote.rb +19 -0
- data/test/test_wikiquote.rb +8 -0
- metadata +83 -0
data/Rakefile
ADDED
data/bin/wikiquote
ADDED
data/lib/wikiquote.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/evn ruby
|
|
2
|
+
require 'net/http'
|
|
3
|
+
require 'open-uri'
|
|
4
|
+
require 'nokogiri'
|
|
5
|
+
# The main wiki driver
|
|
6
|
+
class WikiQuote
|
|
7
|
+
# Get quote of the day from wikiquotes
|
|
8
|
+
#
|
|
9
|
+
# Example:
|
|
10
|
+
# >> WikiQuote.get()
|
|
11
|
+
# => "Ruby rocks"
|
|
12
|
+
def self.get()
|
|
13
|
+
# Gets the quote of the day
|
|
14
|
+
quote_url = 'http://en.wikiquote.org/wiki/Main_Page'
|
|
15
|
+
quote_selector = "td , #mw-content-text div div:nth-child(1)" # Hope this remians ;)
|
|
16
|
+
page = Nokogiri::HTML(open(quote_url).read)
|
|
17
|
+
page.css(quote_selector)[3].text
|
|
18
|
+
end
|
|
19
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: wikiquote
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 23
|
|
5
|
+
prerelease:
|
|
6
|
+
segments:
|
|
7
|
+
- 1
|
|
8
|
+
- 0
|
|
9
|
+
- 0
|
|
10
|
+
version: 1.0.0
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Hemanth.HM
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2012-05-20 00:00:00 Z
|
|
19
|
+
dependencies:
|
|
20
|
+
- !ruby/object:Gem::Dependency
|
|
21
|
+
name: nokogiri
|
|
22
|
+
prerelease: false
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
none: false
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
hash: 3
|
|
29
|
+
segments:
|
|
30
|
+
- 1
|
|
31
|
+
- 5
|
|
32
|
+
- 0
|
|
33
|
+
version: 1.5.0
|
|
34
|
+
type: :runtime
|
|
35
|
+
version_requirements: *id001
|
|
36
|
+
description: A simple gem to get Quote of the day from wikiquote.org
|
|
37
|
+
email: hemanth.hm@gmail.com
|
|
38
|
+
executables:
|
|
39
|
+
- wikiquote
|
|
40
|
+
extensions: []
|
|
41
|
+
|
|
42
|
+
extra_rdoc_files: []
|
|
43
|
+
|
|
44
|
+
files:
|
|
45
|
+
- Rakefile
|
|
46
|
+
- lib/wikiquote.rb
|
|
47
|
+
- bin/wikiquote
|
|
48
|
+
- test/test_wikiquote.rb
|
|
49
|
+
homepage: http://rubygems.org/gems/xkcd
|
|
50
|
+
licenses: []
|
|
51
|
+
|
|
52
|
+
post_install_message:
|
|
53
|
+
rdoc_options: []
|
|
54
|
+
|
|
55
|
+
require_paths:
|
|
56
|
+
- lib
|
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
|
+
none: false
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
hash: 3
|
|
63
|
+
segments:
|
|
64
|
+
- 0
|
|
65
|
+
version: "0"
|
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
|
+
none: false
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
hash: 3
|
|
72
|
+
segments:
|
|
73
|
+
- 0
|
|
74
|
+
version: "0"
|
|
75
|
+
requirements: []
|
|
76
|
+
|
|
77
|
+
rubyforge_project:
|
|
78
|
+
rubygems_version: 1.8.24
|
|
79
|
+
signing_key:
|
|
80
|
+
specification_version: 3
|
|
81
|
+
summary: Quote of the day from wikiquote.org
|
|
82
|
+
test_files:
|
|
83
|
+
- test/test_wikiquote.rb
|