feedly2fastladder 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3b7103cbdc09de313c593ffe7b4c7356d65713c7
4
+ data.tar.gz: 661477241008f264d576c613daf6262a0fb2946c
5
+ SHA512:
6
+ metadata.gz: 6b21fd5a11ec46d32831ed5961369ad1c308a43194ebced6cd911410941f403f49ea5d9ccf99d3fc10e83fada379f57052a896d01d9845052f5a0dbda521bc12
7
+ data.tar.gz: 81b4ae206354fc46dd135ec1ead4120c923d06873add6035f53d68cb03c41d6555e2262a8d2351b0d55f8ce5d20e3c91773d57e89452f0e5982d722daf08731a
@@ -0,0 +1,57 @@
1
+ *.gem
2
+ *.rbc
3
+ <<<<<<< HEAD
4
+ /.config
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalisation:
25
+ /.bundle/
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
36
+ =======
37
+ .bundle
38
+ .config
39
+ .yardoc
40
+ Gemfile.lock
41
+ InstalledFiles
42
+ _yardoc
43
+ coverage
44
+ doc/
45
+ lib/bundler/man
46
+ pkg
47
+ rdoc
48
+ spec/reports
49
+ test/tmp
50
+ test/version_tmp
51
+ tmp
52
+ *.bundle
53
+ *.so
54
+ *.o
55
+ *.a
56
+ mkmf.log
57
+ >>>>>>> 29ab419... [ci skip]
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in feedly2fastladder.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 laiso
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,68 @@
1
+ # Feedly2fastladder
2
+
3
+ Bridge for converting to the Web API response of Fast ladder (https://github.com/fastladder/fastladder) from Feedly cloud.
4
+
5
+ First get your access token of Feedly API sandbox.
6
+
7
+ * http://developer.feedly.com/v3/sandbox/
8
+
9
+ ## Integrate with Fastladder
10
+
11
+ You must use Fastladder + Feedly backend fork version.
12
+ https://github.com/laiso/fastladder/tree/feedly_backend
13
+
14
+ ## Subscriptions
15
+
16
+ ```ruby:
17
+ f2f = Feedly2fastladder.new(token: ENV["FEEDLY_TOKEN"])
18
+
19
+ json_body = f2f.subs(unread: false)
20
+ puts json_body
21
+ ```
22
+
23
+ ```ruby:
24
+ feeds = JSON.parse(json_body)
25
+ feeds.each do |feed|
26
+ puts feed["tile"]
27
+ end
28
+ ```
29
+
30
+ ## Articles
31
+
32
+ ```ruby:
33
+ json_body = f2f.unread subscribe_id: 'feed/http://blogs.jetbrains.com/ruby/feed/'
34
+ puts json_body
35
+ ```
36
+
37
+ ## Mark as Read
38
+
39
+ ```ruby:
40
+ f2f.touch_all(subscribe_id: "feed/http://d.hatena.ne.jp/shu223/rss",
41
+ entry_id: "8fPKPXQE24TE54JEOGjF2sZj8ETeM/gFTA93+y2aPso=_148ff50f96b:56909a5:9c034b5e")
42
+ ```
43
+
44
+ ## Installation
45
+
46
+ Add this line to your application's Gemfile:
47
+
48
+ gem 'feedly2fastladder'
49
+
50
+ And then execute:
51
+
52
+ $ bundle
53
+
54
+ Or install it yourself as:
55
+
56
+ $ gem install feedly2fastladder
57
+
58
+ ## Tests
59
+
60
+ $ rspec spec/
61
+
62
+ ## Contributing
63
+
64
+ 1. Fork it ( https://github.com/laiso/feedly2fastladder/fork )
65
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
66
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
67
+ 4. Push to the branch (`git push origin my-new-feature`)
68
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'feedly2fastladder'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "feedly2fastladder"
8
+ spec.version = Feedly2fastladder::VERSION
9
+ spec.authors = ["laiso"]
10
+ spec.email = ["laiso@lai.so"]
11
+ spec.summary = %q{Bridge for converting to the Web API response of Fast ladder from Feedly cloud.}
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/laiso/feedly2fastladder/"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "faraday"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", "~>3.0"
26
+ end
@@ -0,0 +1,89 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'faraday'
3
+ require 'json'
4
+
5
+ class Feedly2fastladder
6
+ VERSION = "0.0.2"
7
+
8
+ def initialize(token: token)
9
+ @token = token
10
+ end
11
+
12
+ def subs(unread, from_id: 0, limit: 100)
13
+ @is_unread_only = unread
14
+ @unread_counts = unread_counts
15
+ response = conn.get "/v3/subscriptions"
16
+ convert_with_subs response.body
17
+ end
18
+
19
+ def unread(subscribe_id)
20
+ response = conn.get "/v3/streams/contents", {
21
+ streamId: subscribe_id.to_s,
22
+ unreadOnly: true
23
+ }
24
+ convert_with_contents response.body
25
+ end
26
+
27
+ def touch_all(subscribe_id, entry_id)
28
+ response = conn.post "/v3/markers" do |req|
29
+ req.headers['Content-Type'] = 'application/json'
30
+ req.body = {
31
+ action: "markAsRead",
32
+ type: "feeds",
33
+ lastReadEntryId: entry_id,
34
+ feedIds: [subscribe_id],
35
+ }.to_json
36
+ end
37
+ response.status == 200
38
+ end
39
+
40
+ private
41
+ def conn
42
+ conn = Faraday.new url: "https://cloud.feedly.com"
43
+ conn.headers["Authorization"] = "Bearer #{@token}"
44
+ conn
45
+ end
46
+
47
+ def convert_with_subs(text)
48
+ items = JSON.parse(text).map do |item|
49
+ item[:public] = 1
50
+ item[:rate] = item["sortid"]
51
+ item[:unread_count] = unread_count_by_id item["id"]
52
+ item[:subscribe_id] = item["id"]
53
+ item[:subscribers_count] = item["subscribers"]
54
+ item[:modified_on] = item["updated"]
55
+ item[:folder] = item["categories"][0]["label"]
56
+ item[:link] = item["website"]
57
+ item[:feedlink] = item["id"].sub /\Afeed\//, ''
58
+ item
59
+ end
60
+ items.select {|item| !@is_unread_only or item[:unread_count] > 0}.to_json
61
+ end
62
+
63
+ def convert_with_contents(text)
64
+ contents = JSON.parse(text)
65
+ contents[:subscribe_id] = contents["id"]
66
+ contents[:channel] = {
67
+ title: contents["title"],
68
+ modified_on: contents["updated"],
69
+ }
70
+ contents[:items] = contents["items"].map do |item|
71
+ item[:created_on] = item["published"]
72
+ item[:modified_on] = item["updated"]
73
+ item[:body] = item["content"]["content"] if item["content"]
74
+ item[:link] = item["alternate"][0]["href"] if item["alternate"]
75
+ item
76
+ end
77
+ contents.to_json
78
+ end
79
+
80
+ def unread_counts
81
+ response = conn.get "/v3/markers/counts"
82
+ JSON.parse(response.body)["unreadcounts"]
83
+ end
84
+
85
+ def unread_count_by_id(id)
86
+ item = @unread_counts.find {|data| data["id"] == id}
87
+ item["count"].to_i || 0
88
+ end
89
+ end
@@ -0,0 +1,70 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'json'
4
+ require 'rspec'
5
+
6
+ require 'feedly2fastladder'
7
+
8
+ unless ENV["FEEDLY_TOKEN"]
9
+ STDERR.write "[ERROR] Set a enviroment value FEEDLY_TOKEN your auth token.\n"
10
+ exit 1
11
+ end
12
+
13
+ describe 'F2F' do
14
+ before(:each) do
15
+ @f2f = Feedly2fastladder.new(token: ENV["FEEDLY_TOKEN"])
16
+ end
17
+
18
+ describe '#subs all feeds' do
19
+ before(:each) do
20
+ @subs_json = @f2f.subs(unread: false)
21
+ end
22
+
23
+ example "should subs response is valid JSON" do
24
+ parsable = JSON.parse(@subs_json).count > 0
25
+ expect(parsable).to eq(true)
26
+ end
27
+
28
+ example "should convert to FL-JSON" do
29
+ feed_item= JSON.parse(@subs_json)
30
+ item = feed_item.first
31
+ expect(item["subscribers_count"]).to be_a Integer
32
+ expect(item["modified_on"]).to be_a Fixnum
33
+ expect(item["title"]).to be_a String
34
+ expect(item["folder"]).to be_a String
35
+ expect(item["link"]).to start_with "http"
36
+ expect(item["feedlink"]).to start_with "http"
37
+ expect(item["public"]).to eq 1
38
+ end
39
+ end
40
+
41
+ describe '#subs unread feeds' do
42
+ before(:each) do
43
+ @subs_json = @f2f.subs(true)
44
+ end
45
+
46
+ example "should fetch the unread feeds" do
47
+ subs = JSON.parse(@subs_json)
48
+ subs.each do |feed|
49
+ expect(feed["unread_count"].to_i > 0).to be_truthy
50
+ end
51
+ end
52
+ end
53
+
54
+ describe '#unread' do
55
+ example "should load a feed" do
56
+ result = @f2f.unread 'feed/http://blogs.jetbrains.com/ruby/feed/'
57
+ feed = JSON.parse result
58
+ expect(feed["title"]).to eq("JetBrains RubyMine Blog")
59
+ end
60
+ end
61
+
62
+ describe '#touch_all' do
63
+ example "should mark read the feed" do
64
+ result = @f2f.touch_all("feed/http://d.hatena.ne.jp/shu223/rss",
65
+ "8fPKPXQE24TE54JEOGjF2sZj8ETeM/gFTA93+y2aPso=_148ff50f96b:56909a5:9c034b5e")
66
+ expect(result).to be_truthy
67
+ end
68
+ end
69
+
70
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: feedly2fastladder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - laiso
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
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
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: Bridge for converting to the Web API response of Fast ladder from Feedly
70
+ cloud.
71
+ email:
72
+ - laiso@lai.so
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - feedly2fastladder.gemspec
83
+ - lib/feedly2fastladder.rb
84
+ - spec/feedly2fastladder_spec.rb
85
+ homepage: https://github.com/laiso/feedly2fastladder/
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.2.2
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Bridge for converting to the Web API response of Fast ladder from Feedly
109
+ cloud.
110
+ test_files:
111
+ - spec/feedly2fastladder_spec.rb
112
+ has_rdoc: