newsblurry 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2f2046f72b33788e1164f9dc67f29dd6ed621fe0
4
+ data.tar.gz: 58dd9af17bf01649f2cabc6e64157298337dcc0f
5
+ SHA512:
6
+ metadata.gz: a2543e9a04d8bbe80c4e0e2062f0c340a16f74a880d6fda27842876e63aaf8cb61349156f23ab6c4182b924d73e220f07620f1ee77ea5abaaffdf954405a37a5
7
+ data.tar.gz: 8b8f3b6c35e9f8f0378cb71a355e32f253c9e534d9a64b79be13a2c391c894cc66381c6345b8bc5f4de74c079d8bf2426ee01f59621b5af8a1a62f319f6744a5
data/.gitignore ADDED
@@ -0,0 +1,81 @@
1
+ #----------------------------------------------------------------------------
2
+ # Ignore these files when commiting to a git repository.
3
+ #
4
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
5
+ #
6
+ # The original version of this file is found here:
7
+ # https://github.com/RailsApps/rails3-application-templates/raw/master/files/gitignore.txt
8
+ #
9
+ # Corrections? Improvements? Create a GitHub issue:
10
+ # http://github.com/RailsApps/rails3-application-templates/issues
11
+ #----------------------------------------------------------------------------
12
+
13
+ # bundler state
14
+ /.bundle
15
+ /vendor/bundle
16
+ ./vendor
17
+
18
+ # minimal Rails specific artifacts
19
+ db/*.sqlite3
20
+ /log/*.log
21
+ /log/*.pid
22
+ /tmp
23
+
24
+ # various artifacts
25
+ **.war
26
+ *.rbc
27
+ *.sassc
28
+ *.log
29
+ .rspec
30
+ .redcar/
31
+ .sass-cache
32
+ /config/config.yml
33
+ /config/mail.yml
34
+ /coverage.data
35
+ /coverage/
36
+ /db/*.javadb/
37
+ /db/*.sqlite3-journal
38
+ /doc/api/
39
+ /doc/app/
40
+ /doc/features.html
41
+ /doc/specs.html
42
+ /public/cache
43
+ /public/stylesheets/compiled
44
+ /public/assets/[^.]*
45
+ /public/uploads/[^.]*
46
+ /public/stylesheets/*.css
47
+ /public/system
48
+ /spec/tmp/*
49
+ /cache
50
+ /capybara*
51
+ /capybara-*.html
52
+ /gems
53
+ /rerun.txt
54
+ /specifications
55
+ /tags
56
+ .env
57
+ Gemfile.lock
58
+
59
+ # If you find yourself ignoring temporary files generated by your text editor
60
+ # or operating system, you probably want to add a global ignore instead:
61
+ # git config --global core.excludesfile ~/.gitignore_global
62
+ #
63
+ # Here are some files you may want to ignore globally:
64
+
65
+ # scm revert files
66
+ **.orig
67
+
68
+ # Mac finder artifacts
69
+ .DS_Store
70
+
71
+ # Netbeans project directory
72
+ /nbproject/
73
+
74
+ # RubyMine project files
75
+ .idea
76
+
77
+ # Textmate project files
78
+ /*.tmproj
79
+
80
+ # vim artifacts
81
+ **.swp
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ Documentation:
2
+ Enabled: false
3
+ AllCops:
4
+ Excludes:
5
+ - vendor/**
6
+ - spec/fixtures/**
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 0.0.1, released 2013-10-06
2
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org/'
2
+
3
+ gemspec
4
+
5
+ gem "pry"
6
+ gem "rspec"
7
+ gem "rake"
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # Newsblurry
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/newsblurry.png)](https://rubygems.org/gems/newsblurry)
4
+ [![Dependency Status](https://gemnasium.com/jgeiger/newsblurry.png)](https://gemnasium.com/jgeiger/newsblurry)
5
+ [![Build Status](https://travis-ci.org/jgeiger/newsblurry.png)](https://travis-ci.org/jgeiger/newsblurry)
6
+ [![Code Climate](https://codeclimate.com/github/jgeiger/newsblurry.png)](https://codeclimate.com/github/jgeiger/newsblurry)
7
+
8
+ ## Description
9
+
10
+ Connect to Newsblur
11
+
12
+ ## Installation
13
+ Add this line to your Gemfile
14
+
15
+ gem 'newsblurry'
16
+
17
+ And then:
18
+
19
+ bundle
20
+
21
+ ## Usage
22
+
23
+ ## License
24
+ Released under the MIT License
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ task :default => :spec
5
+
6
+ def bundle_exec(command)
7
+ sh %Q{bundle update && bundle exec #{command}}
8
+ end
9
+
10
+ def bundle_install_dependencies
11
+ sh %Q{bundle install --path vendor/bundle}
12
+ end
13
+
14
+ desc "Run all specs"
15
+ task "spec" do
16
+ bundle_exec("rspec spec")
17
+ end
18
+
19
+ desc "Install dependencies"
20
+ task "dependencies" do
21
+ bundle_install_dependencies
22
+ end
@@ -0,0 +1,67 @@
1
+ module Newsblurry
2
+ class Connection
3
+ include HTTParty
4
+ base_uri 'https://www.newsblur.com'
5
+ disable_rails_query_string_format
6
+
7
+ debug_output
8
+
9
+ def initialize(username, password)
10
+ options = { body: { username: username, password: password } }
11
+ response = post_request('/api/login', options)
12
+ @cookie = response.headers['set-cookie']
13
+ end
14
+
15
+ def unread_stories
16
+ feed_array = feeds
17
+ unread_feed_story_hashes.keys.flat_map do |feed_id|
18
+ feed = feed_array.find { |f| f.id == feed_id.to_i }
19
+ unread_stories_for_feed(feed)
20
+ end
21
+ end
22
+
23
+ def mark_as_read(story_hash)
24
+ options = { body: { story_hash: story_hash } }
25
+ post_request('/reader/mark_story_hashes_as_read', options)
26
+ end
27
+
28
+ private
29
+
30
+ def feeds
31
+ response = get_request('/reader/feeds')
32
+ FeedParser.new(response['feeds']).feeds
33
+ end
34
+
35
+ def unread_stories_for_feed(feed)
36
+ options = {
37
+ query: {
38
+ read_filter: 'unread', include_story_content: false
39
+ }
40
+ }
41
+ response = get_request("/reader/feed/#{feed.id}", options)
42
+ StoryParser.new(feed, response['stories']).stories
43
+ end
44
+
45
+ def unread_feed_story_hashes
46
+ response = get_request('/reader/unread_story_hashes')
47
+ response['unread_feed_story_hashes']
48
+ end
49
+
50
+ def get_request(url, options = {})
51
+ options.merge!(headers)
52
+ self.class.get(url, options)
53
+ end
54
+
55
+ def post_request(url, options = {})
56
+ options.merge!(headers)
57
+ self.class.post(url, options)
58
+ end
59
+
60
+ def headers
61
+ { headers: {
62
+ 'User-Agent' => "#{self.class.name} - #{Newsblurry::VERSION}",
63
+ 'Cookie' => @cookie || '' }
64
+ }
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,12 @@
1
+ module Newsblurry
2
+ class Feed
3
+ attr_reader :id, :title, :link, :address
4
+
5
+ def initialize(feed_hash)
6
+ @id = feed_hash['id']
7
+ @title = feed_hash['feed_title']
8
+ @link = feed_hash['feed_link']
9
+ @address = feed_hash['feed_address']
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ module Newsblurry
2
+ class FeedParser
3
+
4
+ attr_reader :feeds
5
+
6
+ def initialize(feeds_hash)
7
+ @feeds = []
8
+ @feeds_hash = feeds_hash
9
+ parse_feeds
10
+ end
11
+
12
+ private
13
+
14
+ def parse_feeds
15
+ @feeds = @feeds_hash.values.map do |value|
16
+ Newsblurry::Feed.new(value)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ module Newsblurry
2
+ class Story
3
+
4
+ attr_reader :title, :link, :hash, :published_at,
5
+ :feed_title, :feed_link, :feed_address
6
+
7
+ def initialize(feed, story_hash)
8
+ @title = story_hash['story_title']
9
+ @link = story_hash['story_permalink']
10
+ @hash = story_hash['story_hash']
11
+ @published_at = DateTime.parse(story_hash['story_date'])
12
+ @feed_title = feed.title
13
+ @feed_link = feed.link
14
+ @feed_address = feed.address
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ module Newsblurry
2
+ class StoryParser
3
+
4
+ attr_reader :stories
5
+
6
+ def initialize(feed, story_hashes)
7
+ @stories = []
8
+ @feed = feed
9
+ @story_hashes = story_hashes
10
+ parse_stories
11
+ end
12
+
13
+ private
14
+
15
+ def parse_stories
16
+ @stories = @story_hashes.map do |story_hash|
17
+ Newsblurry::Story.new(@feed, story_hash)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Newsblurry
2
+ VERSION = '0.0.1'
3
+ end
data/lib/newsblurry.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'httparty'
2
+ require 'newsblurry/version'
3
+
4
+ module Newsblurry
5
+ autoload :Connection, 'newsblurry/connection'
6
+ autoload :Feed, 'newsblurry/feed'
7
+ autoload :Story, 'newsblurry/story'
8
+ autoload :FeedParser, 'newsblurry/feed_parser'
9
+ autoload :StoryParser, 'newsblurry/story_parser'
10
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "newsblurry/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'newsblurry'
7
+ s.version = Newsblurry::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+
10
+ s.authors = ['Joey Geiger']
11
+ s.email = 'jgeiger@gmail.com'
12
+ s.homepage = 'http://github.com/jgeiger/newsblurry'
13
+
14
+ s.summary = 'Newsblurry is a Ruby client to access the Newsblur API.'
15
+ s.description = 'Access your Newsblur feed using Ruby.'
16
+ s.licenses = ["MIT"]
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
20
+ s.require_paths = ['lib']
21
+
22
+ s.add_dependency 'httparty'
23
+
24
+ s.add_development_dependency 'webmock'
25
+ s.add_development_dependency 'pry'
26
+ end
@@ -0,0 +1,14 @@
1
+ HTTP/1.1 200 OK
2
+ Server: gunicorn/0.17.4
3
+ Date: Wed, 09 Oct 2013 04:16:59 GMT
4
+ Transfer-Encoding: chunked
5
+ Connection: close
6
+ Expires: Wed, 09 Oct 2013 04:16:59 GMT
7
+ Vary: Cookie, Accept-Encoding
8
+ Last-Modified: Wed, 09 Oct 2013 04:16:59 GMT
9
+ Cache-Control: max-age=0
10
+ X-Nelson: Dad didn't leave... When he comes back from the store, he's going to wave those pop-tarts right in your face!
11
+ Content-Type: application/json
12
+ X-gunicorn-server: app06
13
+
14
+ {"updated": "43 minutes", "authenticated": true, "feed_tags": [], "feed_authors": [], "elapsed_time": 0.04, "feed_id": 1641, "stories": [{"story_authors": "Jerod Santo", "intelligence": {"feed": 0, "tags": 0, "author": 0, "title": 0}, "story_permalink": "http://feedproxy.google.com/~r/thechangelog/~3/3Hgy1mKZWsg/", "reply_count": 0, "comment_user_ids": [], "story_timestamp": "1381180513", "share_user_ids": [], "story_hash": "1641:aaae79", "id": "http://thechangelog.com/?p=6697", "comment_count": null, "story_tags": ["links", "activerecord", "postgresql", "rails", "ruby"], "share_count": null, "friend_comments": [], "story_date": "2013-10-07 21:15:13", "short_parsed_date": "07 Oct 2013, 4:15pm", "guid_hash": "aaae79", "image_urls": ["http://feeds.feedburner.com/~ff/thechangelog?d=yIl2AUoC8zA", "http://feeds.feedburner.com/~ff/thechangelog?d=7Q72WNTAKBA", "http://feeds.feedburner.com/~ff/thechangelog?i=3Hgy1mKZWsg:sXiRXBXQvaQ:V_sGLiPBpWU", "http://feeds.feedburner.com/~ff/thechangelog?d=qj6IDK7rITs", "http://feeds.feedburner.com/~ff/thechangelog?i=3Hgy1mKZWsg:sXiRXBXQvaQ:gIN9vFwOqvQ", "http://feeds.feedburner.com/~r/thechangelog/~4/3Hgy1mKZWsg"], "story_feed_id": 1641, "long_parsed_date": "Monday, October 7th, 2013 4:15pm", "public_comments": [], "read_status": 0, "story_title": "Use Rails with the db schema you always wanted"}], "result": "ok", "message": null, "classifiers": {"authors": {}, "feeds": {}, "titles": {}, "tags": {}}, "user_profiles": []}
@@ -0,0 +1,13 @@
1
+ HTTP/1.1 200 OK
2
+ Server: gunicorn/0.17.4
3
+ Date: Wed, 09 Oct 2013 04:16:59 GMT
4
+ Transfer-Encoding: chunked
5
+ Expires: Wed, 09 Oct 2013 04:16:59 GMT
6
+ Vary: Cookie, Accept-Encoding
7
+ Last-Modified: Wed, 09 Oct 2013 04:16:59 GMT
8
+ Cache-Control: max-age=0
9
+ X-Nelson: Dad didn't leave... When he comes back from the store, he's going to wave those pop-tarts right in your face!
10
+ Content-Type: application/json
11
+ X-gunicorn-server: app06
12
+
13
+ {"folders": [834, 693769, 4443494, 1675, 2678, 1700, 183814, 123960, 159238, 4425070, 882290, 588670, 1076, 1710, 165, 236715, 1084, 1095, 1641, 162717, 175738, 238176, 169], "authenticated": true, "social_profile": {"website": "", "following_user_ids": [], "following_count": 0, "shared_stories_count": 0, "private": false, "large_photo_url": "https://www.gravatar.com/avatar/0e7d5331c8315f1cdba91506ed360195", "id": "social:194625", "feed_address": "http://www.newsblur.com/social/rss/194625/jgeiger", "user_id": 194625, "feed_link": "http://jgeiger.newsblur.com", "follower_user_ids": [], "location": "", "popular_publishers": null, "follower_count": 0, "username": "jgeiger", "bio": "", "average_stories_per_month": 0, "feed_title": "jgeiger's blurblog", "photo_service": "gravatar", "stories_last_month": 0, "photo_url": "https://www.gravatar.com/avatar/0e7d5331c8315f1cdba91506ed360195", "num_subscribers": 0, "protected": false}, "user_profile": {"hide_getting_started": true, "preferences": {"keyboard_verticalarrows": "story", "read_story_delay": "0", "feed_view_single_story": "0", "story_styling": "sans-serif", "story_share_kippt": false, "truncate_story": "social", "story_share_delicious": false, "hide_story_changes": "1", "default_view": "feed", "story_share_evernote": false, "story_share_diigo": false, "hide_public_comments": false, "default_read_filter": "all", "story_share_facebook": true, "folder_counts": false, "story_share_twitter": true, "story_share_readability": false, "story_pane_anchor": "south", "intro_page": "4", "space_scroll_spacing": "40", "open_feed_action": "0", "ssl": "0", "new_window": "1", "animations": true, "story_size": "s", "story_share_googleplus": false, "arrow_scroll_spacing": "100", "story_share_instapaper": true, "default_order": "newest", "story_share_pinboard": false, "story_share_readitlater": false, "feed_order": "ALPHABETICAL", "title_counts": true, "show_tooltips": "1", "story_share_tumblr": false, "keyboard_horizontalarrows": "view"}, "tutorial_finished": false, "has_setup_feeds": true, "is_premium": false, "dashboard_date": "2013-06-17 14:43:47.980382", "has_trained_intelligence": false, "has_found_friends": false}, "starred_count": 0, "result": "ok", "feeds": {"1084": {"subs": 1357, "favicon_url": "http://icons.newsblur.com/1084.png", "is_push": true, "feed_opens": 8, "id": 1084, "ps": 0, "feed_link": "http://www.rubyinside.com", "updated_seconds_ago": 36633, "favicon_fetching": false, "ng": 0, "favicon_border": "a97175", "nt": 0, "not_yet_fetched": false, "updated": "10 hours", "s3_icon": true, "feed_address": "http://feeds.feedburner.com/RubyInside", "feed_title": "Ruby Inside", "favicon_fade": "ffbac0", "favicon_color": "e2979d", "active": true, "fetched_once": true, "favicon_text_color": "white", "subscribed": true, "num_subscribers": 1357, "s3_page": false, "min_to_decay": 696}, "1641": {"subs": 1098, "favicon_url": "http://icons.newsblur.com/1641.png", "is_push": true, "feed_opens": 42, "id": 1641, "ps": 0, "feed_link": "http://thechangelog.com", "updated_seconds_ago": 879, "favicon_fetching": false, "ng": 0, "favicon_border": "2e332a", "nt": 1, "not_yet_fetched": false, "updated": "14 minutes", "s3_icon": true, "feed_address": "http://feeds.feedburner.com/thechangelog", "feed_title": "The Changelog", "favicon_fade": "61675b", "favicon_color": "3e4438", "active": true, "fetched_once": true, "favicon_text_color": "white", "subscribed": true, "num_subscribers": 1098, "s3_page": false, "min_to_decay": 192}, "588670": {"subs": 81, "favicon_url": "http://icons.newsblur.com/588670.png", "is_push": false, "feed_opens": 65, "id": 588670, "ps": 0, "feed_link": "http://pivotallabs.com", "updated_seconds_ago": 145, "favicon_fetching": false, "ng": 0, "favicon_border": "6993ac", "nt": 1, "not_yet_fetched": false, "updated": "2 minutes", "s3_icon": true, "feed_address": "http://pivotallabs.com/feed/", "feed_title": "Pivotal Labs", "favicon_fade": "b0e7ff", "favicon_color": "8dc4e6", "active": true, "fetched_once": true, "favicon_text_color": "black", "subscribed": true, "num_subscribers": 81, "s3_page": false, "min_to_decay": 4}}, "social_services": {"facebook": {"syncing": false, "facebook_picture_url": null, "facebook_uid": null}, "twitter": {"twitter_username": null, "syncing": false, "twitter_picture_url": null, "twitter_uid": null}, "gravatar": {"gravatar_picture_url": "https://www.gravatar.com/avatar/0e7d5331c8315f1cdba91506ed360195"}, "appdotnet": {"syncing": false, "appdotnet_uid": null, "appdotnet_picture_url": null}, "upload": {"upload_picture_url": null}}, "categories": null, "social_feeds": []}
@@ -0,0 +1,11 @@
1
+ HTTP/1.1 200 OK
2
+ Server: gunicorn/0.17.4
3
+ Date: Wed, 09 Oct 2013 04:16:59 GMT
4
+ Transfer-Encoding: chunked
5
+ Connection: close
6
+ X-Nelson: Dad didn't leave... When he comes back from the store, he's going to wave those pop-tarts right in your face!
7
+ Content-Type: application/json
8
+ X-gunicorn-server: app06
9
+ Vary: Cookie
10
+
11
+ {"code": 1, "authenticated": true, "friend_user_ids": [], "feed_ids": ["1095"], "result": "ok", "story_hashes": ["1095:cdeec3"]}
@@ -0,0 +1,11 @@
1
+ HTTP/1.1 200 OK
2
+ Server: gunicorn/0.17.4
3
+ Date: Wed, 09 Oct 2013 04:16:59 GMT
4
+ Transfer-Encoding: chunked
5
+ Connection: close
6
+ X-Nelson: Dad didn't leave... When he comes back from the store, he's going to wave those pop-tarts right in your face!
7
+ Content-Type: application/json
8
+ X-gunicorn-server: app06
9
+ Vary: Cookie
10
+
11
+ {"unread_feed_story_hashes": {"1641": ["1641:cb0caf", "1641:aaae79"]}, "authenticated": true, "result": "ok"}
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe Newsblurry::Connection do
4
+ context '#initialize' do
5
+ it 'logs the user in' do
6
+ username = 'test'
7
+ password = 'test'
8
+
9
+ stub_request(:post, 'https://www.newsblur.com/api/login')
10
+ .with(
11
+ body: 'password=test&username=test',
12
+ headers: {
13
+ 'Cookie' => '',
14
+ 'User-Agent' => 'Newsblurry::Connection - 0.0.1'
15
+ }
16
+ )
17
+
18
+ connection = Newsblurry::Connection.new(username, password)
19
+ expect(connection.class).to eq(Newsblurry::Connection)
20
+ end
21
+ end
22
+
23
+ context 'when accessing the API' do
24
+ before do
25
+ stub_request(:post, 'https://www.newsblur.com/api/login')
26
+ @connection = Newsblurry::Connection.new('test', 'test')
27
+ end
28
+
29
+ context '#unread_stories' do
30
+ it 'returns an array of unread Newsblurry::Story' do
31
+ feeds_file = File.new('spec/fixtures/feeds.txt')
32
+ stub_request(:get, 'https://www.newsblur.com/reader/feeds')
33
+ .to_return(feeds_file)
34
+
35
+ hashes_file = File.new('spec/fixtures/unread_feed_story_hashes.txt')
36
+ stub_request(
37
+ :get,
38
+ 'https://www.newsblur.com/reader/unread_story_hashes'
39
+ ).to_return(hashes_file)
40
+
41
+ feed_file = File.new('spec/fixtures/feed_1641.txt')
42
+ stub_request(:get, 'https://www.newsblur.com/reader/feed/1641')
43
+ .with(query: { include_story_content: false, read_filter: 'unread' })
44
+ .to_return(feed_file)
45
+
46
+ unread_stories = @connection.unread_stories
47
+
48
+ titles = ['Use Rails with the db schema you always wanted']
49
+ expect(unread_stories.map(&:title)).to match_array(titles)
50
+ end
51
+ end
52
+
53
+ context '#mark_as_read' do
54
+ it 'marks the Newsblurry::Story as read' do
55
+ file = File.new('spec/fixtures/mark_as_read_1095_cdeec3.txt')
56
+ stub_request(
57
+ :post,
58
+ 'https://www.newsblur.com/reader/mark_story_hashes_as_read'
59
+ ).with(body: 'story_hash=1095%3Acdeec3').to_return(file)
60
+
61
+ story_hash_string = '1095:cdeec3'
62
+ response = @connection.mark_as_read(story_hash_string)
63
+
64
+ expect(response['feed_ids']).to eq(['1095'])
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Newsblurry::FeedParser do
4
+ before do
5
+ @ruby_feed_hash = {
6
+ 'id' => 1084,
7
+ 'feed_link' => 'http://www.rubyinside.com',
8
+ 'feed_address' => 'http://feeds.feedburner.com/RubyInside',
9
+ 'feed_title' => 'Ruby Inside'
10
+ }
11
+ @pivotal_feed_hash = {
12
+ 'id' => 588_670,
13
+ 'feed_link' => 'http://pivotallabs.com',
14
+ 'feed_address' => 'http://pivotallabs.com/feed/',
15
+ 'feed_title' => 'Pivotal Labs'
16
+ }
17
+ @changelog_feed_hash = {
18
+ 'id' => 1641,
19
+ 'feed_link' => 'http://thechangelog.com',
20
+ 'feed_address' => 'http://feeds.feedburner.com/thechangelog',
21
+ 'feed_title' => 'The Changelog',
22
+ }
23
+ feeds_hash = {
24
+ '1084' => @ruby_feed_hash,
25
+ '588670' => @pivotal_feed_hash,
26
+ '1641' => @changelog_feed_hash
27
+ }
28
+ @feed_parser = Newsblurry::FeedParser.new(feeds_hash)
29
+ end
30
+
31
+ it 'returns the feeds in an array' do
32
+ ruby_feed = Newsblurry::Feed.new(@ruby_feed_hash)
33
+ pivotal_feed = Newsblurry::Feed.new(@pivotal_feed_hash)
34
+ changelog_feed = Newsblurry::Feed.new(@changelog_feed_hash)
35
+ parsed_feed_title_array = [changelog_feed.title,
36
+ pivotal_feed.title,
37
+ ruby_feed.title]
38
+ titles = @feed_parser.feeds.map(&:title)
39
+ expect(titles).to match_array(parsed_feed_title_array)
40
+ end
41
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Newsblurry::Feed do
4
+ before do
5
+ feed_hash = {
6
+ 'id' => 1084,
7
+ 'feed_link' => 'http://www.rubyinside.com',
8
+ 'feed_address' => 'http://feeds.feedburner.com/RubyInside',
9
+ 'feed_title' => 'Ruby Inside'
10
+ }
11
+ @feed = Newsblurry::Feed.new(feed_hash)
12
+ end
13
+
14
+ it 'sets the id' do
15
+ id = 1084
16
+ expect(@feed.id).to eq(id)
17
+ end
18
+
19
+ it 'sets the link' do
20
+ link = 'http://www.rubyinside.com'
21
+ expect(@feed.link).to eq(link)
22
+ end
23
+
24
+ it 'sets the title' do
25
+ title = 'Ruby Inside'
26
+ expect(@feed.title).to eq(title)
27
+ end
28
+
29
+ it 'sets the address' do
30
+ address = 'http://feeds.feedburner.com/RubyInside'
31
+ expect(@feed.address).to eq(address)
32
+ end
33
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Newsblurry::StoryParser do
4
+ before do
5
+ story_hashes = [
6
+ {
7
+ 'story_permalink' => 'http://feedproxy.google.com/~r/thechangelog/',
8
+ 'story_hash' => '1641:aaae79',
9
+ 'id' => 'http://thechangelog.com/?p=6697',
10
+ 'story_date' => '2013-10-07 21:15:13',
11
+ 'story_feed_id' => 1641,
12
+ 'story_title' => 'Use Rails with the db schema you always wanted'
13
+ }
14
+ ]
15
+ feed_hash = {
16
+ 'id' => 1641,
17
+ 'feed_link' => 'http://www.thechangelog.com',
18
+ 'feed_address' => 'http://feeds.thechangelog.com',
19
+ 'feed_title' => 'The Changelog'
20
+ }
21
+ feed = Newsblurry::Feed.new(feed_hash)
22
+ @story_parser = Newsblurry::StoryParser.new(feed, story_hashes)
23
+ end
24
+
25
+ it 'returns the stories in an array' do
26
+ parsed_title_array = ['Use Rails with the db schema you always wanted']
27
+ titles = @story_parser.stories.map(&:title)
28
+ expect(titles).to match_array(parsed_title_array)
29
+ end
30
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe Newsblurry::Story do
4
+ before do
5
+ story_hash = {
6
+ 'story_title' => 'Broken lives of Fukushima',
7
+ 'story_permalink' => 'http://feeds.boston.com/c/35022/story01.htm',
8
+ 'story_hash' => '1095:67324d',
9
+ 'story_date' => '2013-10-07 23:54:16'
10
+ }
11
+
12
+ feed_hash = {
13
+ 'id' => 1095,
14
+ 'feed_link' => 'http://boston.com',
15
+ 'feed_address' => 'http://feeds.boston.com',
16
+ 'feed_title' => 'The Big Picture'
17
+ }
18
+
19
+ feed = Newsblurry::Feed.new(feed_hash)
20
+ @story = Newsblurry::Story.new(feed, story_hash)
21
+ end
22
+
23
+ it 'sets the link' do
24
+ link = 'http://feeds.boston.com/c/35022/story01.htm'
25
+ expect(@story.link).to eq(link)
26
+ end
27
+
28
+ it 'returns the title' do
29
+ title = 'Broken lives of Fukushima'
30
+ expect(@story.title).to eq(title)
31
+ end
32
+
33
+ it 'returns the hash' do
34
+ hash = '1095:67324d'
35
+ expect(@story.hash).to eq(hash)
36
+ end
37
+
38
+ it 'returns the published_at' do
39
+ published_at = '2013-10-07 23:54:16'
40
+ expect(@story.published_at).to eq(DateTime.parse(published_at))
41
+ end
42
+
43
+ it 'returns the feed_title' do
44
+ feed_title = 'The Big Picture'
45
+ expect(@story.feed_title).to eq(feed_title)
46
+ end
47
+
48
+ it 'returns the feed_link' do
49
+ feed_link = 'http://boston.com'
50
+ expect(@story.feed_link).to eq(feed_link)
51
+ end
52
+
53
+ it 'returns the feed_address' do
54
+ feed_address = 'http://feeds.boston.com'
55
+ expect(@story.feed_address).to eq(feed_address)
56
+ end
57
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Newsblurry do
4
+ it 'returns the version' do
5
+ expect(Newsblurry::VERSION).to eq('0.0.1')
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/newsblurry')
2
+
3
+ require 'pry'
4
+ require 'webmock/rspec'
5
+
6
+ WebMock.disable_net_connect!
7
+
8
+ RSpec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: newsblurry
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joey Geiger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: webmock
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Access your Newsblur feed using Ruby.
56
+ email: jgeiger@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - .gitignore
62
+ - .rubocop.yml
63
+ - CHANGELOG.md
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - lib/newsblurry.rb
68
+ - lib/newsblurry/connection.rb
69
+ - lib/newsblurry/feed.rb
70
+ - lib/newsblurry/feed_parser.rb
71
+ - lib/newsblurry/story.rb
72
+ - lib/newsblurry/story_parser.rb
73
+ - lib/newsblurry/version.rb
74
+ - newsblurry.gemspec
75
+ - spec/fixtures/feed_1641.txt
76
+ - spec/fixtures/feeds.txt
77
+ - spec/fixtures/mark_as_read_1095_cdeec3.txt
78
+ - spec/fixtures/unread_feed_story_hashes.txt
79
+ - spec/newsblurry/connection_spec.rb
80
+ - spec/newsblurry/feed_parser_spec.rb
81
+ - spec/newsblurry/feed_spec.rb
82
+ - spec/newsblurry/story_parser_spec.rb
83
+ - spec/newsblurry/story_spec.rb
84
+ - spec/newsblurry/version_spec.rb
85
+ - spec/spec_helper.rb
86
+ homepage: http://github.com/jgeiger/newsblurry
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.0.3
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Newsblurry is a Ruby client to access the Newsblur API.
110
+ test_files: []