feedlrop 0.1.20

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: 4d02856b3bf488c375d4f533bf7fa10be0607111
4
+ data.tar.gz: 633d78623de1190cac13fa5d68267460032eb29d
5
+ SHA512:
6
+ metadata.gz: a21c70a548193f7a606e2383183d81b1ced2b952dd43124de846d4800bcfe25cbd298b1ba17d5b9d76e2fa74fd9fc339f49c8866ac07dac458b1d9f09dee7f0a
7
+ data.tar.gz: b33b393863783e5ea6e14137f49cdf9694580e348874a126fd1dfb7e36bc979ff6a31d6caa92f4303896969973421f1d16afe3b5ccc55a6270fa9994fc6203bd
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ before_install: gem install bundler -v 1.10.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in feedlrop.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Feedlrop
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/feedlrop`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'feedlrop'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install feedlrop
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec feedlrop` to use the gem in this directory, ignoring other installed copies of this gem.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/feedlrop.
36
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "feedlrop"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exe/feedlrop ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'arxutils'
4
+ require 'feedlrop'
5
+
6
+ dbconfig = Arxutils::Dbutil::DBCONFIG_MYSQL
7
+ dbconfig = Arxutils::Dbutil::DBCONFIG_SQLITE3
8
+
9
+ token = ARGV[0]
10
+ hs = {
11
+ "db_dir" => Arxutils::Dbutil::DB_DIR,
12
+ "migrate_dir" => Arxutils::Dbutil::MIGRATE_DIR,
13
+ "config_dir" => Arxutils::Dbutil::CONFIG_DIR,
14
+ "dbconfig" => dbconfig,
15
+ "log_fname" => Arxutils::Dbutil::DATABASELOG,
16
+ }
17
+
18
+ fo = Feedlrop::Feedlrop.new(
19
+ token ,
20
+ :db,
21
+ hs
22
+ )
23
+ fo.csv_open
24
+ fo.get_all_unread_count
25
+ fo.csv_close
26
+
data/exe/makemigrate ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'arxutils'
5
+ require 'feedlrop'
6
+
7
+ data_ary = [
8
+ {
9
+ :flist => %W!noitem!,
10
+ :classname => "Countdatetime",
11
+ :classname_downcase => "countdatetime",
12
+ :items => [
13
+ ["countdatetime" , "datetime", "false"],
14
+ ],
15
+ :plural => "countdatetimes"
16
+ },
17
+
18
+ {
19
+ :flist => %W!base!,
20
+ :classname => "Unreadfeed",
21
+ :classname_downcase => "unreadfeed",
22
+
23
+ :items => [
24
+ ["time_id" , "integer", "false"],
25
+ ["category" , "string", "false"],
26
+ ["url" , "string", "false"],
27
+ ["unread_count" , "integer", "false"],
28
+ ],
29
+ :plural => "unreadfeeds"
30
+ },
31
+ ]
32
+
33
+ dbconfig = Arxutils::Dbutil::DBCONFIG_MYSQL
34
+ dbconfig = Arxutils::Dbutil::DBCONFIG_SQLITE3
35
+
36
+ forced = true
37
+ Arxutils::Migrate.migrate(
38
+ data_ary,
39
+ 0,
40
+ dbconfig,
41
+ forced
42
+ )
data/feedlrop.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'feedlrop/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "feedlrop"
8
+ spec.version = Feedlrop::VERSION
9
+ spec.authors = ["yasuo kominami"]
10
+ spec.email = ["ykominami@gmail.com"]
11
+
12
+ spec.summary = %q{utility functions for Feedly API.}
13
+ spec.description = %q{utility functions for Feedly API.}
14
+ spec.homepage = ""
15
+
16
+ spec.license = "MIT"
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "feedlr"
31
+
32
+ spec.add_runtime_dependency "activerecord"
33
+ spec.add_runtime_dependency "sqlite3"
34
+ spec.add_runtime_dependency "arxutils", "~> 0.1.10"
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.10"
37
+ spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "rspec"
39
+ end
@@ -0,0 +1,17 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'forwardable'
3
+ require 'feedlrop/dbutil/feedlropmgr'
4
+
5
+ module Feedlrop
6
+ module Dbutil
7
+ class DbMgr
8
+ extend Forwardable
9
+
10
+ def_delegator( :@feedlropmgr , :add, :add)
11
+
12
+ def initialize( register_time )
13
+ @feedlropmgr = FeedlropMgr.new( register_time )
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'active_record'
3
+ require 'forwardable'
4
+ require 'pp'
5
+
6
+ module Feedlrop
7
+ module Dbutil
8
+ class Unreadfeed < ActiveRecord::Base
9
+ end
10
+
11
+ class Countdatetime < ActiveRecord::Base
12
+ end
13
+
14
+ class FeedlropMgr
15
+ extend Forwardable
16
+
17
+ def initialize(register_time)
18
+ @register_time = register_time
19
+ @ct = Countdatetime.create( countdatetime: @register_time )
20
+ end
21
+
22
+ def add( category, url , unread_count )
23
+ begin
24
+ uf = Unreadfeed.create( time_id: @ct.id , category: category , url: url , unread_count: unread_count , start_datetime: @register_time )
25
+ rescue => ex
26
+ p ex.class
27
+ p ex.message
28
+ pp ex.backtrace
29
+ end
30
+
31
+ uf
32
+ end
33
+
34
+ def find(id)
35
+ Unreadfeed.find(id)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'feedlrop/dbutil/dbmgr'
3
+ require 'feedlrop/dbutil/feedlropmgr'
4
+
5
+ module Feedlrop
6
+ module Dbutil
7
+ end
8
+ end
@@ -0,0 +1,65 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'arxutils'
3
+ require 'arxutils/store'
4
+ require 'csv'
5
+ require 'pp'
6
+
7
+ module Feedlrop
8
+ class Feedlrop
9
+
10
+ def initialize( token , kind, hs )
11
+ @oauth_access_token = token
12
+ @dbmgr = Arxutils::Store.init(kind , hs ){ | register_time |
13
+ Dbutil::DbMgr.new( register_time )
14
+ }
15
+
16
+ @client = Feedlr::Client.new(sandbox: false , oauth_access_token: @oauth_access_token)
17
+ @profile = @client.user_profile
18
+ @categories = @client.user_categories
19
+ end
20
+
21
+ def get_output_file( ext )
22
+ n = Time.now
23
+ fname = %Q!#{n.year}-#{n.month}-#{n.day}-#{n.hour}-#{n.min}-#{n.sec}.#{ext}!
24
+ File.open( fname , "w")
25
+ end
26
+
27
+ def csv_open
28
+ @csv = CSV.new(get_output_file("csv") , {
29
+ :headers => %w!category_id id count!,
30
+ :write_headers => true
31
+ } )
32
+ end
33
+
34
+ def csv_add(category_id , id , count)
35
+ @csv << [category_id , id , count ]
36
+ end
37
+
38
+ def get_all_unread_count
39
+ #p categories
40
+ @categories.each do | x |
41
+ # f.puts "id=#{x.id.split('/')[-1]}"
42
+ f = true
43
+ if x.class == String
44
+ category_id = x.id.split('/')[-1]
45
+ else
46
+ f = false
47
+ end
48
+ next unless f
49
+
50
+ en = @client.user_unread_counts( {:streamId => x.id } )
51
+ en.unreadcounts.each do |y|
52
+ if y.id =~ /^feed\/(.+)/
53
+ url = $1
54
+ csv_add( category_id , url , y[:count] )
55
+ @dbmgr.add( category_id , url , y[:count] )
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ def csv_close
62
+ @csv.close
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ module Feedlrop
2
+ VERSION = "0.1.20"
3
+ end
data/lib/feedlrop.rb ADDED
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'arxutils'
3
+ require "feedlrop/version"
4
+ require "feedlrop/feedlrop"
5
+ require "feedlrop/dbutil"
6
+
7
+ require 'feedlr'
8
+
9
+ module Feedlrop
10
+ end
11
+
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: feedlrop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.20
5
+ platform: ruby
6
+ authors:
7
+ - yasuo kominami
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: feedlr
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: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: arxutils
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.10
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.10
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: utility functions for Feedly API.
112
+ email:
113
+ - ykominami@gmail.com
114
+ executables:
115
+ - feedlrop
116
+ - makemigrate
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".gitignore"
121
+ - ".rspec"
122
+ - ".travis.yml"
123
+ - Gemfile
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - exe/feedlrop
129
+ - exe/makemigrate
130
+ - feedlrop.gemspec
131
+ - lib/feedlrop.rb
132
+ - lib/feedlrop/dbutil.rb
133
+ - lib/feedlrop/dbutil/dbmgr.rb
134
+ - lib/feedlrop/dbutil/feedlropmgr.rb
135
+ - lib/feedlrop/feedlrop.rb
136
+ - lib/feedlrop/version.rb
137
+ homepage: ''
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.4.8
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: utility functions for Feedly API.
161
+ test_files: []
162
+ has_rdoc: