royw-tmdb 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,6 +11,8 @@ begin
11
11
  gem.authors = ["Roy Wright"]
12
12
 
13
13
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ gem.add_dependency('royw-roys_extensions','>= 0.0.2')
15
+ gem.add_dependency('royw-read_page_cache','>= 0.0.1')
14
16
  end
15
17
  rescue LoadError
16
18
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
@@ -46,3 +48,8 @@ Rake::RDocTask.new do |rdoc|
46
48
  rdoc.rdoc_files.include('lib/**/*.rb')
47
49
  end
48
50
 
51
+ desc "stalk github until gem is published"
52
+ task :stalk do
53
+ `gemstalk royw tmdb`
54
+ end
55
+
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 5
2
+ :patch: 6
3
3
  :major: 0
4
4
  :minor: 1
@@ -6,11 +6,11 @@ require 'open-uri'
6
6
  require 'date'
7
7
  require 'xmlsimple'
8
8
 
9
+ # royw gems on github
10
+ require 'roys_extensions'
11
+
12
+ # local files
9
13
  require 'tmdb/optional_logger'
10
14
  require 'tmdb/tmdb_movie'
11
15
  require 'tmdb/tmdb_image'
12
16
  require 'tmdb/tmdb_profile'
13
- require 'module_extensions'
14
- require 'string_extensions'
15
- require 'file_extensions'
16
- require 'object_extensions'
@@ -9,8 +9,8 @@ $samples_dir = File.dirname(__FILE__) + '/samples'
9
9
 
10
10
  TMPDIR = File.join(File.dirname(__FILE__), '../tmp')
11
11
 
12
- require 'cache_extensions'
13
- CacheExtensions.attach_to_read_page_classes($samples_dir)
12
+ require 'read_page_cache'
13
+ ReadPageCache.attach_to_classes($samples_dir)
14
14
 
15
15
  Spec::Runner.configure do |config|
16
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: royw-tmdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roy Wright
@@ -9,10 +9,29 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-20 00:00:00 -07:00
12
+ date: 2009-04-21 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: royw-roys_extensions
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: royw-read_page_cache
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.1
34
+ version:
16
35
  description:
17
36
  email: roy@wright.org
18
37
  executables: []
@@ -27,16 +46,11 @@ files:
27
46
  - README.rdoc
28
47
  - Rakefile
29
48
  - VERSION.yml
30
- - lib/file_extensions.rb
31
- - lib/module_extensions.rb
32
- - lib/object_extensions.rb
33
- - lib/string_extensions.rb
34
49
  - lib/tmdb.rb
35
50
  - lib/tmdb/optional_logger.rb
36
51
  - lib/tmdb/tmdb_image.rb
37
52
  - lib/tmdb/tmdb_movie.rb
38
53
  - lib/tmdb/tmdb_profile.rb
39
- - spec/cache_extensions.rb
40
54
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0060934&api_key=7a2f6eb9b6aa01651000f0a9324db835
41
55
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0465234&api_key=7a2f6eb9b6aa01651000f0a9324db835
42
56
  - spec/samples/www.themoviedb.org/image/backdrops/14621/National_Treasure_-_Book_Of_Secrets__XVID___2007_-fanart.jpg
@@ -71,7 +85,6 @@ signing_key:
71
85
  specification_version: 2
72
86
  summary: TODO
73
87
  test_files:
74
- - spec/cache_extensions.rb
75
88
  - spec/tmdb_profile_spec.rb
76
89
  - spec/spec_helper.rb
77
90
  - spec/tmdb_movie_spec.rb
