urban 0.0.3 → 0.0.4
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/README +1 -0
- data/lib/urban.rb +6 -6
- data/lib/urban/version.rb +1 -1
- data/urban.gemspec +1 -0
- metadata +12 -1
data/README
CHANGED
data/lib/urban.rb
CHANGED
@@ -6,23 +6,23 @@ require 'active_support/core_ext/string/inflections'
|
|
6
6
|
|
7
7
|
module Urban
|
8
8
|
def self.random
|
9
|
-
url = URI.encode(
|
9
|
+
url = URI.encode('http://www.urbandictionary.com/random.php')
|
10
10
|
doc = Nokogiri.HTML(open(url))
|
11
11
|
word = clean_text(doc.at_css('.word')).humanize
|
12
|
-
definition = clean_text(doc.at_css('.definition')).humanize
|
12
|
+
definition = clean_text(doc.at_css('.definition')).humanize.gsub(/\. \w/) { |char| char.upcase }
|
13
13
|
puts "#{word}: #{definition}"
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
def self.clean_text(node_set)
|
18
18
|
node_set.children.each do |node|
|
19
|
-
if node.
|
20
|
-
node.content = node.content.strip << ' '
|
21
|
-
else
|
19
|
+
if node.name == 'br'
|
22
20
|
node.remove
|
21
|
+
else
|
22
|
+
node.content = node.content.strip << ' '
|
23
23
|
end
|
24
24
|
end
|
25
|
-
return node_set.content.strip
|
25
|
+
return node_set.content.strip.gsub(/ \./, '.')
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
data/lib/urban/version.rb
CHANGED
data/urban.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: urban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tom Miller
|
@@ -46,6 +46,17 @@ dependencies:
|
|
46
46
|
version: "0"
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: ruby-debug19
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
49
60
|
description: A scraper for urban dictionary. It comes with a command line tool to get random definitions from urbandictionary.com.
|
50
61
|
email:
|
51
62
|
- jackerran@gmail.com
|