ossy 0.2.0 → 0.3.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: 42f272fd7b46f44fe9cc14fe50f7eb4a845a02a09c609c3b8f3c24281abddafc
4
- data.tar.gz: ed9a25034d678b97d02e3096a4e067dc46c94ed93c4c7b7f06a143362911a8e7
3
+ metadata.gz: 888c62267952b5f24a66741016179765c541c7fe9f28576ed892484b48e4ce52
4
+ data.tar.gz: '01885a2a26f4b3c8e02be23419c9165ade07ed4aeedd2c047c537d4793cd61f9'
5
5
  SHA512:
6
- metadata.gz: 1a4dea604320619051ae8f6ced4993151c5e34eb7c8c9bf578359d73dc6e32bf5f7fed0fdee50d5003f60ec79d8b14844f5d7790134b9344053e91a726e55f5e
7
- data.tar.gz: 16a3cbfbb40242064668e2b6167d07e3c4a7f019594f3da3d84dde2c74d689807171492a7cc5457072e502bb4899c13cac2ae97b713243a828c3e2b21d7aba1f
6
+ metadata.gz: a62e32830553990689776251581d2c9bdc91e3f3b40dee67b2c1f0fccfe114774ae9ad67552f92b6a10222a1484455c26251fc781d4bb5fa2478fd5264ee538c
7
+ data.tar.gz: 900e60b374b75b8ea0e957b60938fb9c6a3571136b111cef7731e4b113a950565ad33908279e5bacd11c33b9fdc99cca757e3ae6819cd094c4522bd3fd1af321
@@ -16,6 +16,8 @@ module Ossy
16
16
  require "ossy/cli/changelogs/generate"
17
17
  require "ossy/cli/changelogs/update"
18
18
 
19
+ require "ossy/cli/releases/generate"
20
+
19
21
  require "ossy/cli/configs/merge"
20
22
 
21
23
  require "ossy/cli/templates/compile"
@@ -37,6 +39,10 @@ module Ossy
37
39
  changelogs.register "update", Changelogs::Update, aliases: %w[u]
38
40
  end
39
41
 
42
+ register "releases", aliases: %w[r] do |releases|
43
+ releases.register "generate", Releases::Generate, aliases: %w[g]
44
+ end
45
+
40
46
  register "configs", aliases: %w[c] do |configs|
41
47
  configs.register "merge", Configs::Merge, aliases: %w[m]
42
48
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ossy/cli/commands/core"
4
+ require "ossy/import"
5
+ require "ossy/release"
6
+
7
+ require "yaml"
8
+ require "tilt"
9
+ require "ostruct"
10
+
11
+ module Ossy
12
+ module CLI
13
+ module Releases
14
+ class Context < OpenStruct
15
+ def self.new(data)
16
+ super(releases: [data.map(&Release).first])
17
+ end
18
+
19
+ def update(hash)
20
+ hash.each { |k, v| self[k.to_sym] = v }
21
+ self
22
+ end
23
+ end
24
+
25
+ class Generate < Commands::Core
26
+ desc "Generates a release markdown file from a changelog.yml file"
27
+
28
+ argument :config_path, required: true, desc: "The path to the changelog config"
29
+ argument :output_path, required: true, desc: "The path to the output md file"
30
+ argument :template_path, required: true, desc: "The path to the changelog ERB template"
31
+
32
+ def call(config_path:, output_path:, template_path:, data_path: nil)
33
+ puts "Generating #{output_path} from #{config_path} using #{template_path}"
34
+
35
+ ctx_data = YAML.load_file(config_path)
36
+ template = Tilt.new(template_path)
37
+
38
+ context = Context.new(ctx_data)
39
+
40
+ if data_path
41
+ key = File.basename(data_path).gsub(".yml", "")
42
+ data = YAML.load_file(data_path)
43
+
44
+ context.update(key => OpenStruct.new(data))
45
+ end
46
+
47
+ output = template.render(context)
48
+
49
+ File.write(output_path, "#{output.strip}\n")
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ossy
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ossy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-02 00:00:00.000000000 Z
11
+ date: 2021-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -199,6 +199,7 @@ files:
199
199
  - lib/ossy/cli/github/tagger.rb
200
200
  - lib/ossy/cli/github/update_file.rb
201
201
  - lib/ossy/cli/github/workflow.rb
202
+ - lib/ossy/cli/releases/generate.rb
202
203
  - lib/ossy/cli/templates/compile.rb
203
204
  - lib/ossy/container.rb
204
205
  - lib/ossy/github/client.rb