douban-ruby 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,25 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- douban-ruby (0.0.9)
4
+ douban-ruby (0.0.10)
5
5
  oauth
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- diff-lcs (1.1.2)
10
+ diff-lcs (1.1.3)
11
+ json (1.6.5)
12
+ multi_json (1.1.0)
11
13
  oauth (0.4.5)
12
- rake (0.9.2)
13
- rcov (0.9.9)
14
- rdoc (3.8)
15
- rspec (2.6.0)
16
- rspec-core (~> 2.6.0)
17
- rspec-expectations (~> 2.6.0)
18
- rspec-mocks (~> 2.6.0)
19
- rspec-core (2.6.4)
20
- rspec-expectations (2.6.0)
21
- diff-lcs (~> 1.1.2)
22
- rspec-mocks (2.6.0)
14
+ rake (0.9.2.2)
15
+ rdoc (3.12)
16
+ json (~> 1.4)
17
+ rspec (2.9.0)
18
+ rspec-core (~> 2.9.0)
19
+ rspec-expectations (~> 2.9.0)
20
+ rspec-mocks (~> 2.9.0)
21
+ rspec-core (2.9.0)
22
+ rspec-expectations (2.9.0)
23
+ diff-lcs (~> 1.1.3)
24
+ rspec-mocks (2.9.0)
25
+ simplecov (0.6.1)
26
+ multi_json (~> 1.0)
27
+ simplecov-html (~> 0.5.3)
28
+ simplecov-html (0.5.3)
23
29
 
24
30
  PLATFORMS
25
31
  ruby
@@ -28,6 +34,6 @@ DEPENDENCIES
28
34
  bundler (>= 1.0.0)
29
35
  douban-ruby!
30
36
  rake
31
- rcov
32
37
  rdoc
33
38
  rspec (~> 2.0)
39
+ simplecov
@@ -1,3 +1,9 @@
1
+ === 0.0.10 / 2012-03-22
2
+ * Douban::Subject
3
+ * support multiple attribute (thx to huacnlee)
4
+ * attribute stores in array
5
+ * add #aka, #akas method.
6
+
1
7
  === 0.0.9 / 2011-07-13
2
8
  * Douban::Authorize
3
9
  * access_token, request_token support :as_hash argument.
@@ -35,9 +41,9 @@
35
41
 
36
42
  === 0.0.4 / 2010-07-03
37
43
  * Douban::Authorize
38
- * all create_* functions (except create_mail) will return an Object if
44
+ * all create_* functions (except create_mail) will return an Object if
39
45
  success, otherwise nil, in old version, it will return true or false.
40
- create_mail does not work like other functions, it's should be named
46
+ create_mail does not work like other functions, it's should be named
41
47
  as send_mail.
42
48
  * some refactors on the model classes.
43
49
 
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_development_dependency "bundler", ">= 1.0.0"
22
22
  s.add_development_dependency 'rspec', '~> 2.0'
23
23
  s.add_development_dependency 'rake'
24
- s.add_development_dependency 'rcov'
24
+ s.add_development_dependency 'simplecov'
25
25
  s.add_development_dependency 'rdoc'
26
26
 
27
27
  s.files = `git ls-files`.split("\n")
@@ -31,6 +31,7 @@ module Douban
31
31
  when nil then nil
32
32
  else REXML::Document.new(atom).root
33
33
  end
34
+ @doc = doc
34
35
 
35
36
  id=REXML::XPath.first(doc,"./id")
36
37
  @id=id.text if id
@@ -63,8 +64,9 @@ module Douban
63
64
  @link[link.attributes['rel']]=link.attributes['href']
64
65
  end
65
66
  REXML::XPath.each(doc,"./db:attribute") do |attribute|
66
- @attribute||={}
67
- @attribute[attribute.attributes['name']]=attribute.text
67
+ @attribute ||= {}
68
+ @attribute[attribute.attributes['name']] ||= []
69
+ @attribute[attribute.attributes['name']] << attribute.text
68
70
  end
