bkmrq 0.0.2 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8634093579553dbf24bccae5aea2028ad55ac67dd189a9c52d583069a4675748
4
- data.tar.gz: 023a1c37aa64a72dd7f754ccbe730f44c71ed355e03219515431ad91a11051fa
3
+ metadata.gz: 7604f5591402564df015fe49292a7f0a796449d06da7e0629fafdbd8eba00917
4
+ data.tar.gz: 91969416823b5f17a9b776a41f4e9441960a6d7b748ec9d0e2b9cd6f130e2060
5
5
  SHA512:
6
- metadata.gz: 6518627468fc14ee99c2f38f1f40e5b73d875cba7c29c3fe994ceedf026176ba30f8df4b85f657d20146a38df23b93b92052fa5dc6f426c6729f5bc94b2a0de8
7
- data.tar.gz: a929707641a9efb193c81f29dd3177b898dfc6e155c5376b0eb43a33a73a96d991a5b9769ec4511df77b9a1d854e727fe06697b65eae90ce4bd2de95537cbca4
6
+ metadata.gz: f08759adf91f263b6671581bd431d985396b596a79ca1e2f1f93b1fcadda4b36e20f25740c8d9854ef6a1100e3592adb6a0f12de5ed072e9c84dbfa8832baa68
7
+ data.tar.gz: d2208c4a470c2a8e093100c3542ad0ea9b26191760d9059c30fda5fab30d14bb9c49c45d2ea31b232c766564b7758d07435f8c7e5df0d51944cce88bb5c247a8
data/bin/bkmrq CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
5
  require 'bkmrq/cli'
5
-
6
6
  Bkmrq::Cli.new(ARGV)
data/lib/bkmrq/app.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
+ require 'fileutils'
4
5
  require 'bkmrq/docs_template'
5
6
  require 'bkmrq/browser_config'
6
7
 
@@ -9,8 +10,9 @@ module Bkmrq
9
10
  class App
10
11
  BLOCKLIST = ENV.fetch('BKMRQ_BLOCKLIST', '(pdf|google|file:)').split(',').map(&:strip)
11
12
 
12
- def initialize(browser: :brave, bookmarks_input: nil)
13
- @bookmarks_input = bookmarks_input || Bkmrq::BROWSER_CONFIG.dig(browser, :bookmark_file_path)
13
+ def initialize(browser: nil, input_file: nil, output_path: nil, edit: false)
14
+ @bookmarks_input = input_file || Bkmrq::BROWSER_CONFIG.dig(browser, :bookmark_file_path)
15
+ @output_path = output_path || FileUtils.pwd
14
16
  end
15
17
 
16
18
  def export!
@@ -25,7 +27,7 @@ module Bkmrq
25
27
 
26
28
  def output_file
27
29
  @output_file ||= ::File.open(
28
- "bkmrq_export_#{String(Integer(Time.now))[0..-2]}.md",
30
+ File.join(@output_path, "bkmrq_export_#{String(Integer(Time.now))[0..-2]}.md"),
29
31
  'w+'
30
32
  )
31
33
  end
@@ -66,7 +68,6 @@ module Bkmrq
66
68
 
67
69
  def generate_bookmark_title(bookmark, level)
68
70
  [
69
- ' ' * level,
70
71
  '#' * level,
71
72
  "#{bookmark['name']}\n"
72
73
  ].join(' ')
@@ -74,7 +75,7 @@ module Bkmrq
74
75
 
75
76
  def generate_bookmark_link(bookmark, level)
76
77
  [
77
- ' ' * level,
78
+ ' ' * (level % 2),
78
79
  "[#{bookmark['name']}](#{bookmark['url']}) \n"
79
80
  ].join(' ')
80
81
  end
@@ -17,7 +17,8 @@ module Bkmrq
17
17
  }.freeze
18
18
 
19
19
  BROWSER_CONFIG = {
20
- brave: BRAVE_BROWSER_CONFIG,
21
- chrome: CHROME_BROWSER_CONFIG
20
+ 'brave' => BRAVE_BROWSER_CONFIG,
21
+ 'chrome' => CHROME_BROWSER_CONFIG,
22
+ 'chromium' => CHROME_BROWSER_CONFIG
22
23
  }.freeze
23
24
  end
data/lib/bkmrq/cli.rb CHANGED
@@ -11,17 +11,24 @@ module Bkmrq
11
11
  class Cli
12
12
  def initialize(args)
13
13
  @opts = {}
14
- option_parser.parse!(sanitize_args(args), into: @opts)
14
+ option_parser.parse!(default_args(sanitize_args(args)), into: @opts)
15
+ init_app if opts_valid?
15
16
  end
16
17
 
17
18
  private
18
19
 
20
+ def init_app
21
+ Bkmrq::App.new(
22
+ **@opts.slice(*Bkmrq::Manual.options_specs.map(&:last))
23
+ ).export!
24
+ end
25
+
19
26
  def option_parser
20
27
  @option_parser ||= OptionParser.new do |args|
21
28
  # Option Parsing
22
29
  Bkmrq::Manual.options_specs.map do |option_spec|
23
30
  option_key = option_spec.pop
24
- args.on(*option_spec) { |input| @opts.send(:[]=, option_key, input) }
31
+ args.on(*option_spec) { |input| @opts[option_key] = input }
25
32
  end
26
33
 
27
34
  # Manual Printing
@@ -33,5 +40,13 @@ module Bkmrq
33
40
  def sanitize_args(args)
34
41
  args.reject(&:empty?).map(&:scrub).map(&:split).flatten
35
42
  end
43
+
44
+ def default_args(args)
45
+ args.empty? ? ['-H'] : args
46
+ end
47
+
48
+ def opts_valid?
49
+ !@opts.key?(:help)
50
+ end
36
51
  end
37
52
  end
data/lib/bkmrq/manual.rb CHANGED
@@ -26,7 +26,8 @@ module Bkmrq
26
26
  '-B BROWSER',
27
27
  '--browser BROWSER',
28
28
  String,
29
- 'Browser (Loads Default Configs)', :browser
29
+ 'Browser (Loads Default Configs)',
30
+ :browser
30
31
  ]
31
32
  end
32
33
 
@@ -36,7 +37,7 @@ module Bkmrq
36
37
  '--input-file FILE',
37
38
  String,
38
39
  'Bookmarks file generated by your browser. (JSON FORMAT ONLY)',
39
- :'input-file'
40
+ :input_file
40
41
  ]
41
42
  end
42
43
 
@@ -46,7 +47,7 @@ module Bkmrq
46
47
  '--output-file FILE',
47
48
  String,
48
49
  'Filepath for markdown generated by Bkmrq',
49
- :'output-file'
50
+ :output_path
50
51
  ]
51
52
  end
52
53
 
data/lib/bkmrq.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bkmrq
4
+ require 'bkmrq/app'
5
+ require 'bkmrq/browser_config'
6
+ require 'bkmrq/cli'
7
+ require 'bkmrq/docs_template'
8
+ require 'bkmrq/manual'
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bkmrq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sreedev Kodichath
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-04 00:00:00.000000000 Z
11
+ date: 2021-11-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Bkmrq Converts Bookmarks stored by your browser in JSON format to a readable
14
14
  markdown format
@@ -19,6 +19,7 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - bin/bkmrq
22
+ - lib/bkmrq.rb
22
23
  - lib/bkmrq/app.rb
23
24
  - lib/bkmrq/browser_config.rb
24
25
  - lib/bkmrq/cli.rb