hanamimastery-cli 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36c410a4c1317266697eba1d58732b9b1e018a2ddc51b0a8cfafbe0c8780317d
4
- data.tar.gz: e6b2466740c7500812cc6b515dcd67331a555c0c6cb6414b6a0f33f10fd0c7e7
3
+ metadata.gz: 6f56928a78087f1f81bbfb204a6a7fe99a9699f3d2d5548e6c62dbcb8ced937e
4
+ data.tar.gz: 3cde3782ed0e096ebc60646478824f04265c6b8d5ab5438f1355983862fc55c8
5
5
  SHA512:
6
- metadata.gz: d33b85682cc980154071ee7091e4450f0c5c41a68c1e877b10b8175c599a7845e13befcaa0a0bdb492e35f3f2c5b47c41c38f47c3e77059dec2bab967e8c69ca
7
- data.tar.gz: b36792d64bf0871c77aeec43209ba043dfc6befb73e0a3b46fc1a1a731278ddd83b9c75329484fd6c7ef698d84b5291bcdb0f6cfc7efbc46670c1c91c47bd2db
6
+ metadata.gz: 57472d81ba5d1a57dbde932ecef22251167504f4cf162bb23e8a04f0b02131e88ad17e1e850a3cecdbd61a13423808c42d7ffb8c886f22157d715c759de48a9f
7
+ data.tar.gz: 5b2ecf88571395e9446f01385ee51617040d1ba6d5a0fb4ddf4b7756ba407f365e3a9c7dcba66f49d12a926a1bc4dad654c655a3ca855d9ab30d5f667d3bdc13
data/CHANGELOG.md CHANGED
@@ -25,3 +25,12 @@ Added new command to render HTML version of premium episodes.
25
25
 
26
26
  **PRO**
27
27
  Transformes episode's markdown into HTML ready to be used in Podia editor.
28
+
29
+
30
+ ## [0.2.1] - 2023-01-20
31
+
32
+ - Fixed incorrect dependency loading key
33
+
34
+ ## [0.2.2] - 2023-01-20
35
+
36
+ - Improved zeitwer configuration for file loading
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hanamimastery-cli (0.2.1)
4
+ hanamimastery-cli (0.3.0)
5
5
  commonmarker (~> 1.0.0.pre6)
6
6
  dry-cli (<= 1.0)
7
7
  dry-configurable (~> 1.0)
data/exe/hanamimastery CHANGED
@@ -4,6 +4,8 @@
4
4
  require "bundler/setup"
5
5
  require "hanamimastery/cli"
6
6
 
7
+ Hanamimastery::CLI::Container.finalize!
8
+
7
9
  cli = Dry::CLI.new(Hanamimastery::CLI)
8
10
 
9
11
  cli.call
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanamimastery
4
+ module CLI
5
+ module Commands
6
+ class ToNotion < Dry::CLI::Command
7
+ desc 'Renders HTML out of Markdown'
8
+ argument :episode, type: :integer, required: :true, desc: "Episode's ID to render"
9
+ option :save, aliases: ['-s'], type: :boolean, default: false, desc: 'Save to file?'
10
+
11
+ include Deps[
12
+ repository: 'repositories.episodes',
13
+ transformation: 'transformations.to_pro'
14
+ ]
15
+
16
+ def call(episode:, save:, **)
17
+ content = repository.fetch(episode).content
18
+ processed = transformation.call(content)
19
+ save ? File.write("#{episode}-episode.html", processed) : puts(processed)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -16,7 +16,7 @@ module Hanamimastery
16
16
  def call(episode:, save:, **)
17
17
  content = repository.fetch(episode).content
18
18
  processed = transformation.call(content)
19
- save ? File.write("#{episode}-episode.html", processed) : puts(processed)
19
+ repository.replace(episode, processed)
20
20
  end
21
21
  end
22
22
  end
@@ -7,13 +7,24 @@ module Hanamimastery
7
7
  use :zeitwerk
8
8
 
9
9
  configure do |config|