69
71
  @rating={}
70
72
  rating=REXML::XPath.first(doc,"./gd:rating")
@@ -75,41 +77,59 @@ module Douban
75
77
  @rating['max']=rating.attributes['max']
76
78
  end
77
79
  end #initialize
78
-
80
+
79
81
  def subject_id
80
82
  /\/(\d+)$/.match(@id)[1].to_i rescue nil
81
- end
82
-
83
+ end
84
+
85
+ def akas(lang = nil)
86
+ if lang.nil?
87
+ @attribute["aka"]
88
+ else
89
+ res = []
90
+ REXML::XPath.each(@doc,"./db:attribute") do |attribute|
91
+ if attribute.attributes["name"] == 'aka' and attribute.attributes["lang"] == lang
92
+ res << attribute.text
93
+ end
94
+ end
95
+ res
96
+ end
97
+ end
98
+
99
+ def aka(lang)
100
+ akas(lang).first
101
+ end
102
+
83
103
  end # class Subject
84
-
104
+
85
105
  class Movie<Subject
86
106
  def initialize(atom)
87
107
  super(atom)
88
108
  end
89
-
109
+
90
110
  def imdb
91
- /(tt\d+)\/$/.match(@attribute["imdb"])[1] rescue nil
111
+ /(tt\d+)\/$/.match(@attribute["imdb"].first)[1] rescue nil
92
112
  end
93
113
  end
94
-
114
+
95
115
  class Book<Subject
96
116
  def initialize(atom)
97
117
  super(atom)
98
118
  end
99
-
119
+
100
120
  def isbn10
101
- @attribute["isbn10"] rescue nil
121
+ @attribute["isbn10"].first rescue nil
102
122
  end
103
-
123
+
104
124
  def isbn13
105
- @attribute["isbn13"] rescue nil
125
+ @attribute["isbn13"].first rescue nil
106
126
  end
107
-
127
+
108
128
  def isbn
109
129
  isbn13 ? isbn13 : isbn10
110
130
  end
111
131
  end
112
-
132
+
113
133
  class Music<Subject
114
134
  def initialize(atom)
115
135
  super(atom)
@@ -1,3 +1,3 @@
1
1
  module Douban
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
@@ -38,7 +38,7 @@ module Douban
38
38
  <gd:rating average="8.0" max="10" min="0" numRaters="50"/>
39
39
  </entry>}
40
40
  end
41
-
41
+
42
42
  it "should correct deserialize from string" do
43
43
  subject = Subject.new(@s)
44
44
  subject.id.should == "http://api.douban.com/book/subject/1088840"
@@ -46,22 +46,30 @@ module Douban
46
46
  subject.title.should == "无机化学(下)/高等学校教材"
47
47
  subject.category.should == {"term"=>"http://www.douban.com/2007#book", "scheme"=>"http://www.douban.com/2007#kind"}
48
48
  subject.author.class.should == Author