@@ -1,18 +0,0 @@
1
- # == Synopsis
2
- # add a mkdirs method to the File class
3
- class File
4
- class << self
5
- my_extension("mkdirs") do
6
- ##
7
- # make directories including any missing in the path
8
- #
9
- # @param [String] dirspec the path to make sure exists
10
- def File.mkdirs(dirspec)
11
- unless File.exists?(dirspec)
12
- mkdirs(File.dirname(dirspec))
13
- Dir.mkdir(dirspec)
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,27 +0,0 @@
1
- ######################################################################
2
- # my extensions to Module. (taken from rake, named changed to not clash
3
- # when rake is used for this rails project.
4
- #
5
- class Module
6
- # Check for an existing method in the current class before extending. IF
7
- # the method already exists, then a warning is printed and the extension is
8
- # not added. Otherwise the block is yielded and any definitions in the
9
- # block will take effect.
10
- #
11
- # Usage:
12
- #
13
- # class String
14
- # rake_extension("xyz") do
15
- # def xyz
16
- # ...
17
- # end
18
- # end
19
- # end
20
- #
21
- def my_extension(method)
22
- unless instance_methods.include?(method.to_s) || instance_methods.include?(method.to_sym)
23
- yield
24
- end
25
- end
26
- end # module Module
27
-
@@ -1,24 +0,0 @@
1
- # == Synopsis
2
- # add a blank? method to all Objects
3
- class Object
4
- my_extension("blank?") do
5
- # return asserted if object is nil or empty
6
- def blank?
7
- result = nil?
8
- unless result
9
- if respond_to? 'empty?'
10
- if respond_to? 'strip'
11
- result = strip.empty?
12
- else
13
- if respond_to? 'compact'
14
- result = compact.empty?
15
- else
16
- result = empty?
17
- end
18
- end
19
- end
20
- end
21
- result
22
- end
23
- end
24
- end
@@ -1,40 +0,0 @@
1
- require 'cgi'
2
- require 'iconv'
3
-
4
- class String
5
- my_extension("unescape_html") do
6
- def unescape_html
7
- Iconv.conv("UTF-8", 'ISO-8859-1', CGI::unescapeHTML(self))
8
- end
9
- end
10
-
11
- # this handles unicode characters by converting each byte to "%XX"
12
- # where XX is the hex value
13
- my_extension("escape_unicode") do
14
- def escape_unicode
15
- self.each_byte.collect{|c| c.to_i > 127 ? "%#{c.to_i.to_s(16)}" : c.chr}.join('')
16
- end
17
- end
18
-
19
- my_extension("strip_tags") do
20
- def strip_tags
21
- gsub(/<\/?[^>]*>/, "")
22
- end
23
- end
24
-
25
- my_extension("ext") do
26
- # Replace the file extension with +newext+. If there is no extenson on
27
- # the string, append the new extension to the end. If the new extension
28
- # is not given, or is the empty string, remove any existing extension.
29
- #
30
- # +ext+ is a user added method for the String class.
31
- def ext(newext='')
32
- return self.dup if ['.', '..'].include? self
33
- if newext != ''
34
- newext = (newext =~ /^\./) ? newext : ("." + newext)
35
- end
36
- dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || self + newext
37
- end
38
- end
39
- end
40
-
@@ -1,53 +0,0 @@
1
-
2
- # override the classes' read_page method and replace with one
3
- # that will cache pages in spec/samples/{url}
4
-
5
- module CacheExtensions
6
- # == Synopsis
7
- # Attach the read_page and cache_file methods to the given
8
- # class (cls) and use the given directory for the cache files
9
- def self.attach_to(cls, directory='/tmp')
10
-
11
- # define the read_page(page) method on the given class: cls
12
- cls.send('define_method', "read_page") do |page|
13
- data = nil
14
- filespec = page.gsub(/^http:\//, directory).gsub(/\/$/, '.html')
15
- if File.exist?(filespec)
16
- data = open(filespec).read
17
- else
18
- data = open(page).read
19
- cache_file(page, data)
20
- end
21
- data
22
- end
23
-
24
- # define the cache_file(page, data) method on the given class: cls
25
- cls.send('define_method', "cache_file") do |page, data|
26
- begin
27
- filespec = page.gsub(/^http:\//, directory).gsub(/\/$/, '.html')
28
- unless File.exist?(filespec)
29
- puts "caching #{filespec}"
30
- File.mkdirs(File.dirname(filespec))
31
- File.open(filespec, 'w') { |f| f.puts data }
32
- end
33
- rescue Exception => eMsg
34
- puts eMsg.to_s
35
- end
36
- end
37
- end
38
-
39
- # == Synopsis
40
- # Find all classes that have a read_page instance method and
41
- # then overwrite that read_page method with one that handles
42
- # the caching. Use the given directory for the cache files.
43
- def self.attach_to_read_page_classes(directory='/tmp')
44
- ObjectSpace.each_object(Class) do |cls|
45
- if(cls.public_instance_methods(false).include?("read_page") ||
46
- cls.protected_instance_methods(false).include?("read_page") ||
47
- cls.private_instance_methods(false).include?("read_page"))
48
- CacheExtensions.attach_to(cls, directory)
49
- end
50
- end
51
- end
52
- end
53
-