10
- config.component_dirs.add "lib" do |dir|
11
- dir.namespaces.add "hanamimastery/cli", key: nil
12
- end
10
+ root = File.expand_path("../../..", __dir__)
11
+ config.root = root
12
+ config.autoloader.tag = "hanamimastery-cli"
13
+ config.autoloader.inflector = Zeitwerk::GemInflector.new("#{root}/hanamimastery-cli.rb")
14
+ config.autoloader.push_dir(root)
15
+ config.autoloader.ignore(
16
+ "#{root}/hanamimastery-cli.rb",
17
+ "#{root}/hanamimastery/cli/{errors,version,deps,container}.rb"
18
+ )
19
+
13
20
  config.inflector = Dry::Inflector.new do |inflections|
14
21
  inflections.acronym('CLI')
15
22
  inflections.acronym('PRO')
16
23
  end
24
+
25
+ config.component_dirs.add 'lib' do |dir|
26
+ dir.namespaces.add "hanamimastery/cli", key: nil
27
+ end
17
28
  end
18
29
  end
19
30
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Hanamimastery
4
4
  module CLI
5
- class Error < StandardError; end
5
+ module Errors
6
+ class BaseError < StandardError; end
7
+ end
6
8
  end
7
9
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'commonmarker'
4
+
5
+ module Hanamimastery
6
+ module CLI
7
+ module Transformations
8
+ class ToPRO
9
+ # TODO: Make it Configurable
10
+ HOST = "https://hanamimastery.com"
11
+
12
+ # Transforms Markdown input to output compatible with Notion
13
+ #
14
+ def call(id, content)
15
+ image_patern = /\!(\[\[)(.+)(\]\])/
16
+ result
17
+ .gsub(image_pattern, "![#{'\2'.humanize.tr('-', ''))}](#{HOST}/images/episodes/#{id})")
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Hanamimastery
4
4
  module CLI
5
- VERSION = "0.2.1"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
@@ -1,16 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'dry/cli'
4
+ require 'hanamimastery/cli/version'
5
+ require 'hanamimastery/cli/errors'
6
+ require 'hanamimastery/cli/deps'
4
7
 
5
8
  module Hanamimastery
6
9
  module CLI
7
- require_relative 'cli/version'
8
- require_relative 'cli/error'
9
- require_relative 'cli/deps'
10
- require_relative 'cli/commands'
11
-
12
10
  extend Dry::CLI::Registry
13
-
14
11
  register 'touch', Commands::Touch
15
12
  register 'unshot', Commands::Unshot
16
13
  register 'pro', Commands::ToPRO
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'hanamimastery/cli'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanamimastery-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Wilgosz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-20 00:00:00.000000000 Z
11
+ date: 2023-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -100,15 +100,18 @@ files:
100
100
  - README.md
101
101
  - Rakefile
102
102
  - exe/hanamimastery
103
+ - lib/hanamimastery-cli.rb
103
104
  - lib/hanamimastery/cli.rb
104
105
  - lib/hanamimastery/cli/commands.rb
106
+ - lib/hanamimastery/cli/commands/to_notion.rb
105
107
  - lib/hanamimastery/cli/commands/to_pro.rb
106
108
  - lib/hanamimastery/cli/commands/touch.rb
107
109
  - lib/hanamimastery/cli/commands/unshot.rb
108
110
  - lib/hanamimastery/cli/container.rb
109
111
  - lib/hanamimastery/cli/deps.rb
110
- - lib/hanamimastery/cli/error.rb
112
+ - lib/hanamimastery/cli/errors.rb
111
113
  - lib/hanamimastery/cli/repositories/episodes.rb
114
+ - lib/hanamimastery/cli/transformations/to_notion.rb
112
115
  - lib/hanamimastery/cli/transformations/to_pro.rb
113
116
  - lib/hanamimastery/cli/transformations/touch.rb
114
117
  - lib/hanamimastery/cli/transformations/unshot.rb
@@ -137,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
140
  - !ruby/object:Gem::Version
138
141
  version: '0'
139
142
  requirements: []
140
- rubygems_version: 3.4.1
143
+ rubygems_version: 3.4.12
141
144
  signing_key:
142
145
  specification_version: 4
143
146
  summary: Command line p