wikipedia-client 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -40,7 +40,18 @@ page.images
40
40
 
41
41
  page.image_urls
42
42
 
43
- => ["http://upload.wikimedia.org/wikipedia/en/e/e1/Getting_Things_Done.jpg", ...]]</code></pre>
43
+ => ["http://upload.wikimedia.org/wikipedia/en/e/e1/Getting_Things_Done.jpg"]
44
+
45
+ page.image_descriptionurls
46
+ => ["http://en.wikipedia.org/wiki/File:Getting_Things_Done.jpg"]
47
+
48
+ page.coordinates
49
+
50
+ => [48.853, 2.3498, "", "earth"]
51
+
52
+ page.templates
53
+
54
+ => [..., "Template:About", ...]</code></pre>
44
55
 
45
56
  h2. Configuration
46
57
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.2.0
@@ -27,7 +27,7 @@ module Wikipedia
27
27
  def request_page( title, options = {} )
28
28
  request( {
29
29
  :action => "query",
30
- :prop => %w{ revisions links images categories coordinates },
30
+ :prop => %w{ revisions links images categories coordinates templates },
31
31
  :rvprop => "content",
32
32
  :titles => title
33
33
  }.merge( options ) )
@@ -48,17 +48,16 @@ module Wikipedia
48
48
  page['imageinfo'].first['url'] if page['imageinfo']
49
49
  end
50
50
 
51
+ def image_descriptionurl
52
+ page['imageinfo'].first['descriptionurl'] if page['imageinfo']
53
+ end
54
+
51
55
  def image_urls
52
- if list = images
53
- filtered = list.select {|i| i =~ /^file:.+\.(jpg|jpeg|png|gif)$/i && !i.include?("LinkFA-star") }
54
- filtered.map do |title|
55
- Wikipedia.find_image( title ).image_url
56
- end
57
- end
56
+ image_metadata.map {|img| img.image_url }
58
57
  end
59
58
 
60
- def image_descriptionurl
61
- page['imageinfo'].first['descriptionurl'] if page['imageinfo']
59
+ def image_descriptionurls
60
+ image_metadata.map {|img| img.image_descriptionurl }
62
61
  end
63
62
 
64
63
  def coordinates
@@ -69,6 +68,20 @@ module Wikipedia
69
68
  @data
70
69
  end
71
70
 
71
+ def image_metadata
72
+ unless @cached_image_metadata
73
+ if list = images
74
+ filtered = list.select {|i| i =~ /^file:.+\.(jpg|jpeg|png|gif)$/i && !i.include?("LinkFA-star") }
75
+ @cached_image_metadata = filtered.map {|title| Wikipedia.find_image(title) }
76
+ end
77
+ end
78
+ @cached_image_metadata || []
79
+ end
80
+
81
+ def templates
82
+ page['templates'].map {|c| c['title'] } if page['templates']
83
+ end
84
+
72
85
  def json
73
86
  @json
74
87
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "wikipedia-client"
8
- s.version = "1.1.2"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Cyril David", "Ken Pratt", "Mike Haugland"]
12
- s.date = "2013-06-26"
12
+ s.date = "2013-06-27"
13
13
  s.description = "Ruby client for the Wikipedia API"
14
14
  s.email = "mike.haugland@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wikipedia-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-06-26 00:00:00.000000000 Z
14
+ date: 2013-06-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: thoughtbot-shoulda