feedlrop 0.1.23 → 0.1.24
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.
- checksums.yaml +5 -5
- data/.gitignore +15 -0
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +73 -0
- data/.ruby-version +1 -0
- data/Gemfile +21 -0
- data/Rakefile +19 -3
- data/bin/console +4 -3
- data/exe/feedlrop +48 -20
- data/f.bat +0 -0
- data/feedlrop.gemspec +32 -26
- data/lib/feedlrop/cli.rb +26 -0
- data/lib/feedlrop/dbutil/feedlropmgr.rb +14 -18
- data/lib/feedlrop/dbutil.rb +3 -7
- data/lib/feedlrop/feedlrop.rb +143 -37
- data/lib/feedlrop/version.rb +4 -1
- data/lib/feedlrop.rb +12 -7
- metadata +21 -36
- data/exe/f +0 -27
- data/exe/makemigrate +0 -42
- data/lib/feedlrop/dbutil/dbmgr.rb +0 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 78db68bfb40f6b07770276e3f479b79e30fa8f8fe710d71a9c91e2ed1e576133
|
|
4
|
+
data.tar.gz: '0870817dffecf5fb13af7abdb09ee76fdacedd242c5cf8eb87551cff02cd6774'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29bce63e36709640c0faa8a813fde0735aba01848c04fcd6c26ca95841dcce7e01c16847e6713b1fd73d2aebc6ea4fa91c20aea21896f06fe4593e5e4c982107
|
|
7
|
+
data.tar.gz: 4c9ffd2a625231e5c8da879e2bd978738405700f1e1a6fca4c6a0213608fbbf0a02f57732caa713987b35e6e74182b592d67d9fd9976783ff09fa26aaa26946d
|
data/.gitignore
CHANGED
|
@@ -14,4 +14,19 @@
|
|
|
14
14
|
/memo/
|
|
15
15
|
/TAGS
|
|
16
16
|
/*.bat
|
|
17
|
+
/OLD-DATA
|
|
18
|
+
/exe/get_access*
|
|
19
|
+
*~
|
|
20
|
+
xdoc.txt
|
|
21
|
+
xdoc2.txt
|
|
22
|
+
/logs
|
|
23
|
+
/vendor
|
|
24
|
+
/output
|
|
25
|
+
/lib/feedlrop/dbutil/dbrelation.rb
|
|
26
|
+
/exe2
|
|
27
|
+
a.rb
|
|
28
|
+
f.sh
|
|
29
|
+
lib/dbrelation.rb
|
|
30
|
+
/pstore*/
|
|
31
|
+
/lib/dbacrecord.rb
|
|
17
32
|
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2022-09-22 09:32:47 UTC using RuboCop version 1.36.0.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
# Configuration parameters: Include.
|
|
11
|
+
# Include: **/*.gemspec
|
|
12
|
+
Gemspec/RequiredRubyVersion:
|
|
13
|
+
Exclude:
|
|
14
|
+
# - 'feedlrop.gemspec'
|
|
15
|
+
|
|
16
|
+
# Offense count: 1
|
|
17
|
+
# Configuration parameters: AllowSafeAssignment.
|
|
18
|
+
Lint/AssignmentInCondition:
|
|
19
|
+
Exclude:
|
|
20
|
+
# - 'exe/feedlrop'
|
|
21
|
+
|
|
22
|
+
# Offense count: 4
|
|
23
|
+
Lint/UselessAssignment:
|
|
24
|
+
Exclude:
|
|
25
|
+
# - 'exe/feedlrop'
|
|
26
|
+
|
|
27
|
+
# Offense count: 3
|
|
28
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
|
|
29
|
+
Metrics/AbcSize:
|
|
30
|
+
Max: 24
|
|
31
|
+
|
|
32
|
+
# Offense count: 4
|
|
33
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
|
34
|
+
Metrics/MethodLength:
|
|
35
|
+
Max: 25
|
|
36
|
+
|
|
37
|
+
# Offense count: 3
|
|
38
|
+
Naming/AccessorMethodName:
|
|
39
|
+
Exclude:
|
|
40
|
+
# - 'lib/feedlrop/feedlrop.rb'
|
|
41
|
+
|
|
42
|
+
# Offense count: 3
|
|
43
|
+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
|
44
|
+
# AllowedNames: as, at, by, db, id, in, io, ip, of, on, os, pp, to
|
|
45
|
+
Naming/MethodParameterName:
|
|
46
|
+
Exclude:
|
|
47
|
+
# - 'exe/feedlrop'
|
|
48
|
+
# - 'lib/feedlrop/feedlrop.rb'
|
|
49
|
+
|
|
50
|
+
# Offense count: 5
|
|
51
|
+
# Configuration parameters: AllowedConstants.
|
|
52
|
+
Style/Documentation:
|
|
53
|
+
Exclude:
|
|
54
|
+
- 'spec/**/*'
|
|
55
|
+
- 'test/**/*'
|
|
56
|
+
- 'db/migrate/010_create_countdatetime.rb'
|
|
57
|
+
- 'db/migrate/020_create_evnb.rb'
|
|
58
|
+
- 'db/migrate/030_create_ennblist.rb'
|
|
59
|
+
- 'db/migrate/040_create_invalidennblist.rb'
|
|
60
|
+
- 'db/migrate/050_create_currentennblist.rb'
|
|
61
|
+
|
|
62
|
+
# Offense count: 1
|
|
63
|
+
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
|
|
64
|
+
Style/GuardClause:
|
|
65
|
+
Exclude:
|
|
66
|
+
- 'feedlrop.gemspec'
|
|
67
|
+
|
|
68
|
+
# Offense count: 1
|
|
69
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
70
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
|
71
|
+
# URISchemes: http, https
|
|
72
|
+
Layout/LineLength:
|
|
73
|
+
Max: 163
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.6.10
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
source 'https://rubygems.org'
|
|
2
4
|
|
|
3
5
|
# Specify your gem's dependencies in feedlrop.gemspec
|
|
4
6
|
gemspec
|
|
7
|
+
gem 'awesome_print'
|
|
8
|
+
gem 'feedlr'
|
|
9
|
+
# gem "faraday"
|
|
10
|
+
|
|
11
|
+
gem "arxutils_sqlite3"
|
|
12
|
+
# gem 'arxutils_sqlite3', path: '../arxutils_sqlite3_3'
|
|
13
|
+
gem "simpleoptparse"
|
|
14
|
+
gem 'ykxutils'
|
|
15
|
+
|
|
16
|
+
gem 'rake', '~> 13.0'
|
|
17
|
+
gem 'rspec', '~> 3.0'
|
|
18
|
+
|
|
19
|
+
gem 'rubocop', '~> 1.7'
|
|
20
|
+
gem 'rubocop-rake'
|
|
21
|
+
gem 'rubocop-rspec'
|
|
22
|
+
|
|
23
|
+
group :development do
|
|
24
|
+
gem 'yard'
|
|
25
|
+
end
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'feedlrop'
|
|
4
|
+
require 'arxutils_sqlite3/rake_task'
|
|
5
|
+
|
|
6
|
+
require 'bundler/gem_tasks'
|
|
7
|
+
require 'rspec/core/rake_task'
|
|
3
8
|
|
|
4
9
|
RSpec::Core::RakeTask.new(:spec)
|
|
5
10
|
|
|
6
|
-
|
|
11
|
+
require 'rubocop/rake_task'
|
|
12
|
+
|
|
13
|
+
RuboCop::RakeTask.new
|
|
14
|
+
|
|
15
|
+
# task :default => :spec
|
|
16
|
+
desc 'Feedlr related operation'
|
|
17
|
+
task :feedlrop do
|
|
18
|
+
sh 'bundle exec feedlrop'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc 'Feedlr related operation'
|
|
22
|
+
task default: %i[spec rubocop]
|
data/bin/console
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'feedlrop'
|
|
5
6
|
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
|
@@ -10,5 +11,5 @@ require "feedlrop"
|
|
|
10
11
|
# require "pry"
|
|
11
12
|
# Pry.start
|
|
12
13
|
|
|
13
|
-
require
|
|
14
|
+
require 'irb'
|
|
14
15
|
IRB.start
|
data/exe/feedlrop
CHANGED
|
@@ -1,26 +1,54 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'arxutils'
|
|
2
|
+
# frozen_string_literal: true
|
|
4
3
|
require 'feedlrop'
|
|
4
|
+
require "simpleoptparse"
|
|
5
|
+
require 'yaml'
|
|
6
|
+
|
|
7
|
+
token, user_id, hash = Feedlrop::Cli.setup
|
|
8
|
+
|
|
9
|
+
banner = "Usage: bundle exec feedlrop --cmd=(lp|lpd|r)"
|
|
10
|
+
opts = {}
|
|
11
|
+
Simpleoptparse::Simpleoptparse.parse(ARGV, opts, banner, Arxutils_Sqlite3::VERSION, nil) do |parser|
|
|
12
|
+
parser.on("--cmd X", %w[lp lpd r]) { |x| opts["cmd"] = x }
|
|
13
|
+
end
|
|
5
14
|
|
|
6
|
-
|
|
7
|
-
|
|
15
|
+
flop = Feedlrop::Feedlrop.new(
|
|
16
|
+
token,
|
|
17
|
+
hash
|
|
18
|
+
)
|
|
8
19
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"log_fname" => Arxutils::Dbutil::DATABASELOG,
|
|
16
|
-
}
|
|
20
|
+
cmd = opts["cmd"]
|
|
21
|
+
# way = :REMOTE
|
|
22
|
+
# way = :LOCAL
|
|
23
|
+
# way = :LOCAL_PSTORE
|
|
24
|
+
# way = :LOCAL_PSTORE_AND_DB
|
|
25
|
+
# way = :REMOTE
|
|
17
26
|
|
|
18
|
-
|
|
19
|
-
token ,
|
|
20
|
-
:db,
|
|
21
|
-
hs
|
|
22
|
-
)
|
|
23
|
-
fo.csv_open
|
|
24
|
-
fo.get_all_unread_count
|
|
25
|
-
fo.csv_close
|
|
27
|
+
ERROR_CODE_INVALID_CMD = 100
|
|
26
28
|
|
|
29
|
+
case cmd
|
|
30
|
+
when "lp"
|
|
31
|
+
# :LOCAL_PSTORE
|
|
32
|
+
# puts "way=#{way}"
|
|
33
|
+
# exit
|
|
34
|
+
flop.check_backup
|
|
35
|
+
# exit
|
|
36
|
+
when "lpd"
|
|
37
|
+
# :LOCAL_PSTORE_AND_DB
|
|
38
|
+
# puts "way=#{way}"
|
|
39
|
+
# exit
|
|
40
|
+
# flop.check_backup
|
|
41
|
+
flop.csv_to_db
|
|
42
|
+
# exit
|
|
43
|
+
when "r"
|
|
44
|
+
# :REMOTE
|
|
45
|
+
puts "cmd=#{cmd}"
|
|
46
|
+
# exit
|
|
47
|
+
flop.csv_open(hash['output_dir'])
|
|
48
|
+
ret = flop.all_unread_count
|
|
49
|
+
puts "all_unread_count=#{ret.size}"
|
|
50
|
+
flop.csv_close
|
|
51
|
+
else
|
|
52
|
+
puts "cmd=#{cmd}"
|
|
53
|
+
exit ERROR_CODE_INVALID_CMD
|
|
54
|
+
end
|
data/f.bat
CHANGED
|
File without changes
|
data/feedlrop.gemspec
CHANGED
|
@@ -1,40 +1,46 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
5
|
require 'feedlrop/version'
|
|
5
6
|
|
|
6
7
|
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name =
|
|
8
|
+
spec.name = 'feedlrop'
|
|
8
9
|
spec.version = Feedlrop::VERSION
|
|
9
|
-
spec.authors = [
|
|
10
|
-
spec.email = [
|
|
11
|
-
|
|
12
|
-
spec.summary =
|
|
13
|
-
spec.description =
|
|
14
|
-
spec.homepage =
|
|
15
|
-
|
|
16
|
-
spec.
|
|
10
|
+
spec.authors = ['yasuo kominami']
|
|
11
|
+
spec.email = ['ykominami@gmail.com']
|
|
12
|
+
|
|
13
|
+
spec.summary = 'utility functions for Feedly API.'
|
|
14
|
+
spec.description = 'utility functions for Feedly API.'
|
|
15
|
+
spec.homepage = ''
|
|
16
|
+
spec.license = 'MIT'
|
|
17
|
+
spec.required_ruby_version = '>= 2.6.10'
|
|
18
|
+
|
|
17
19
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
20
|
# delete this section to allow pushing this gem to any host.
|
|
19
21
|
if spec.respond_to?(:metadata)
|
|
20
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
22
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
23
|
else
|
|
22
|
-
raise
|
|
24
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
-
spec.bindir =
|
|
28
|
+
spec.bindir = 'exe'
|
|
27
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
-
spec.require_paths = [
|
|
29
|
-
|
|
30
|
-
spec.add_dependency
|
|
31
|
-
|
|
32
|
-
spec.add_runtime_dependency
|
|
33
|
-
|
|
34
|
-
spec.add_runtime_dependency "
|
|
35
|
-
spec.add_runtime_dependency "
|
|
36
|
-
|
|
37
|
-
spec.
|
|
38
|
-
spec.
|
|
39
|
-
|
|
30
|
+
spec.require_paths = ['lib']
|
|
31
|
+
|
|
32
|
+
spec.add_dependency 'feedlr'
|
|
33
|
+
spec.add_runtime_dependency 'awesome_print'
|
|
34
|
+
spec.add_runtime_dependency 'faraday'
|
|
35
|
+
|
|
36
|
+
# spec.add_runtime_dependency "activerecord" , "~> 4.2"
|
|
37
|
+
# spec.add_runtime_dependency "sqlite3"
|
|
38
|
+
# spec.add_runtime_dependency "mysql2" , "~> 0.4.1"
|
|
39
|
+
# spec.add_runtime_dependency "arxutils", "~> 0.1.10"
|
|
40
|
+
spec.add_runtime_dependency 'arxutils_sqlite3'
|
|
41
|
+
|
|
42
|
+
spec.add_development_dependency 'bundler'
|
|
43
|
+
spec.add_development_dependency 'rake'
|
|
44
|
+
spec.add_development_dependency 'rspec'
|
|
45
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
40
46
|
end
|
data/lib/feedlrop/cli.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "arxutils_sqlite3"
|
|
2
|
+
|
|
3
|
+
module Feedlrop
|
|
4
|
+
class Cli
|
|
5
|
+
def self.setup
|
|
6
|
+
token = ENV.fetch("FEEDLY_DEVELOPER_ACCESS_TOKEN", nil)
|
|
7
|
+
user_id = ENV.fetch("FEEDLER_USE_ID", nil)
|
|
8
|
+
env = ENV.fetch("ENV", nil)
|
|
9
|
+
# env ||= "development"
|
|
10
|
+
env ||= "production"
|
|
11
|
+
|
|
12
|
+
hash = {
|
|
13
|
+
'db_dir' => Arxutils_Sqlite3::Config::DB_DIR,
|
|
14
|
+
'migrate_dir' => Arxutils_Sqlite3::Config::MIGRATE_DIR,
|
|
15
|
+
'config_dir' => Arxutils_Sqlite3::Config::CONFIG_DIR,
|
|
16
|
+
"dbconfig" => Arxutils_Sqlite3::Config::DBCONFIG_SQLITE3,
|
|
17
|
+
'env' => env,
|
|
18
|
+
'log_fname' => Arxutils_Sqlite3::Config::DATABASELOG,
|
|
19
|
+
'output_dir' => ::Feedlrop::OUTPUT_DIR,
|
|
20
|
+
'pstore_dir' => ::Feedlrop::PSTORE_DIR,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[token, user_id, hash]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -1,36 +1,32 @@
|
|
|
1
|
-
#
|
|
2
|
-
require 'active_record'
|
|
3
|
-
require 'forwardable'
|
|
1
|
+
# frozen_string_literal: true
|
|
4
2
|
require 'pp'
|
|
5
3
|
|
|
6
4
|
module Feedlrop
|
|
5
|
+
# DB操作用ユーティリティモジュール
|
|
7
6
|
module Dbutil
|
|
8
|
-
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
class Countdatetime < ActiveRecord::Base
|
|
12
|
-
end
|
|
13
|
-
|
|
7
|
+
# Feedlrに関する情報用DB操作クラス
|
|
14
8
|
class FeedlropMgr
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
# 初期化
|
|
17
10
|
def initialize(register_time)
|
|
18
11
|
@register_time = register_time
|
|
19
|
-
@ct = Countdatetime.create(
|
|
12
|
+
@ct = Dbutil::Countdatetime.create(countdatetime: @register_time)
|
|
20
13
|
end
|
|
21
14
|
|
|
22
|
-
|
|
15
|
+
# 指定フィードの未読情報登録
|
|
16
|
+
def add(category, url, unread_count)
|
|
23
17
|
begin
|
|
24
|
-
uf = Unreadfeed.create(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
p
|
|
28
|
-
|
|
18
|
+
uf = Dbutil::Unreadfeed.create(time_id: @ct.id, category: category, url: url, unread_count: unread_count,
|
|
19
|
+
start_datetime: @register_time)
|
|
20
|
+
rescue StandardError => e
|
|
21
|
+
p e.class
|
|
22
|
+
p e.message
|
|
23
|
+
pp e.backtrace
|
|
29
24
|
end
|
|
30
25
|
|
|
31
26
|
uf
|
|
32
27
|
end
|
|
33
28
|
|
|
29
|
+
# IDで指定したフィードの未読情報取得
|
|
34
30
|
def find(id)
|
|
35
31
|
Unreadfeed.find(id)
|
|
36
32
|
end
|
data/lib/feedlrop/dbutil.rb
CHANGED
data/lib/feedlrop/feedlrop.rb
CHANGED
|
@@ -1,77 +1,183 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
require '
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'arxutils_sqlite3'
|
|
4
4
|
require 'csv'
|
|
5
5
|
require 'pp'
|
|
6
6
|
require 'feedlr'
|
|
7
7
|
require 'awesome_print'
|
|
8
|
+
require 'fileutils'
|
|
9
|
+
require 'ykxutils'
|
|
8
10
|
|
|
9
11
|
module Feedlrop
|
|
12
|
+
# Feedlr操作クラス
|
|
10
13
|
class Feedlrop
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
attr_reader :categories, :profile
|
|
15
|
+
|
|
16
|
+
# 初期化
|
|
17
|
+
def initialize(token, hash)
|
|
18
|
+
# OAuthアクセストークン
|
|
13
19
|
@oauth_access_token = token
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
|
|
21
|
+
db_dir = hash['db_dir']
|
|
22
|
+
config_dir = hash['config_dir']
|
|
23
|
+
env = hash['env']
|
|
24
|
+
dbconfig = hash['dbconfig']
|
|
25
|
+
@output_dir = hash['output_dir']
|
|
26
|
+
@pstore_dir = hash['pstore_dir']
|
|
27
|
+
|
|
28
|
+
dbconfig_path = Arxutils_Sqlite3::Util.make_dbconfig_path(config_dir, dbconfig)
|
|
29
|
+
log_path = Arxutils_Sqlite3::Util.make_log_path(db_dir, dbconfig)
|
|
30
|
+
dbconnect = Arxutils_Sqlite3::Dbutil::Dbconnect.new(
|
|
31
|
+
dbconfig_path,
|
|
32
|
+
env,
|
|
33
|
+
log_path
|
|
34
|
+
)
|
|
35
|
+
register_time = dbconnect.connect
|
|
36
|
+
# register_time = Arxutils::Dbutil::Dbconnect.init( hs["db_dir"], hs["migrate_dir"] , hs["config_dir"], hs["dbconfig"] , hs["env"] , hs["log_fname"] , opts )
|
|
37
|
+
# 保存用DBマネージャ
|
|
38
|
+
# @dbmgr = ::Feedlrop::Dbutil::FeedlropMgr.new(register_time)
|
|
39
|
+
@dbmgr = Dbutil::FeedlropMgr.new(register_time)
|
|
40
|
+
# Feedlrクライアント
|
|
41
|
+
@client = Feedlr::Client.new(sandbox: false, oauth_access_token: @oauth_access_token)
|
|
42
|
+
# ユーザプロファイル
|
|
19
43
|
@profile = @client.user_profile
|
|
44
|
+
# カテゴリ
|
|
20
45
|
@categories = @client.user_categories
|
|
46
|
+
|
|
47
|
+
@pstorex = Ykxutils::Pstorex.new(@pstore_dir)
|
|
48
|
+
@pstore_key = ::Feedlrop::PSTORE_KEY
|
|
49
|
+
@pstore_default_value = []
|
|
50
|
+
load_pstore
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# psotreからの取得
|
|
54
|
+
def pstore_fetch(key, default_value)
|
|
55
|
+
@pstorex.fetch(key, default_value)
|
|
21
56
|
end
|
|
22
57
|
|
|
23
|
-
|
|
58
|
+
# pstore更新
|
|
59
|
+
def pstore_store(key, value)
|
|
60
|
+
@pstorex.store(key, value)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# DBへ登録
|
|
64
|
+
def dbmgr_add(category_id, url, count)
|
|
65
|
+
@dbmgr.add(category_id, url, count)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# 出力ファイル取得
|
|
69
|
+
def get_output_file(parent_dir, ext)
|
|
24
70
|
n = Time.now
|
|
25
|
-
fname = %
|
|
26
|
-
|
|
71
|
+
fname = %(#{n.year}-#{n.month}-#{n.day}-#{n.hour}-#{n.min}-#{n.sec}.#{ext})
|
|
72
|
+
FileUtils.mkdir_p(parent_dir)
|
|
73
|
+
outfname = File.join(parent_dir, fname)
|
|
74
|
+
File.open(outfname, 'w')
|
|
27
75
|
end
|
|
28
76
|
|
|
29
|
-
|
|
30
|
-
|
|
77
|
+
# 各フィードの未読数を全て取得
|
|
78
|
+
def all_unread_count
|
|
79
|
+
@categories.each do |x|
|
|
80
|
+
if x.instance_of?(Array)
|
|
81
|
+
_err, error_code = x
|
|
82
|
+
next
|
|
83
|
+
end
|
|
31
84
|
f = true
|
|
32
|
-
if x.
|
|
33
|
-
category_id = x.id.split('/')[-1]
|
|
34
|
-
else
|
|
85
|
+
if x.instance_of?(String)
|
|
35
86
|
f = false
|
|
87
|
+
else
|
|
88
|
+
category_id = x.id.split('/')[-1]
|
|
36
89
|
end
|
|
37
90
|
next unless f
|
|
38
91
|
|
|
39
|
-
en = @client.user_unread_counts(
|
|
92
|
+
en = @client.user_unread_counts({ streamId: x.id })
|
|
93
|
+
next if en.nil?
|
|
40
94
|
en.unreadcounts.each do |y|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
95
|
+
next unless y.id =~ %r{^feed/(.+)}
|
|
96
|
+
|
|
97
|
+
url = ::Regexp.last_match(1)
|
|
98
|
+
csv_add(category_id, url, y[:count])
|
|
99
|
+
@dbmgr.add(category_id, url, y[:count])
|
|
46
100
|
end
|
|
47
101
|
end
|
|
48
102
|
end
|
|
49
103
|
|
|
104
|
+
# ユーザプロファイルをコンソールへ出力
|
|
50
105
|
def print_user_profile
|
|
51
106
|
pp @profile
|
|
52
107
|
end
|
|
53
108
|
|
|
109
|
+
# ユーザサブスクリプションをコンソールへ出力
|
|
54
110
|
def print_subscription
|
|
55
|
-
option = {:
|
|
56
|
-
puts @client.user_subscriptions.size
|
|
57
|
-
@client.user_subscriptions.map{|m|
|
|
58
|
-
puts
|
|
59
|
-
@client.user_subscriptions.map{|m| ap m , option }
|
|
111
|
+
option = { plain: true }
|
|
112
|
+
# puts @client.user_subscriptions.size
|
|
113
|
+
@client.user_subscriptions.map { |m| puts m.id }
|
|
114
|
+
# puts '==============='
|
|
60
115
|
end
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
116
|
+
|
|
117
|
+
# 指定ディレクトリに出力準備(CVS形式)
|
|
118
|
+
def csv_open(parent_dir)
|
|
119
|
+
csv_file = get_output_file(parent_dir, 'csv')
|
|
120
|
+
@csv = CSV.new(csv_file,
|
|
121
|
+
headers: %w[category_id id count],
|
|
122
|
+
write_headers: true)
|
|
67
123
|
end
|
|
68
124
|
|
|
69
|
-
|
|
70
|
-
|
|
125
|
+
# 出力先にカテゴリID、フィードID、未読数を出力
|
|
126
|
+
def csv_add(category_id, id, count)
|
|
127
|
+
@csv << [category_id, id, count]
|
|
71
128
|
end
|
|
72
129
|
|
|
130
|
+
# 出力先クローズ
|
|
73
131
|
def csv_close
|
|
74
132
|
@csv.close
|
|
75
133
|
end
|
|
134
|
+
|
|
135
|
+
def load_pstore
|
|
136
|
+
value = pstore_fetch(@pstore_key, @pstore_default_value)
|
|
137
|
+
|
|
138
|
+
if value == @pstore_default_value
|
|
139
|
+
new_value = {
|
|
140
|
+
key => {
|
|
141
|
+
profile: @profile,
|
|
142
|
+
categories: @categories
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
pstore_store(@pstore_key, new_value)
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def check_backup
|
|
150
|
+
value2 = pstore_fetch(@pstore_key, @pstore_default_value)
|
|
151
|
+
return if value2 == @pstore_default_value
|
|
152
|
+
|
|
153
|
+
top = value2[@pstore_key]
|
|
154
|
+
profile = top[:profile]
|
|
155
|
+
categories = top[:categories]
|
|
156
|
+
# p "profile=#{profile}"
|
|
157
|
+
# p "categories.size=#{categories.size}"
|
|
158
|
+
# categories.map{ |x| puts x.label }
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def csv_to_db
|
|
162
|
+
ary = Pathname.new(@output_dir).children.sort_by(&:ctime)
|
|
163
|
+
latest_file = ary.last
|
|
164
|
+
f = latest_file.open
|
|
165
|
+
csv = CSV.new(f,
|
|
166
|
+
headers: true,
|
|
167
|
+
write_headers: true)
|
|
168
|
+
csv.each do |row|
|
|
169
|
+
category_id = row['category_id']
|
|
170
|
+
id = row['id']
|
|
171
|
+
count = row['count']
|
|
172
|
+
if !category_id.nil? && !id.nil? && !count.nil?
|
|
173
|
+
dbmgr_add(category_id, id, count)
|
|
174
|
+
else
|
|
175
|
+
p category_id
|
|
176
|
+
p id
|
|
177
|
+
p count
|
|
178
|
+
p '=='
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
76
182
|
end
|
|
77
183
|
end
|
data/lib/feedlrop/version.rb
CHANGED
data/lib/feedlrop.rb
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
#
|
|
2
|
-
require 'arxutils'
|
|
3
|
-
require "feedlrop/version"
|
|
4
|
-
require "feedlrop/feedlrop"
|
|
5
|
-
require "feedlrop/dbutil"
|
|
1
|
+
# frozen_string_literal: true
|
|
6
2
|
|
|
7
|
-
require '
|
|
3
|
+
require 'arxutils_sqlite3'
|
|
4
|
+
require_relative 'dbacrecord'
|
|
5
|
+
require_relative 'feedlrop/version'
|
|
6
|
+
require_relative 'feedlrop/feedlrop'
|
|
7
|
+
require_relative 'feedlrop/dbutil'
|
|
8
|
+
require_relative 'feedlrop/cli'
|
|
8
9
|
|
|
10
|
+
# Feedlr操作用モジュール
|
|
9
11
|
module Feedlrop
|
|
12
|
+
OUTPUT_DIR = "output"
|
|
13
|
+
# PSTORE_DIR = "pstore"
|
|
14
|
+
PSTORE_DIR = "pstore_2"
|
|
15
|
+
PSTORE_KEY = :TOP
|
|
10
16
|
end
|
|
11
|
-
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: feedlrop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.24
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- yasuo kominami
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-09-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: feedlr
|
|
@@ -25,7 +25,7 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: awesome_print
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
@@ -39,7 +39,7 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: faraday
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
@@ -53,21 +53,7 @@ dependencies:
|
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
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: awesome_print
|
|
56
|
+
name: arxutils_sqlite3
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
|
72
58
|
requirements:
|
|
73
59
|
- - ">="
|
|
@@ -84,30 +70,30 @@ dependencies:
|
|
|
84
70
|
name: bundler
|
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
|
86
72
|
requirements:
|
|
87
|
-
- - "
|
|
73
|
+
- - ">="
|
|
88
74
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
75
|
+
version: '0'
|
|
90
76
|
type: :development
|
|
91
77
|
prerelease: false
|
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
79
|
requirements:
|
|
94
|
-
- - "
|
|
80
|
+
- - ">="
|
|
95
81
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '
|
|
82
|
+
version: '0'
|
|
97
83
|
- !ruby/object:Gem::Dependency
|
|
98
84
|
name: rake
|
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
|
100
86
|
requirements:
|
|
101
|
-
- - "
|
|
87
|
+
- - ">="
|
|
102
88
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '
|
|
89
|
+
version: '0'
|
|
104
90
|
type: :development
|
|
105
91
|
prerelease: false
|
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
93
|
requirements:
|
|
108
|
-
- - "
|
|
94
|
+
- - ">="
|
|
109
95
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '
|
|
96
|
+
version: '0'
|
|
111
97
|
- !ruby/object:Gem::Dependency
|
|
112
98
|
name: rspec
|
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -126,35 +112,35 @@ description: utility functions for Feedly API.
|
|
|
126
112
|
email:
|
|
127
113
|
- ykominami@gmail.com
|
|
128
114
|
executables:
|
|
129
|
-
- f
|
|
130
115
|
- feedlrop
|
|
131
|
-
- makemigrate
|
|
132
116
|
extensions: []
|
|
133
117
|
extra_rdoc_files: []
|
|
134
118
|
files:
|
|
135
119
|
- ".gitignore"
|
|
136
120
|
- ".rspec"
|
|
121
|
+
- ".rubocop.yml"
|
|
122
|
+
- ".rubocop_todo.yml"
|
|
123
|
+
- ".ruby-version"
|
|
137
124
|
- ".travis.yml"
|
|
138
125
|
- Gemfile
|
|
139
126
|
- README.md
|
|
140
127
|
- Rakefile
|
|
141
128
|
- bin/console
|
|
142
129
|
- bin/setup
|
|
143
|
-
- exe/f
|
|
144
130
|
- exe/feedlrop
|
|
145
|
-
- exe/makemigrate
|
|
146
131
|
- f.bat
|
|
147
132
|
- feedlrop.gemspec
|
|
148
133
|
- lib/feedlrop.rb
|
|
134
|
+
- lib/feedlrop/cli.rb
|
|
149
135
|
- lib/feedlrop/dbutil.rb
|
|
150
|
-
- lib/feedlrop/dbutil/dbmgr.rb
|
|
151
136
|
- lib/feedlrop/dbutil/feedlropmgr.rb
|
|
152
137
|
- lib/feedlrop/feedlrop.rb
|
|
153
138
|
- lib/feedlrop/version.rb
|
|
154
139
|
homepage: ''
|
|
155
140
|
licenses:
|
|
156
141
|
- MIT
|
|
157
|
-
metadata:
|
|
142
|
+
metadata:
|
|
143
|
+
rubygems_mfa_required: 'true'
|
|
158
144
|
post_install_message:
|
|
159
145
|
rdoc_options: []
|
|
160
146
|
require_paths:
|
|
@@ -163,15 +149,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
163
149
|
requirements:
|
|
164
150
|
- - ">="
|
|
165
151
|
- !ruby/object:Gem::Version
|
|
166
|
-
version:
|
|
152
|
+
version: 2.6.10
|
|
167
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
154
|
requirements:
|
|
169
155
|
- - ">="
|
|
170
156
|
- !ruby/object:Gem::Version
|
|
171
157
|
version: '0'
|
|
172
158
|
requirements: []
|
|
173
|
-
|
|
174
|
-
rubygems_version: 2.4.5.1
|
|
159
|
+
rubygems_version: 3.0.3.1
|
|
175
160
|
signing_key:
|
|
176
161
|
specification_version: 4
|
|
177
162
|
summary: utility functions for Feedly API.
|
data/exe/f
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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.get_all_unread_count
|
|
24
|
-
fo.print_user_profile
|
|
25
|
-
fo.print_subscription
|
|
26
|
-
|
|
27
|
-
|
data/exe/makemigrate
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
require 'arxutils'
|
|
5
|
-
require 'feedlrop'
|
|
6
|
-
|
|
7
|
-
db_def_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
|
-
db_def_ary,
|
|
39
|
-
0,
|
|
40
|
-
dbconfig,
|
|
41
|
-
forced
|
|
42
|
-
)
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|