greader 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ v0.0.2 - Jun 03, 2011
2
+ ---------------------
3
+
4
+ Added contributions from Colin Gemmell
5
+ ([pythonandchips.net](http://pythonandchips.net),
6
+ [@pythonandchips](http://github.com/pythonandchips)).
7
+
8
+ ### Fixed:
9
+ * **Compatibility with 1.8.7 and JRuby**
10
+ * **Fix authentication problem**
11
+ * Fixed published time being invalid
12
+ * Fix feeds like Imgur which fails at getting Entry#feed
13
+ * Fix tests on a Mac
14
+
15
+ ### Added:
16
+ * Implement GReader#html_processors.
17
+ * Implement read/starred checks by for entries using Entry#read? and
18
+ Entry#starred?.
19
+ * A `ParseError` will now be thrown in the weird chance that Google Reader
20
+ JSON that the gem can't handle.
21
+
22
+ ### Changed:
23
+ * Refine the image fetching algo.
24
+
25
+ v0.0.1 - March 21, 2011
26
+ -----------------------
27
+
28
+ First release.
data/README.md CHANGED
@@ -12,3 +12,10 @@ Please read the {GReader} module documentation.
12
12
 
13
13
  [doc]: http://rubydoc.info/github/rstacruz/greader
14
14
  [api]: http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
15
+
16
+ ### Authors
17
+
18
+ Authored and maintained by Rico Sta. Cruz (github.com/rstacruz),
19
+ with contributions from:
20
+
21
+ * Colin Gemmell (pythonandchips.net)
@@ -53,7 +53,7 @@ require 'nokogiri' unless defined?(Nokogiri)
53
53
  #
54
54
  module GReader
55
55
  PREFIX = File.expand_path('../greader/', __FILE__)
56
- VERSION = "0.0.1"
56
+ VERSION = "0.0.2"
57
57
 
58
58
  autoload :Client, "#{PREFIX}/client"
59
59
  autoload :Entry, "#{PREFIX}/entry"
@@ -61,10 +61,8 @@ module GReader
61
61
  'Email' => options[:email],
62
62
  'Passwd' => options[:password],
63
63
  'source' => client_name
64
-
65
64
  m = /Auth=(.*)/i.match(response.to_s)
66
65
  @auth = m ? m[1] : nil
67
-
68
66
  true
69
67
  rescue RestClient::Forbidden
70
68
  false
@@ -87,13 +85,17 @@ module GReader
87
85
  def feeds
88
86
  @feeds ||= begin
89
87
  list = json_get('subscription/list')['subscriptions']
90
- list.inject({}) { |h, item| feed = Feed.new self, item; h[feed.to_param] = feed; h }
88
+ list.inject({}) do |h, item|
89
+ feed = Feed.new(self, item)
90
+ h[feed.to_param] = feed
91
+ h
92
+ end
91
93
  end
92
94
  @feeds.values.sort
93
95
  end
94
96
 
95
97
  def feed(what=nil)
96
- feeds && @feeds[what.to_s.gsub('/', '_')]
98
+ feeds && @feeds[slug(what)]
97
99
  end
98
100
 
99
101
  def tags
@@ -115,7 +117,7 @@ module GReader
115
117
  def client_name() "greader.rb/#{GReader.version}"; end
116
118
 
117
119
  def get(url, options={})
118
- request :get, url, params: options.merge('client' => client_name)
120
+ request :get, url, options.merge('client' => client_name)
119
121
  end
120
122
 
121
123
  def post(url, options={})
@@ -128,7 +130,6 @@ module GReader
128
130
 
129
131
  def request(meth, url, options={})
130
132
  url = API_URL + url
131
-
132
133
  if @auth
133
134
  auth_request meth, url, options
134
135
  elsif @oauth_token
@@ -144,13 +145,10 @@ module GReader
144
145
 
145
146
  protected
146
147
 
147
- # For those using #auth(email: x, password: x)
148
148
  def auth_request(meth, url, options={})
149
- options['Authorization'] = "GoogleLogin auth=#{self.auth}" if logged_in?
150
- RestClient.send meth, url, options
149
+ RestClient.send meth, url, :params => options, :Authorization => "GoogleLogin auth=#{@auth}"
151
150
  end
152
151
 
153
- # For those using #auth(access_token: x)
154
152
  def oauth_request(meth, url, options={})
155
153
  if meth == :get
156
154
  @oauth_token.get url + '?' + kv_map(options[:params])
@@ -55,7 +55,7 @@ module GReader
55
55
 
56
56
  # Constructor.
57
57
  # Can be called with an options hash or a Nokogiri XML node.
58
- def initialize(client=Client.new, options)
58
+ def initialize(client=Client.new, options={})
59
59
  @client = client
60
60
 
61
61
  @feed = client.feed(options[:feed])
@@ -139,8 +139,8 @@ module GReader
139
139
  :author => doc['author'],
140
140
  :content => summary,
141
141
  :title => doc['title'],
142
- :published => Time.new(doc['published']),
143
- :updated => Time.new(doc['updated']),
142
+ :published => DateTime.new(doc['published']),
143
+ :updated => DateTime.new(doc['updated']),
144
144
  :feed => doc['origin']['streamId'],
145
145
  :id => doc['id'],
146
146
  :read => doc['categories'].any? { |s| s =~ /com\.google\/fresh$/ },
@@ -50,11 +50,11 @@ module GReader
50
50
 
51
51
  alias to_s title
52
52
 
53
- def initialize(client=Client.new, options)
53
+ def initialize(client=Client.new, options={})
54
54
  @client = client
55
55
  @options = options
56
56
  @title = options['title']
57
- @url = options['htmlUrl']
57
+ @url = options['id'].gsub("feed/","")
58
58
  @sortid = options['sortid']
59
59
  @id = options['id']
60
60
  @tags_ = options['categories']
@@ -31,7 +31,7 @@ module GReader
31
31
  # @return [Client]
32
32
  attr_reader :client
33
33
 
34
- def initialize(client=Client.new, options)
34
+ def initialize(client, options)
35
35
  @client = client
36
36
  @options = options
37
37
  @id = options['id']
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class ClientTest < Test::Unit::TestCase
4
- setup do
4
+ def setup
5
5
  @client = GReader.auth credentials
6
6
  end
7
7
 
@@ -1,23 +1,23 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class FeedTest < Test::Unit::TestCase
4
- setup do
4
+ def setup
5
5
  @client = GReader.auth credentials
6
6
  @feeds = @client.feeds
7
- @feed = @feeds[29]
7
+ @feed = @feeds[0]
8
8
  end
9
9
 
10
10
  test "feeds" do
11
11
  assert @feeds.is_a?(Array)
12
- assert @feeds.size == 79
12
+ assert @feeds.size == 3
13
13
 
14
- assert_equal "Badass JavaScript", @feed.title
15
- assert_equal "http://badassjs.com/", @feed.url
14
+ assert_equal "Martin Fowler", @feed.title
15
+ assert_equal "http://martinfowler.com/feed.atom", @feed.url
16
16
  end
17
17
 
18
18
  test "Feed#tags" do
19
19
  tag = @feed.tags.first
20
- assert tag.is_a?(GReader::Tag)
21
- assert_equal "Dev | JavaScript", tag.to_s
20
+ assert_equal GReader::Tag, tag.class
21
+ assert_equal "coding", tag.to_s
22
22
  end
23
23
  end
@@ -1,8 +1,7 @@
1
- ENV['RESTCLIENT_LOG'] = 'stdout' if ENV['REAL']
2
-
3
1
  $:.push File.expand_path('../../lib', __FILE__)
4
2
 
5
3
  begin
4
+ require "test/unit"
6
5
  require 'contest'
7
6
  require 'fakeweb'
8
7
  require 'yaml'
@@ -14,6 +13,7 @@ end
14
13
 
15
14
  require 'greader'
16
15
 
16
+ RestClient.log = '/tmp/restclient.log'
17
17
  module TestHelpers
18
18
  extend self
19
19
 
@@ -33,7 +33,7 @@ module TestHelpers
33
33
  if real?
34
34
  YAML::load fixture('credentials.yml')
35
35
  else
36
- { :email => 'christian@mcnamara-troy.com', :password => 'yoplait' }
36
+ { :email => 'rubygreadertest', :password => 'greader_200' }
37
37
  end
38
38
  end
39
39
 
@@ -1,24 +1,24 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class TagTest < Test::Unit::TestCase
4
- setup do
4
+ def setup
5
5
  @client = GReader.auth credentials
6
6
  @tags = @client.tags
7
- @tag = @tags[4]
7
+ @tag = @tags[0]
8
8
  end
9
9
 
10
10
  test "Client#tags" do
11
- assert_equal 24, @tags.size
11
+ assert_equal 7, @tags.size
12
12
  end
13
13
 
14
14
  test "Tag" do
15
- assert_equal "Dev | Ruby", @tag.to_s
15
+ assert_equal "coding", @tag.to_s
16
16
  end
17
17
 
18
18
  test "Tag#feeds" do
19
19
  @feeds = @tag.feeds
20
20
 
21
- control = ["pipe :to => /dev/null", "RubyInside.com", "The timeless repository", "Antirez.com"]
21
+ control = ["Martin Fowler", "Ruby5", "RubyFlow"]
22
22
  assert_equal control, @feeds.map(&:to_s)
23
23
  end
24
24
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: greader
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Rico Sta. Cruz
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-22 00:00:00 +08:00
13
+ date: 2011-06-03 00:00:00 +08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -19,9 +19,9 @@ dependencies:
19
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
- - - ">="
22
+ - - ~>
23
23
  - !ruby/object:Gem::Version
24
- version: "0"
24
+ version: 1.4.4
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
@@ -62,6 +62,7 @@ files:
62
62
  - test/fixtures/tag-list.json
63
63
  - test/helper.rb
64
64
  - test/tag_test.rb
65
+ - HISTORY.md
65
66
  - README.md
66
67
  - Rakefile
67
68
  has_rdoc: true
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  requirements: []
89
90
 
90
91
  rubyforge_project:
91
- rubygems_version: 1.5.0
92
+ rubygems_version: 1.6.2
92
93
  signing_key:
93
94
  specification_version: 3
94
95
  summary: Google Reader API client.