www-tvtropes 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ .*.swp
2
+ *.gem
3
+ .bundle
4
+ Gemfile.lock
5
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in www-tvtropes.gemspec
4
+ gemspec
data/HISTORY ADDED
@@ -0,0 +1,6 @@
1
+ 2011-04-07 v0.0.2
2
+ - Clean up user error(s) in v0.0.1.
3
+
4
+ 2011-04-07 v0.0.1
5
+ - Initial prototype release.
6
+
@@ -0,0 +1,24 @@
1
+ = WWW::TvTropes - Interact with tvtropes.org
2
+
3
+ == Usage
4
+
5
+ require 'www-tvtropes'
6
+
7
+ WWW::TvTropes.new do |tropes|
8
+ # Return "Characters As Device" tropes
9
+ tropes.characters_as_device.each_pair do |name, url|
10
+ puts "%-40s\t%s" % [ name, url ]
11
+ end
12
+ end
13
+
14
+ == To Do
15
+
16
+ * Tests!
17
+ * Random tropes!
18
+ * More tropes!
19
+ * Binary
20
+
21
+ == See Also
22
+
23
+ http://tvtropes.org/pmwiki/pmwiki.php/Main/HomePage
24
+
@@ -0,0 +1,6 @@
1
+ require 'bundler'
2
+ require 'rdoc-readme/rake_task'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+ RDoc::Readme::RakeTask.new 'lib/www-tvtropes.rb', 'README.rdoc'
6
+
@@ -0,0 +1,59 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
4
+ module WWW # :nodoc:
5
+
6
+ #
7
+ # = WWW::TvTropes - Interact with tvtropes.org
8
+ #
9
+ # == Usage
10
+ #
11
+ # require 'www-tvtropes'
12
+ #
13
+ # WWW::TvTropes.new do |tropes|
14
+ # # Return "Characters As Device" tropes
15
+ # tropes.characters_as_device.each_pair do |name, url|
16
+ # puts "%-40s\t%s" % [ name, url ]
17
+ # end
18
+ # end
19
+ #
20
+ # == To Do
21
+ #
22
+ # * Tests!
23
+ # * Random tropes!
24
+ # * More tropes!
25
+ # * Binary
26
+ #
27
+ # == See Also
28
+ #
29
+ # http://tvtropes.org/pmwiki/pmwiki.php/Main/HomePage
30
+ #
31
+ class TvTropes
32
+
33
+ def initialize
34
+ yield self if block_given?
35
+ end
36
+
37
+ # Returns hash (name => url) of "Characters As Device" tropes from http://tvtropes.org/pmwiki/pmwiki.php/Main/CharactersAsDevice.
38
+ def characters_as_device
39
+ tropes = {}
40
+ doc = Nokogiri::HTML( open( 'http://tvtropes.org/pmwiki/pmwiki.php/Main/CharactersAsDevice'), nil, 'UTF-8' )
41
+ # XXX doc = Nokogiri::HTML( open( './CharactersAsDevice'), nil, 'UTF-8' )
42
+ doc.css('h2 + ul > li > a').each do |link|
43
+ tropes[ link.content ] = link['href']
44
+ end
45
+ return tropes
46
+ end
47
+
48
+ end # class TvTropes
49
+
50
+ end # module WWW
51
+
52
+ if __FILE__ == $0
53
+ WWW::TvTropes.new do |tropes|
54
+ tropes.characters_as_device.each_pair do |name, url|
55
+ puts "%-40s\t%s" % [ name, url ]
56
+ end
57
+ end
58
+ end
59
+
@@ -0,0 +1,5 @@
1
+ module WWW # :nodoc:
2
+ class TvTropes # :nodoc:
3
+ VERSION = '0.0.2'
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "www-tvtropes/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "www-tvtropes"
7
+ s.version = WWW::TvTropes::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Blair Christensen']
10
+ s.email = ['blair.christensen@gmail.com']
11
+ s.homepage = ""
12
+ s.summary = %q{Interact with tvtropes.org}
13
+ s.description = %q{Interact with tvtropes.org}
14
+
15
+ s.rubyforge_project = "www-tvtropes"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency( %q<nokogiri>, [ '>=1.4.4' ] )
23
+
24
+ # s.add_development_dependency( %q<rspec>, [ ">=2.5.0" ] )
25
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: www-tvtropes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Blair Christensen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-04-07 00:00:00.000000000 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: nokogiri
17
+ requirement: &2157511520 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 1.4.4
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *2157511520
26
+ description: Interact with tvtropes.org
27
+ email:
28
+ - blair.christensen@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - HISTORY
36
+ - README.rdoc
37
+ - Rakefile
38
+ - lib/www-tvtropes.rb
39
+ - lib/www-tvtropes/version.rb
40
+ - www-tvtropes.gemspec
41
+ has_rdoc: true
42
+ homepage: ''
43
+ licenses: []
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project: www-tvtropes
62
+ rubygems_version: 1.6.0
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Interact with tvtropes.org
66
+ test_files: []