google_reader 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  Gemfile.lock
2
2
  *.xml
3
+
4
+ *.gem
data/README.textile CHANGED
@@ -30,6 +30,10 @@ p item.source
30
30
  p item.liking_users
31
31
  </code></pre>
32
32
 
33
+ h2. Ruby Library
34
+
35
+ google_reader's specifications are certified to run on MRI 1.9.2 and JRuby 1.6.0 (in 1.8 mode).
36
+
33
37
  h2. LICENSE
34
38
 
35
39
  (The MIT License)
@@ -21,5 +21,4 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency "nokogiri", "~> 1.4.4"
22
22
 
23
23
  s.add_development_dependency "rspec"
24
- s.add_development_dependency "ruby-debug19"
25
24
  end
@@ -39,7 +39,8 @@ module GoogleReader
39
39
  tracking-body-link-used).each do |suffix|
40
40
 
41
41
  method_name = suffix.gsub("-", "_") + "_items"
42
- define_method(method_name) do |count=20|
42
+ define_method(method_name) do |*args|
43
+ count = args.first || 20
43
44
  content = RestClient.get(STATE_URL + suffix + "?n=#{CGI.escape(count.to_s)}", headers)
44
45
  parse_atom_feed(content)
45
46
  end
@@ -13,7 +13,11 @@ module GoogleReader
13
13
 
14
14
  def original_id
15
15
  oid_node = id_node.attribute_with_ns("original-id", GOOGLE_ATOM_NAMESPACE)
16
- oid_node ? oid_node.text : id
16
+ return self.id if oid_node.nil?
17
+
18
+ # Cater to JRuby + libffi
19
+ return self.id if oid_node.respond_to?(:null?) && oid_node.null?
20
+ oid_node.text
17
21
  end
18
22
 
19
23
  def title
@@ -50,6 +54,9 @@ module GoogleReader
50
54
  return false unless node
51
55
  attr = node.attribute_with_ns("unknown-author", GOOGLE_ATOM_NAMESPACE)
52
56
  return true unless attr
57
+
58
+ # Cater to JRuby + libffi
59
+ return true if attr.respond_to?(:null?) && attr.null?
53
60
  attr.text != "true"
54
61
  end
55
62
 
@@ -59,10 +66,10 @@ module GoogleReader
59
66
 
60
67
  def source
61
68
  node = @entry.search("source").first
62
- OpenStruct.new(:title => unhtml(node.search("title").first.text),
63
- :href => node.search("link[rel=alternate]").first["href"],
64
- :id => node.search("id").first.text,
65
- :stream_id => node.attribute_with_ns("stream-id", GOOGLE_ATOM_NAMESPACE).text)
69
+ Source.new(:title => unhtml(node.search("title").first.text),
70
+ :href => node.search("link[rel=alternate]").first["href"],
71
+ :id => node.search("id").first.text,
72
+ :stream_id => node.attribute_with_ns("stream-id", GOOGLE_ATOM_NAMESPACE).text)
66
73
  end
67
74
 
68
75
  def liking_users
@@ -0,0 +1,11 @@
1
+ module GoogleReader
2
+ class Source
3
+ attr_reader :id, :name, :href, :title
4
+
5
+ def initialize(values)
6
+ %w(title href id stream_id).each do |attr|
7
+ instance_variable_set("@#{attr}", values.fetch(attr.to_sym))
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module GoogleReader
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/google_reader.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module GoogleReader
2
2
  autoload :Client, "google_reader/client"
3
+ autoload :Source, "google_reader/source"
3
4
  autoload :Entry, "google_reader/entry"
4
5
  end
data/spec/entry_spec.rb CHANGED
@@ -34,6 +34,7 @@ describe GoogleReader::Entry, "where the author is known, and the updated timest
34
34
  it { subject.href.should == "http://www.depesz.com/index.php/2011/04/27/find-cheapest-combination-of-rooms-in-hotels/" }
35
35
  it { subject.should have_known_author }
36
36
  it { subject.author.should == "depesz" }
37
+ it { subject.source.should_not be_nil }
37
38
  it { subject.source.id.should == "tag:google.com,2005:reader/feed/http://www.depesz.com/index.php/feed/" }
38
39
  it { subject.source.href == "http://www.depesz.com" }
39
40
  it { subject.id.should == "tag:google.com,2005:reader/item/d5dee0c34e012ddb" }
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,9 @@
1
1
  require "rubygems"
2
2
  require "nokogiri"
3
3
  require "google_reader"
4
+
5
+ begin
6
+ require "ruby-debug"
7
+ rescue LoadError
8
+ # NOP: ignore
9
+ end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_reader
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 21
4
5
  prerelease:
5
- version: 1.0.0
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 1
10
+ version: 1.0.1
6
11
  platform: ruby
7
12
  authors:
8
13
  - "Fran\xC3\xA7ois Beausoleil"
@@ -21,6 +26,11 @@ dependencies:
21
26
  requirements:
22
27
  - - ~>
23
28
  - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 6
33
+ - 1
24
34
  version: 1.6.1
25
35
  type: :runtime
26
36
  version_requirements: *id001
@@ -32,6 +42,11 @@ dependencies:
32
42
  requirements:
33
43
  - - ~>
34
44
  - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 1
48
+ - 4
49
+ - 4
35
50
  version: 1.4.4
36
51
  type: :runtime
37
52
  version_requirements: *id002
@@ -43,20 +58,12 @@ dependencies:
43
58
  requirements:
44
59
  - - ">="
45
60
  - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
46
64
  version: "0"
47
65
  type: :development
48
66
  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
60
67
  description: Access Google Reader in a quick and simple way, using plain Ruby.
61
68
  email:
62
69
  - francois@teksol.info
@@ -76,6 +83,7 @@ files:
76
83
  - lib/google_reader.rb
77
84
  - lib/google_reader/client.rb
78
85
  - lib/google_reader/entry.rb
86
+ - lib/google_reader/source.rb
79
87
  - lib/google_reader/version.rb
80
88
  - spec/client_spec.rb
81
89
  - spec/entry_spec.rb
@@ -98,12 +106,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
106
  requirements:
99
107
  - - ">="
100
108
  - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
101
112
  version: "0"
102
113
  required_rubygems_version: !ruby/object:Gem::Requirement
103
114
  none: false
104
115
  requirements:
105
116
  - - ">="
106
117
  - !ruby/object:Gem::Version
118
+ hash: 3
119
+ segments:
120
+ - 0
107
121
  version: "0"
108
122
  requirements: []
109
123