fyodor 0.1.1 → 0.2.0
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 +4 -4
- data/bin/fyodor +9 -4
- data/lib/fyodor/cli.rb +8 -9
- data/lib/fyodor/config_getter.rb +11 -5
- data/lib/fyodor/entry_parser.rb +1 -1
- data/lib/fyodor/library.rb +1 -1
- data/lib/fyodor/md_generator.rb +1 -1
- data/lib/fyodor/output_writer.rb +1 -1
- data/lib/fyodor/stats_printer.rb +1 -1
- data/lib/fyodor/strings.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6be6cab905375c4a8adfb19399fa61bbdfdb15379544a9db64bff916c646d05
|
4
|
+
data.tar.gz: bfc78376508d68b62f97659e819b4ddfe1f14cb8a512036bd5e8eabad2fdbb83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0db8ca71d80e837939ac0d40165eaade2b08671e816e2e3ca81ead4830f56efe88ede3849557b4355f307edf4e2119235ed15e8fc9f6fb4558d2a98d4cd4feff
|
7
|
+
data.tar.gz: ef6eafa1e8006b73f0316cb60efb684846ba9c14cacaefcfc1851969be2302a3b303044d977e18f865f7231b6c558f5aedd064d99c7eb84e71e6660bf09b6911
|
data/bin/fyodor
CHANGED
@@ -2,9 +2,14 @@
|
|
2
2
|
|
3
3
|
require "fyodor/cli"
|
4
4
|
|
5
|
-
#
|
6
|
-
|
5
|
+
# Pass --trace to get the stack trace
|
6
|
+
if ARGV.include?("--trace")
|
7
|
+
ARGV.delete("--trace")
|
7
8
|
Fyodor::CLI.new.main
|
8
|
-
|
9
|
-
|
9
|
+
else
|
10
|
+
begin
|
11
|
+
Fyodor::CLI.new.main
|
12
|
+
rescue StandardError => e
|
13
|
+
abort(e.message)
|
14
|
+
end
|
10
15
|
end
|
data/lib/fyodor/cli.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
require "fyodor/config_getter"
|
2
|
+
require "fyodor/stats_printer"
|
3
|
+
require "fyodor/library"
|
4
|
+
require "fyodor/clippings_parser"
|
5
|
+
require "fyodor/output_writer"
|
6
6
|
require "pathname"
|
7
7
|
|
8
8
|
module Fyodor
|
9
9
|
class CLI
|
10
|
+
USAGE = "Usage: #{File.basename($0)} my_clippings_path [output_dir]"
|
11
|
+
|
10
12
|
def initialize
|
11
13
|
get_args
|
12
14
|
@config = ConfigGetter.new.config
|
@@ -23,10 +25,7 @@ module Fyodor
|
|
23
25
|
private
|
24
26
|
|
25
27
|
def get_args
|
26
|
-
if ARGV.count != 1 && ARGV.count != 2
|
27
|
-
puts "Usage: #{File.basename($0)} my_clippings_path [output_dir]"
|
28
|
-
exit 1
|
29
|
-
end
|
28
|
+
abort(USAGE) if ARGV.count != 1 && ARGV.count != 2
|
30
29
|
|
31
30
|
@clippings_path = get_path(ARGV[0])
|
32
31
|
@output_dir = ARGV[1].nil? ? default_output_dir : get_path(ARGV[1])
|
data/lib/fyodor/config_getter.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
|
1
|
+
require "fyodor/core_extensions/hash/merging"
|
2
2
|
require "pathname"
|
3
3
|
require "toml"
|
4
4
|
|
5
5
|
module Fyodor
|
6
6
|
class ConfigGetter
|
7
|
-
PATHS = [Pathname.new(__FILE__).dirname + "../fyodor.toml",
|
8
|
-
Pathname.new("~/.config/fyodor.toml").expand_path]
|
9
7
|
DEFAULT = {
|
10
8
|
"parser" => {
|
11
9
|
"highlight" => "Your Highlight",
|
@@ -30,14 +28,22 @@ module Fyodor
|
|
30
28
|
|
31
29
|
def get_config
|
32
30
|
Hash.include CoreExtensions::Hash::Merging
|
33
|
-
|
34
31
|
print_path
|
32
|
+
|
35
33
|
user_config = path.nil? ? {} : TOML.load_file(path)
|
36
34
|
DEFAULT.deep_merge(user_config)
|
37
35
|
end
|
38
36
|
|
39
37
|
def path
|
40
|
-
@path ||=
|
38
|
+
@path ||= paths.find { |path| path.exist? }
|
39
|
+
end
|
40
|
+
|
41
|
+
def paths
|
42
|
+
return @paths unless @paths.nil?
|
43
|
+
|
44
|
+
@paths = []
|
45
|
+
@paths << Pathname.new(ENV["XDG_CONFIG_HOME"]) + "fyodor.toml" unless ENV["XDG_CONFIG_HOME"].nil?
|
46
|
+
@paths << Pathname.new("~/.config/fyodor.toml").expand_path
|
41
47
|
end
|
42
48
|
|
43
49
|
def print_path
|
data/lib/fyodor/entry_parser.rb
CHANGED
data/lib/fyodor/library.rb
CHANGED
data/lib/fyodor/md_generator.rb
CHANGED
data/lib/fyodor/output_writer.rb
CHANGED
data/lib/fyodor/stats_printer.rb
CHANGED
data/lib/fyodor/strings.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fyodor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Cavalcanti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: toml
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.1'
|
27
27
|
description: Parse Kindle clippings into markdown files
|
28
28
|
email: code@rafaelc.org
|
29
29
|
executables:
|