hanamimastery-cli 0.1.0 → 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: 6ae25baa5d3d87c5333041908310b6f87a98ea85d6a9258f343a3e1808b132d6
4
- data.tar.gz: 91b373599d85a21a6c5e69da01415fe2bd71191fe7b540c0a9496f0fbbe7a00a
3
+ metadata.gz: 0a6ef215794101a805fd2c02baa42bf1e4dc4d650bf79ab2ff37d51684b29d2f
4
+ data.tar.gz: 4f5b2dbfc130bfc0594c76b727dc6555d256f41d58deac6356895b36609fcc4f
5
5
  SHA512:
6
- metadata.gz: 56b10b253dfe0d66669fc13f550ae5c17b0ec70163e00f3fb722e5015eca0a1d989d75b55f6db439b76d727bf35c2c1cb66fc30e225d8630068d4a194ac1951a
7
- data.tar.gz: 79490b4b3a6c83c55add602361c48c8ca3104563d820aa716a36878d573f67b197d7bca7c5ea8b14f53665b3014a8af63d0b4d340192029f75e51e454efb0bee
6
+ metadata.gz: 2224bcd98c1e61a7ca7e92e1f89da9183c326861c84eb1e22420ddd364b0873623d932b52e5ecf90d77099ff735dd9993764b385f8f762274d691de7df47a741
7
+ data.tar.gz: 1d151f4f96507f5c8450eb43d4e250b229ce1737da965977fc577beb591fa599e55c76873347a3555f3296e550b4b50e94a6092a69be48361d49e412b5161d33
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hanamimastery-cli (0.1.0)
4
+ hanamimastery-cli (0.2.0)
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
@@ -12,6 +12,7 @@ module Hanamimastery
12
12
  end
13
13
  config.inflector = Dry::Inflector.new do |inflections|
14
14
  inflections.acronym('CLI')
15
+ inflections.acronym('PRO')
15
16
  end
16
17
  end
17
18
  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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Hanamimastery
4
4
  module CLI
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -13,5 +13,6 @@ module Hanamimastery
13
13
 
14
14
  register 'touch', Commands::Touch
15
15
  register 'unshot', Commands::Unshot
16
+ register 'pro', Commands::ToPRO
16
17
  end
17
18
  end
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.0
4
+ version: 0.2.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-03 00:00:00.000000000 Z
11
+ date: 2023-01-19 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