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 CHANGED
@@ -1,2 +1,3 @@
1
1
  Known words with bad markup for testing
2
2
  http://www.urbandictionary.com/define.php?term=minal
3
+ http://www.urbandictionary.com/define.php?term=ugly-hot
@@ -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("http://www.urbandictionary.com/random.php")
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.text?
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
@@ -1,3 +1,3 @@
1
1
  module Urban
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'nokogiri'
22
22
  s.add_dependency 'i18n'
23
23
  s.add_dependency 'activesupport'
24
+ s.add_development_dependency 'ruby-debug19'
24
25
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: urban
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
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