49
- subject.link.should == {"self"=>"http://api.douban.com/book/subject/1088840",
50
- "alternate"=>"http://book.douban.com/subject/1088840/",
51
- "image"=>"http://img2.douban.com/spic/s1075910.jpg",
49
+ subject.link.should == {"self"=>"http://api.douban.com/book/subject/1088840",
50
+ "alternate"=>"http://book.douban.com/subject/1088840/",
51
+ "image"=>"http://img2.douban.com/spic/s1075910.jpg",
52
52
  "collection"=>"http://api.douban.com/collection/266907549"}
53
53
  subject.summary.should == nil
54
- subject.attribute.should == {"pubdate"=>"2005-1-1", "price"=>"26.5", "isbn10"=>"7040048809", "title"=>"无机化学(下)/高等学校教\346\235\220", "author"=>"武汉大学、吉林大\345\255\246", "isbn13"=>"9787040048803", "publisher"=>"高等教育出版社",
55
- "pages"=>"1185", "binding"=>"平装"}
54
+ subject.attribute.should == {"pubdate"=>["2005-1-1"],
55
+ "price"=>["26.5"],
56
+ "isbn10"=>["7040048809"],
57
+ "title"=>["无机化学(下)/高等学校教\346\235\220"],
58
+ "author"=>["武汉大学、吉林大\345\255\246"],
59
+ "isbn13"=>["9787040048803"],
60
+ "publisher"=>["高等教育出版社"],
61
+ "pages"=>["1185"],
62
+ "binding"=>["平装"]
63
+ }
56
64
  subject.tag.size.should == 8
57
65
  subject.tag[0].class.should == Tag
58
66
  subject.rating.should == {"max"=>"10", "average"=>"8.0", "min"=>"0", "numRaters"=>"50"}
59
67
  end
60
-
68
+
61
69
  it "should support ==" do
62
70
  Subject.new(@s).should == Subject.new(@s)
63
71
  end
64
-
72
+
65
73
  it "should correct deserialize from REXML::Document" do
66
74
  Subject.new(REXML::Document.new(@s)).should == Subject.new(@s)
67
75
  end
@@ -69,16 +77,14 @@ module Douban
69
77
  it "should correct deserialize from REXML::Element" do
70
78
  Subject.new(REXML::Document.new(@s).root).should == Subject.new(@s)
71
79
  end
72
-
80
+
73
81
  context "book" do
74
- it "should support isbn" do
75
- book = Book.new(@s)
76
- book.isbn10.should == "7040048809"
77
- book.isbn13.should == "9787040048803"
78
- book.isbn.should == book.isbn13
79
- end
82
+ subject { Book.new(@s) }
83
+ its(:isbn10) { should == "7040048809" }
84
+ its(:isbn13) { should == "9787040048803" }
85
+ specify { subject.isbn.should == subject.isbn13 }
80
86
  end
81
-
87
+
82
88
  context "movie" do
83
89
  before do
84
90
  @s_movie = %Q{<?xml version="1.0" encoding="UTF-8"?>
@@ -114,7 +120,6 @@ module Douban
114
120
  <db:attribute name="cast">Don Rickles</db:attribute>
115
121
  <db:attribute name="cast">Michael Keaton</db:attribute>
116
122
  <db:attribute name="aka">反斗奇兵3</db:attribute>
117
- <db:attribute name="aka">玩具总动员3</db:attribute>
118
123
  <db:tag count="6515" name="动画"/>
119
124
  <db:tag count="4202" name="Pixar"/>
120
125
  <db:tag count="3054" name="美国"/>
@@ -126,12 +131,17 @@ module Douban
126
131
  <gd:rating average="9.1" max="10" min="0" numRaters="18675"/>
127
132
  </entry>}
128
133
  end
129
-
130
- it "should support imdb" do
131
- movie = Movie.new(@s_movie)
132
- movie.imdb.should == "tt0435761"
133
- end
134
+
135
+ subject { Movie.new(@s_movie) }
136
+ its(:title) { should == "Toy Story 3" }
137
+ its(:imdb) { should == "tt0435761" }
138
+ its(:akas) { should == ["玩具总动员3", "反斗奇兵3"] }
139
+ specify { subject.akas("zh_CN").should == ["玩具总动员3"] }
140
+ specify { subject.aka("zh_CN").should == "玩具总动员3" }
141
+ specify { subject.attribute["language"].should == ["英语","西班牙语"] }
142
+ specify { subject.attribute["pubdate"].should == ["2010-06-16 (中国大陆)"] }
143
+ specify { subject.attribute["director"].should == ["Lee Unkrich"] }
134
144
  end
135
145
  end
136
146
  end
137
-
147
+
metadata CHANGED
@@ -1,123 +1,93 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: douban-ruby
3
- version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 9
10
- version: 0.0.9
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.10
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - LI Daobing
14
9
  - Hoooopo
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2011-07-13 00:00:00 +08:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
13
+ date: 2012-03-22 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
23
16
  name: oauth
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &14140020 !ruby/object:Gem::Requirement
26
18
  none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
34
23
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: bundler
38
24
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *14140020
26
+ - !ruby/object:Gem::Dependency
27
+ name: bundler
28
+ requirement: &14139480 !ruby/object:Gem::Requirement
40
29
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 23
45
- segments:
46
- - 1
47
- - 0
48
- - 0
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
49
33
  version: 1.0.0
50
34
  type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: rspec
54
35
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *14139480
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ requirement: &14138980 !ruby/object:Gem::Requirement
56
40
  none: false
57
- requirements:
41
+ requirements:
58
42
  - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 2
63
- - 0
64
- version: "2.0"
43
+ - !ruby/object:Gem::Version
44
+ version: '2.0'
65
45
  type: :development
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: rake
69
46
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *14138980
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ requirement: &14138600 !ruby/object:Gem::Requirement
71
51
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
79
56
  type: :development
80
- version_requirements: *id004
81
- - !ruby/object:Gem::Dependency
82
- name: rcov
83
57
  prerelease: false
84
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *14138600
59
+ - !ruby/object:Gem::Dependency
60
+ name: simplecov
61
+ requirement: &14138140 !ruby/object:Gem::Requirement
85
62
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- hash: 3
90
- segments:
91
- - 0
92
- version: "0"
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
93
67
  type: :development
94
- version_requirements: *id005
95
- - !ruby/object:Gem::Dependency
96
- name: rdoc
97
68
  prerelease: false
98
- requirement: &id006 !ruby/object:Gem::Requirement
69
+ version_requirements: *14138140
70
+ - !ruby/object:Gem::Dependency
71
+ name: rdoc
72
+ requirement: &14137720 !ruby/object:Gem::Requirement
99
73
  none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- hash: 3
104
- segments:
105
- - 0
106
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
107
78
  type: :development
108
- version_requirements: *id006
109
- description: "Douban API reference: http://www.douban.com/service/apidoc/reference/"
110
- email:
79
+ prerelease: false
80
+ version_requirements: *14137720
81
+ description: ! 'Douban API reference: http://www.douban.com/service/apidoc/reference/'
82
+ email:
111
83
  - lidaobing@gmail.com
112
84
  - hoooopo@gmail.com
113
85
  executables: []
114
-
115
86
  extensions: []
116
-
117
- extra_rdoc_files:
87
+ extra_rdoc_files:
118
88
  - README.rdoc
119
89
  - History.rdoc
120
- files:
90
+ files:
121
91
  - .gitignore
122
92
  - .rspec
123
93
  - Gemfile
@@ -165,44 +135,32 @@ files:
165
135
  - spec/douban/tag_spec.rb
166
136
  - spec/douban_spec.rb
167
137
  - spec/spec_helper.rb
168
- has_rdoc: true
169
138
  homepage: http://rubygems.org/gems/douban-ruby
170
139
  licenses: []
171
-
172
140
  post_install_message:
173
- rdoc_options:
141
+ rdoc_options:
174
142
  - --main
175
143
  - README.rdoc
176
144
  - --charset
177
145
  - UTF-8
178
- require_paths:
146
+ require_paths:
179
147
  - lib
180
- required_ruby_version: !ruby/object:Gem::Requirement
148
+ required_ruby_version: !ruby/object:Gem::Requirement
181
149
  none: false
182
- requirements:
183
- - - ">="
184
- - !ruby/object:Gem::Version
185
- hash: 3
186
- segments:
187
- - 0
188
- version: "0"
189
- required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
155
  none: false
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- hash: 23
195
- segments:
196
- - 1
197
- - 3
198
- - 6
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
199
159
  version: 1.3.6
200
160
  requirements: []
201
-
202
161
  rubyforge_project: douban-ruby
203
- rubygems_version: 1.3.7
162
+ rubygems_version: 1.8.15
204
163
  signing_key:
205
164
  specification_version: 3
206
165
  summary: douban ruby client. including OAuth support.
207
166
  test_files: []
208
-