hanamimastery-cli 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +5 -1
- data/lib/hanamimastery/cli/commands/to_pro.rb +24 -0
- data/lib/hanamimastery/cli/commands/unshot.rb +1 -1
- data/lib/hanamimastery/cli/container.rb +1 -0
- data/lib/hanamimastery/cli/repositories/episodes.rb +14 -0
- data/lib/hanamimastery/cli/transformations/to_pro.rb +25 -0
- data/lib/hanamimastery/cli/version.rb +1 -1
- data/lib/hanamimastery/cli.rb +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36c410a4c1317266697eba1d58732b9b1e018a2ddc51b0a8cfafbe0c8780317d
|
4
|
+
data.tar.gz: e6b2466740c7500812cc6b515dcd67331a555c0c6cb6414b6a0f33f10fd0c7e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d33b85682cc980154071ee7091e4450f0c5c41a68c1e877b10b8175c599a7845e13befcaa0a0bdb492e35f3f2c5b47c41c38f47c3e77059dec2bab967e8c69ca
|
7
|
+
data.tar.gz: b36792d64bf0871c77aeec43209ba043dfc6befb73e0a3b46fc1a1a731278ddd83b9c75329484fd6c7ef698d84b5291bcdb0f6cfc7efbc46670c1c91c47bd2db
|
data/CHANGELOG.md
CHANGED
@@ -14,3 +14,14 @@ Removes shot marks from a given article (i.e. ""[🎬 01] ")
|
|
14
14
|
|
15
15
|
**Touch**
|
16
16
|
Updates the modifiedAt with the current date
|
17
|
+
|
18
|
+
## [0.2.0] - 2023-01-19
|
19
|
+
|
20
|
+
- PRO command
|
21
|
+
|
22
|
+
Added new command to render HTML version of premium episodes.
|
23
|
+
|
24
|
+
### Features
|
25
|
+
|
26
|
+
**PRO**
|
27
|
+
Transformes episode's markdown into HTML ready to be used in Podia editor.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hanamimastery-cli (0.1
|
4
|
+
hanamimastery-cli (0.2.1)
|
5
|
+
commonmarker (~> 1.0.0.pre6)
|
5
6
|
dry-cli (<= 1.0)
|
6
7
|
dry-configurable (~> 1.0)
|
7
8
|
dry-system (~> 1.0)
|
@@ -11,6 +12,8 @@ GEM
|
|
11
12
|
remote: https://rubygems.org/
|
12
13
|
specs:
|
13
14
|
ast (2.4.2)
|
15
|
+
commonmarker (1.0.0.pre6-x86_64-darwin)
|
16
|
+
rb_sys (~> 0.9)
|
14
17
|
concurrent-ruby (1.1.10)
|
15
18
|
diff-lcs (1.5.0)
|
16
19
|
dry-auto_inject (1.0.0)
|
@@ -36,6 +39,7 @@ GEM
|
|
36
39
|
ast (~> 2.4.1)
|
37
40
|
rainbow (3.1.1)
|
38
41
|
rake (13.0.6)
|
42
|
+
rb_sys (0.9.54)
|
39
43
|
regexp_parser (2.6.1)
|
40
44
|
rexml (3.2.5)
|
41
45
|
rspec (3.12.0)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hanamimastery
|
4
|
+
module CLI
|
5
|
+
module Commands
|
6
|
+
class ToPRO < 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
|
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
module Hanamimastery
|
4
4
|
module CLI
|
5
|
+
module Entities
|
6
|
+
class Episode
|
7
|
+
def initialize(content)
|
8
|
+
starts_from = content.lines[1..-1].index("---\n") + 2
|
9
|
+
@content = content.lines[starts_from..-1].join
|
10
|
+
end
|
11
|
+
attr_reader :content
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
module Repositories
|
6
16
|
class Episodes
|
7
17
|
REPO_PATH = '/Users/Sebastian/Projects/hanamimastery/source'
|
@@ -21,6 +31,10 @@ module Hanamimastery
|
|
21
31
|
File.exists?(find(id))
|
22
32
|
end
|
23
33
|
|
34
|
+
def fetch(id)
|
35
|
+
Entities::Episode.new(read(id))
|
36
|
+
end
|
37
|
+
|
24
38
|
private
|
25
39
|
|
26
40
|
def file_name(id)
|
@@ -0,0 +1,25 @@
|
|
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 HTML output compatible with Podia.com editor
|
13
|
+
#
|
14
|
+
def call(content)
|
15
|
+
result = content.gsub(/:::(.*?):::/m, '')
|
16
|
+
result = Commonmarker.to_html(result)
|
17
|
+
result
|
18
|
+
.gsub('src="/images', %{src="#{HOST}/images})
|
19
|
+
.gsub(/<h\d>/, "<h1>")
|
20
|
+
.gsub(/<\/h\d>/, "</h1>")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/hanamimastery/cli.rb
CHANGED
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.1
|
4
|
+
version: 0.2.1
|
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-
|
11
|
+
date: 2023-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: commonmarker
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.0.pre6
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.0.0.pre6
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: zeitwerk
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,12 +102,14 @@ files:
|
|
88
102
|
- exe/hanamimastery
|
89
103
|
- lib/hanamimastery/cli.rb
|
90
104
|
- lib/hanamimastery/cli/commands.rb
|
105
|
+
- lib/hanamimastery/cli/commands/to_pro.rb
|
91
106
|
- lib/hanamimastery/cli/commands/touch.rb
|
92
107
|
- lib/hanamimastery/cli/commands/unshot.rb
|
93
108
|
- lib/hanamimastery/cli/container.rb
|
94
109
|
- lib/hanamimastery/cli/deps.rb
|
95
110
|
- lib/hanamimastery/cli/error.rb
|
96
111
|
- lib/hanamimastery/cli/repositories/episodes.rb
|
112
|
+
- lib/hanamimastery/cli/transformations/to_pro.rb
|
97
113
|
- lib/hanamimastery/cli/transformations/touch.rb
|
98
114
|
- lib/hanamimastery/cli/transformations/unshot.rb
|
99
115
|
- lib/hanamimastery/cli/version.rb
|