fyodor 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d872937f2af8449f6858977455d787a4eee86a4c18d53c32eca0e66476d03fec
4
- data.tar.gz: 5450a2700766580a2ca8df55b1d6135fa22ff368c1536dae891727bee09186bc
3
+ metadata.gz: e6be6cab905375c4a8adfb19399fa61bbdfdb15379544a9db64bff916c646d05
4
+ data.tar.gz: bfc78376508d68b62f97659e819b4ddfe1f14cb8a512036bd5e8eabad2fdbb83
5
5
  SHA512:
6
- metadata.gz: a74ab203ef2bdbdcb6aa69cd62be47c24d21592f891e9eade4935a61351432c788efdcf1bb87ceed287928334f781a4b1fc21c700c63983466cbc1812a0fa1be
7
- data.tar.gz: 96928dac9ae5c258fccb4ca0f2258238daf1ae01208086ccd1f79df590c54a4aa1306ed5645d58df8e82410dba626e6ebdfd31efcf04cf2d6d76bf0c6eef419d
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
- # Supress stack trace
6
- begin
5
+ # Pass --trace to get the stack trace
6
+ if ARGV.include?("--trace")
7
+ ARGV.delete("--trace")
7
8
  Fyodor::CLI.new.main
8
- rescue StandardError => e
9
- abort(e.message)
9
+ else
10
+ begin
11
+ Fyodor::CLI.new.main
12
+ rescue StandardError => e
13
+ abort(e.message)
14
+ end
10
15
  end
@@ -1,12 +1,14 @@
1
- require_relative "config_getter"
2
- require_relative "stats_printer"
3
- require_relative "library"
4
- require_relative "clippings_parser"
5
- require_relative "output_writer"
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])
@@ -1,11 +1,9 @@
1
- require_relative "core_extensions/hash/merging"
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 ||= PATHS.find { |path| path.exist? }
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
@@ -1,4 +1,4 @@
1
- require_relative "entry"
1
+ require "fyodor/entry"
2
2
 
3
3
  module Fyodor
4
4
  class EntryParser
@@ -1,4 +1,4 @@
1
- require_relative "book"
1
+ require "fyodor/book"
2
2
  require "forwardable"
3
3
 
4
4
  module Fyodor
@@ -1,4 +1,4 @@
1
- require_relative "strings"
1
+ require "fyodor/strings"
2
2
 
3
3
  module Fyodor
4
4
  class MdGenerator
@@ -1,4 +1,4 @@
1
- require_relative "md_generator"
1
+ require "fyodor/md_generator"
2
2
 
3
3
  module Fyodor
4
4
  class OutputWriter
@@ -1,4 +1,4 @@
1
- require_relative "strings"
1
+ require "fyodor/strings"
2
2
 
3
3
  module Fyodor
4
4
  class StatsPrinter
@@ -1,4 +1,4 @@
1
- require_relative "entry"
1
+ require "fyodor/entry"
2
2
 
3
3
  module Fyodor
4
4
  module Strings
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.1.1
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-17 00:00:00.000000000 Z
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.0.3
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.0.3
26
+ version: '0.1'
27
27
  description: Parse Kindle clippings into markdown files
28
28
  email: code@rafaelc.org
29
29
  executables: