ossy 0.1.2 → 0.3.1

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: ed72b49fd31404f38c118558aa38f6f2e1469e3937d858c77a1bcb5585f94eff
4
- data.tar.gz: b1b364bc5a9b33da7ed7fabf0f648e7f74b47efc3922d3ca61d47995579f58b4
3
+ metadata.gz: 293d5356dff91ea8e81f4743a6d3b4a5e3a1811b1c3fe2e58ae44d741ea06bee
4
+ data.tar.gz: 5cfb961445bff9d039d42deac7a559eb43d9ed322f7c442e75f65d6ed3c749ca
5
5
  SHA512:
6
- metadata.gz: c050bd2e6d8ceab00e0617a66a363f44f2a9f1a81416c3de2f8a2f05fcb67b9f1cf544b47d15ea59d622bc0b4e2dc1490de4a9b95f43ce51cd3bde1b19902def
7
- data.tar.gz: 16e592ffe2465faf4bd4de7685dfc7c562735e2e65d1a814417f002a72aa1784c4127c159f74b2dc0be552c4dd6ef0b4dc9cba09da159952380f2f64e11d6553
6
+ metadata.gz: 4d8ded74f12c33f88f184ff43f7452710e29b5a22d8247335076f2784783c259a3d2e7382bef8b652821acfe4b186a258c94e7c442d7d9443645d3372761b0f6
7
+ data.tar.gz: e4d08d31c1cbb34f8da36a316603d89a7f3c7d2bb453b9c5e3425993e0e849650da1f021e7ba288dc863a6c1dedfb5a05b9d47414f8f6d0104257eaceec9f9f3
@@ -1,3 +1,21 @@
1
+ ## 0.2.0 2021-01-02
2
+
3
+ ### Added
4
+
5
+ - `configs merge` now supports merging array of hashes (@solnic)
6
+
7
+ ## 0.1.4 2020-01-23
8
+
9
+ ### Fixed
10
+
11
+ - `github workflow` no longer crashes after switching to `faraday` (@solnic)
12
+
13
+ ## 0.1.3 2020-01-23
14
+
15
+ ### Changed
16
+
17
+ - Switched from `http` to `faraday` as it has less dependencies (@solnic)
18
+
1
19
  ## 0.1.2 2020-01-23
2
20
 
3
21
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/version'
3
+ require "ossy/version"
4
4
 
5
5
  module Ossy
6
6
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/cli'
4
- require 'ossy/cli/commands'
3
+ require "dry/cli"
4
+ require "ossy/cli/commands"
5
5
 
6
6
  module Ossy
7
7
  module CLI
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/cli/commands/core'
4
- require 'ossy/import'
5
- require 'ossy/release'
3
+ require "ossy/cli/commands/core"
4
+ require "ossy/import"
5
+ require "ossy/release"
6
6
 
7
- require 'yaml'
8
- require 'tilt'
9
- require 'ostruct'
7
+ require "yaml"
8
+ require "tilt"
9
+ require "ostruct"
10
10
 
11
11
  module Ossy
12
12
  module CLI
@@ -23,13 +23,13 @@ module Ossy
23
23
  end
24
24
  end
25
25
 
26
- desc 'Generates a changelog markdown file from a yaml config'
26
+ desc "Generates a changelog markdown file from a yaml config"
27
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'
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
31
 
32
- option :data_path, required: false, desc: 'Optional path to additional data yaml file'
32
+ option :data_path, required: false, desc: "Optional path to additional data yaml file"
33
33
 
34
34
  def call(config_path:, output_path:, template_path:, data_path: nil)
35
35
  puts "Generating #{output_path} from #{config_path} using #{template_path}"
@@ -40,7 +40,7 @@ module Ossy
40
40
  context = Context.new(ctx_data)
41
41
 
42
42
  if data_path
43
- key = File.basename(data_path).gsub('.yml', '')
43
+ key = File.basename(data_path).gsub(".yml", "")
44
44
  data = YAML.load_file(data_path)
45
45
 
46
46
  context.update(key => OpenStruct.new(data))
@@ -1,19 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/cli/commands/core'
4
- require 'ossy/import'
5
- require 'ossy/release'
3
+ require "ossy/cli/commands/core"
4
+ require "ossy/import"
5
+ require "ossy/release"
6
6
 
7
- require 'yaml'
7
+ require "yaml"
8
8
 
9
9
  module Ossy
10
10
  module CLI
11
11
  module Changelogs
12
12
  class Update < Commands::Core
13
- desc 'Adds a new entry to a changelog config'
13
+ desc "Adds a new entry to a changelog config"
14
14
 
15
- argument :config_path, required: true, desc: 'The path to the changelog config'
16
- argument :message, required: true, desc: 'Message text including the entry'
15
+ argument :config_path, required: true, desc: "The path to the changelog config"
16
+ argument :message, required: true, desc: "Message text including the entry"
17
17
 
18
18
  KEYS = %w[version summary date fixed added changed].freeze
19
19
 
@@ -21,8 +21,8 @@ module Ossy
21
21
  attrs = YAML.load(message)
22
22
  target = YAML.load_file(config_path)
23
23
 
24
- version = attrs['version'] || target[0]['version']
25
- entry = target.detect { |e| e['version'].eql?(version) } || {}
24
+ version = attrs["version"] || target[0]["version"]
25
+ entry = target.detect { |e| e["version"].eql?(version) } || {}
26
26
 
27
27
  release = Release.new(attrs.merge(version: version))
28
28
 
@@ -1,44 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/cli/registry'
3
+ require "dry/cli/registry"
4
4
 
5
5
  module Ossy
6
6
  module CLI
7
7
  module Commands
8
8
  extend Dry::CLI::Registry
9
9
 
10
- require 'ossy/cli/github/workflow'
11
- require 'ossy/cli/github/membership'
12
- require 'ossy/cli/github/tagger'
13
- require 'ossy/cli/github/member'
14
- require 'ossy/cli/github/update_file'
10
+ require "ossy/cli/github/workflow"
11
+ require "ossy/cli/github/membership"
12
+ require "ossy/cli/github/tagger"
13
+ require "ossy/cli/github/member"
14
+ require "ossy/cli/github/update_file"
15
15
 
16
- require 'ossy/cli/changelogs/generate'
17
- require 'ossy/cli/changelogs/update'
16
+ require "ossy/cli/changelogs/generate"
17
+ require "ossy/cli/changelogs/update"
18
18
 
19
- require 'ossy/cli/configs/merge'
19
+ require "ossy/cli/releases/generate"
20
20
 
21
- require 'ossy/cli/templates/compile'
21
+ require "ossy/cli/configs/merge"
22
22
 
23
- register 'github', aliases: %w[gh] do |github|
24
- github.register 'workflow', Github::Workflow, aliases: %w[w]
25
- github.register 'membership', Github::Membership, aliases: %w[m]
26
- github.register 'tagger', Github::Tagger, aliases: %w[t]
27
- github.register 'member', Github::Member, aliases: %w[om]
28
- github.register 'update_file', Github::UpdateFile, aliases: %w[uf]
23
+ require "ossy/cli/templates/compile"
24
+
25
+ register "github", aliases: %w[gh] do |github|
26
+ github.register "workflow", Github::Workflow, aliases: %w[w]
27
+ github.register "membership", Github::Membership, aliases: %w[m]
28
+ github.register "tagger", Github::Tagger, aliases: %w[t]
29
+ github.register "member", Github::Member, aliases: %w[om]
30
+ github.register "update_file", Github::UpdateFile, aliases: %w[uf]
31
+ end
32
+
33
+ register "templates", aliases: %w[t] do |templates|
34
+ templates.register "compile", Templates::Compile, aliases: %w[c]
29
35
  end
30
36
 
31
- register 'templates', aliases: %w[t] do |templates|
32
- templates.register 'compile', Templates::Compile, aliases: %w[c]
37
+ register "changelogs", aliases: %w[ch] do |changelogs|
38
+ changelogs.register "generate", Changelogs::Generate, aliases: %w[g]
39
+ changelogs.register "update", Changelogs::Update, aliases: %w[u]
33
40
  end
34
41
 
35
- register 'changelogs', aliases: %w[ch] do |changelogs|
36
- changelogs.register 'generate', Changelogs::Generate, aliases: %w[g]
37
- changelogs.register 'update', Changelogs::Update, aliases: %w[u]
42
+ register "releases", aliases: %w[r] do |releases|
43
+ releases.register "generate", Releases::Generate, aliases: %w[g]
38
44
  end
39
45
 
40
- register 'configs', aliases: %w[c] do |configs|
41
- configs.register 'merge', Configs::Merge, aliases: %w[m]
46
+ register "configs", aliases: %w[c] do |configs|
47
+ configs.register "merge", Configs::Merge, aliases: %w[m]
42
48
  end
43
49
  end
44
50
  end
@@ -1,39 +1,61 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/cli/commands/core'
4
- require 'ossy/import'
3
+ require "ossy/cli/commands/core"
4
+ require "ossy/import"
5
5
 
6
- require 'yaml'
6
+ require "yaml"
7
7
 
8
8
  module Ossy
9
9
  module CLI
10
10
  module Configs
11
11
  class Merge < Commands::Core
12
- desc 'Merge two yaml config files into a new one'
12
+ desc "Merge two yaml config files into a new one"
13
13
 
14
- argument :source_path, required: true, desc: 'The path to the source file'
15
- argument :target_path, required: true, desc: 'The path to the target file'
16
- argument :output_path, required: true, desc: 'The path to the output file'
14
+ argument :source_path, required: true, desc: "The path to the source file"
15
+ argument :target_path, required: true, desc: "The path to the target file"
16
+ argument :output_path, required: true, desc: "The path to the output file"
17
17
 
18
- def call(source_path:, target_path:, output_path:)
18
+ option :identifiers, required: false, default: "",
19
+ desc: "Key identifier that should be used for merging arrays of hashes"
20
+
21
+ def call(source_path:, target_path:, output_path:, **opts)
19
22
  puts "Merging #{source_path} + #{target_path} into #{output_path}"
20
23
 
24
+ identifiers = opts[:identifiers].split(",").map { |s| s.split(":") }.to_h
25
+
21
26
  source = YAML.load_file(source_path)
22
27
  target = YAML.load_file(target_path)
23
28
 
24
- output = deep_merge(source, target)
29
+ output = deep_merge(source, target, identifiers)
25
30
 
26
31
  File.write(output_path, YAML.dump(output))
27
32
  end
28
33
 
29
34
  private
30
35
 
31
- def deep_merge(h1, h2, &block)
36
+ def deep_merge(h1, h2, identifiers, &block)
32
37
  h1.merge(h2) do |key, val1, val2|
33
38
  if val1.is_a?(Hash) && val2.is_a?(Hash)
34
- deep_merge(val1, val2, &block)
39
+ deep_merge(val1, val2, identifiers, &block)
35
40
  elsif val1.is_a?(Array) && val2.is_a?(Array)
36
- (val1 + val2).uniq
41
+ if (id = identifiers[key])
42
+ arr = (val1 + val2)
43
+ .group_by { |el| el.fetch(id) }
44
+ .values
45
+ .map { |arr| arr.size.equal?(2) ? deep_merge(*arr, identifiers) : arr }
46
+ .flatten(1)
47
+ .uniq
48
+
49
+ arr
50
+ .map
51
+ .with_index { |el, idx|
52
+ (after = el.delete("_after")) ?
53
+ [el, arr.index(arr.detect { |a| a[id].eql?(after) }) + 1] :
54
+ [el, idx]
55
+ }.sort_by(&:last).map(&:first)
56
+ else
57
+ (val1 + val2).uniq
58
+ end
37
59
  else
38
60
  val2
39
61
  end
@@ -1,24 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/cli/commands/core'
4
- require 'ossy/import'
3
+ require "ossy/cli/commands/core"
4
+ require "ossy/import"
5
5
 
6
6
  module Ossy
7
7
  module CLI
8
8
  module Github
9
9
  class Member < Commands::Core
10
- include Import['github.client']
10
+ include Import["github.client"]
11
11
 
12
- desc 'Return org member identified by the full name'
12
+ desc "Return org member identified by the full name"
13
13
 
14
- argument :name, required: true, desc: 'The member name'
15
- argument :org, required: true, desc: 'The org name'
14
+ argument :name, required: true, desc: "The member name"
15
+ argument :org, required: true, desc: "The org name"
16
16
 
17
17
  def call(name:, org:)
18
18
  result = client.member(name, org: org)
19
19
 
20
20
  if result
21
- puts result['login']
21
+ puts result["login"]
22
22
  end
23
23
  end
24
24
  end
@@ -1,26 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/cli/commands/core'
4
- require 'ossy/import'
3
+ require "ossy/cli/commands/core"
4
+ require "ossy/import"
5
5
 
6
6
  module Ossy
7
7
  module CLI
8
8
  module Github
9
9
  class Membership < Commands::Core
10
- include Import['github.client']
10
+ include Import["github.client"]
11
11
 
12
- desc 'Check if a given user has an active membership in a team'
12
+ desc "Check if a given user has an active membership in a team"
13
13
 
14
- argument :username, required: true, desc: 'The username'
15
- argument :org, required: true, desc: 'The name of the org'
16
- argument :team, required: true, desc: 'The name of the team'
14
+ argument :username, required: true, desc: "The username"
15
+ argument :org, required: true, desc: "The name of the org"
16
+ argument :team, required: true, desc: "The name of the team"
17
17
 
18
18
  option :verify, required: false
19
19
 
20
- def call(username:, org:, team:, verify: 'false')
20
+ def call(username:, org:, team:, verify: "false")
21
21
  result = client.membership?(username, org: org, team: team)
22
22
 
23
- if verify.eql?('true')
23
+ if verify.eql?("true")
24
24
  exit(1) unless result
25
25
  else
26
26
  puts "#{username} has active membership in #{org}/@#{team}"
@@ -1,24 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/cli/commands/core'
4
- require 'ossy/import'
3
+ require "ossy/cli/commands/core"
4
+ require "ossy/import"
5
5
 
6
6
  module Ossy
7
7
  module CLI
8
8
  module Github
9
9
  class Tagger < Commands::Core
10
- include Import['github.client']
10
+ include Import["github.client"]
11
11
 
12
- desc 'Return tagger email for a verified tag'
12
+ desc "Return tagger email for a verified tag"
13
13
 
14
- argument :repo, required: true, desc: 'The repo'
15
- argument :tag, required: true, desc: 'The tag name'
14
+ argument :repo, required: true, desc: "The repo"
15
+ argument :tag, required: true, desc: "The tag name"
16
16
 
17
17
  def call(repo:, tag:)
18
18
  result = client.tagger(repo: repo, tag: tag)
19
19
 
20
20
  if result && result[:verified].equal?(true)
21
- puts result[:tagger]['name']
21
+ puts result[:tagger]["name"]
22
22
  end
23
23
  end
24
24
  end
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/cli/commands/core'
4
- require 'open-uri'
3
+ require "ossy/cli/commands/core"
4
+ require "open-uri"
5
5
 
6
6
  module Ossy
7
7
  module CLI
8
8
  module Github
9
9
  class UpdateFile < Commands::Core
10
- desc 'Update provided file using a canonical source in another repository'
10
+ desc "Update provided file using a canonical source in another repository"
11
11
 
12
- argument(:repo, required: true, desc: 'Source repository')
13
- argument(:file, required: true, desc: 'File path ie owner/repo:path/to/file')
14
- option(:branch, required: false, desc: 'Branch name', default: 'master')
12
+ argument(:repo, required: true, desc: "Source repository")
13
+ argument(:file, required: true, desc: "File path ie owner/repo:path/to/file")
14
+ option(:branch, required: false, desc: "Branch name", default: "master")
15
15
 
16
16
  def call(repo:, file:, branch:)
17
17
  url = "https://raw.githubusercontent.com/#{repo}/#{branch}/shared/#{file}"
@@ -1,30 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
3
+ require "json"
4
4
 
5
- require 'ossy/cli/commands/core'
6
- require 'ossy/import'
5
+ require "ossy/cli/commands/core"
6
+ require "ossy/import"
7
7
 
8
8
  module Ossy
9
9
  module CLI
10
10
  module Github
11
11
  class Workflow < Commands::Core
12
- include Import['github.workflow']
12
+ include Import["github.workflow"]
13
13
 
14
- desc 'Start a GitHub workflow'
14
+ desc "Start a GitHub workflow"
15
15
 
16
- argument :repo, required: true, desc: 'The name of the repository on GitHub'
17
- argument :name, required: true, desc: 'The name of the workflow'
16
+ argument :repo, required: true, desc: "The name of the repository on GitHub"
17
+ argument :name, required: true, desc: "The name of the workflow"
18
18
 
19
- option :payload, required: false, desc: 'Optional client payload'
19
+ option :payload, required: false, desc: "Optional client payload"
20
20
 
21
21
  def call(repo:, name:, payload: "{}")
22
22
  puts "Requesting: #{repo} => #{name}"
23
23
 
24
24
  result = workflow.(repo, name, JSON.load(payload))
25
25
 
26
- if result.code.eql?(204)
27
- puts 'Success!'
26
+ if result.status.eql?(204)
27
+ puts "Success!"
28
28
  else
29
29
  puts "Failure! #{result.inspect}"
30
30
  end
@@ -0,0 +1,62 @@
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))
17
+ end
18
+
19
+ def latest_release
20
+ releases.first
21
+ end
22
+
23
+ def previous_release
24
+ releases[1]
25
+ end
26
+
27
+ def update(hash)
28
+ hash.each { |k, v| self[k.to_sym] = v }
29
+ self
30
+ end
31
+ end
32
+
33
+ class Generate < Commands::Core
34
+ desc "Generates a release markdown file from a changelog.yml file"
35
+
36
+ argument :config_path, required: true, desc: "The path to the changelog config"
37
+ argument :output_path, required: true, desc: "The path to the output md file"
38
+ argument :template_path, required: true, desc: "The path to the changelog ERB template"
39
+
40
+ def call(config_path:, output_path:, template_path:, data_path: nil)
41
+ puts "Generating #{output_path} from #{config_path} using #{template_path}"
42
+
43
+ ctx_data = YAML.load_file(config_path)
44
+ template = Tilt.new(template_path)
45
+
46
+ context = Context.new(ctx_data)
47
+
48
+ if data_path
49
+ key = File.basename(data_path).gsub(".yml", "")
50
+ data = YAML.load_file(data_path)
51
+
52
+ context.update(key => OpenStruct.new(data))
53
+ end
54
+
55
+ output = template.render(context)
56
+
57
+ File.write(output_path, "#{output.strip}\n")
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/inflector'
4
- require 'ossy/cli/commands/core'
5
- require 'ossy/import'
3
+ require "dry/inflector"
4
+ require "ossy/cli/commands/core"
5
+ require "ossy/import"
6
6
 
7
- require 'tilt'
8
- require 'erb'
9
- require 'yaml'
10
- require 'ostruct'
7
+ require "tilt"
8
+ require "erb"
9
+ require "yaml"
10
+ require "ostruct"
11
11
 
12
12
  module Ossy
13
13
  module CLI
@@ -15,7 +15,7 @@ module Ossy
15
15
  class Compile < Commands::Core
16
16
  class Context < OpenStruct
17
17
  Inflector = Dry::Inflector.new do |i|
18
- i.acronym 'CLI'
18
+ i.acronym "CLI"
19
19
  end
20
20
 
21
21
  def inflector
@@ -23,13 +23,13 @@ module Ossy
23
23
  end
24
24
  end
25
25
 
26
- include Import['github.workflow']
26
+ include Import["github.workflow"]
27
27
 
28
- desc 'Compile an erb template'
28
+ desc "Compile an erb template"
29
29
 
30
- argument :source_path, required: true, desc: 'The path to the template file'
31
- argument :target_path, required: true, desc: 'The path to the output file'
32
- argument :data_file, required: true, desc: 'The path to yaml data file'
30
+ argument :source_path, required: true, desc: "The path to the template file"
31
+ argument :target_path, required: true, desc: "The path to the output file"
32
+ argument :data_file, required: true, desc: "The path to yaml data file"
33
33
 
34
34
  def call(source_path:, target_path:, data_file:)
35
35
  puts "Compiling #{source_path} => #{target_path}"
@@ -1,21 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/system/container'
4
- require 'dry/system/components'
3
+ require "dry/system/container"
4
+ require "dry/system/components"
5
5
 
6
- require 'ossy/types'
6
+ require "ossy/types"
7
7
 
8
8
  module Ossy
9
9
  class Container < Dry::System::Container
10
- use :env, inferrer: proc { ENV.fetch('OSSY_ENV') { 'development' }.to_sym }
10
+ use :env, inferrer: proc { ENV.fetch("OSSY_ENV") { "development" }.to_sym }
11
11
 
12
12
  configure do |config|
13
- config.root = Pathname(__dir__).join('../../')
13
+ config.root = Pathname(__dir__).join("../../")
14
14
  config.name = :ossy
15
- config.default_namespace = 'ossy'
15
+ config.default_namespace = "ossy"
16
16
  end
17
17
 
18
- load_paths! 'lib'
18
+ load_paths! "lib"
19
19
 
20
20
  boot(:settings, from: :system) do
21
21
  settings do
@@ -1,70 +1,68 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/import'
3
+ require "ossy/import"
4
4
 
5
- require 'http'
6
- require 'json'
5
+ require "faraday"
6
+ require "json"
7
7
 
8
8
  module Ossy
9
9
  module Github
10
10
  class Client
11
11
  include Import[:settings]
12
12
 
13
- BASE_URL = 'https://api.github.com'
13
+ BASE_URL = "https://api.github.com"
14
14
 
15
15
  def membership?(username, org:, team:)
16
16
  path = "orgs/#{org}/teams/#{team}/memberships/#{username}"
17
17
  resp = get(path)
18
18
 
19
- return false unless resp.code.equal?(200)
19
+ return false unless resp.status.equal?(200)
20
20
 
21
21
  json = JSON.parse(resp.body)
22
22
 
23
- json['state'].eql?('active')
23
+ json["state"].eql?("active")
24
24
  end
25
25
 
26
26
  def tagger(repo:, tag:)
27
27
  path = "repos/#{repo}/git/ref/tags/#{tag}"
28
28
  resp = get(path)
29
29
 
30
- return false unless resp.code.equal?(200)
30
+ return false unless resp.status.equal?(200)
31
31
 
32
- sha = JSON.parse(resp.body)['object']['sha']
32
+ sha = JSON.parse(resp.body)["object"]["sha"]
33
33
 
34
34
  path = "repos/#{repo}/git/tags/#{sha}"
35
35
  resp = get(path)
36
36
 
37
- return false unless resp.code.equal?(200)
37
+ return false unless resp.status.equal?(200)
38
38
 
39
39
  json = JSON.parse(resp.body)
40
40
 
41
- { tagger: json['tagger'], verified: json['verification']['verified'] }
41
+ { tagger: json["tagger"], verified: json["verification"]["verified"] }
42
42
  end
43
43
 
44
44
  def member(name, org:)
45
45
  path = "orgs/#{org}/members"
46
46
  resp = get(path)
47
47
 
48
- return nil unless resp.code.equal?(200)
48
+ return nil unless resp.status.equal?(200)
49
49
 
50
- user = JSON.parse(resp.body)
51
- .map { |member| user(member['login']) }
52
- .detect { |user| user['name'].eql?(name) }
53
-
54
- user
50
+ JSON.parse(resp.body)
51
+ .map { |member| user(member["login"]) }
52
+ .detect { |user| user["name"].eql?(name) }
55
53
  end
56
54
 
57
55
  def user(login)
58
56
  path = "users/#{login}"
59
57
  resp = get(path)
60
58
 
61
- return nil unless resp.code.equal?(200)
59
+ return nil unless resp.status.equal?(200)
62
60
 
63
61
  JSON.parse(resp.body)
64
62
  end
65
63
 
66
64
  def request(meth, path, opts = {})
67
- http.public_send(meth, url(path), opts)
65
+ http.public_send(meth, path, opts)
68
66
  end
69
67
 
70
68
  def get(path, opts = {})
@@ -72,17 +70,18 @@ module Ossy
72
70
  end
73
71
 
74
72
  def post(path, input)
75
- request(:post, path, json: input)
73
+ request(:post, path, JSON.dump(input))
76
74
  end
77
75
 
78
- def url(path)
79
- "#{BASE_URL}/#{path}"
76
+ def http
77
+ @http ||= Faraday.new(url: BASE_URL, headers: headers) do |conn|
78
+ conn.basic_auth(settings.github_login, settings.github_token)
79
+ end
80
80
  end
81
81
 
82
- def http
83
- HTTP
84
- .headers('Accept': 'application/vnd.github.everest-preview+json')
85
- .basic_auth(user: settings.github_login, pass: settings.github_token)
82
+ def headers
83
+ { "Content-Type" => "application/json",
84
+ "Accept" => "application/vnd.github.everest-preview+json" }
86
85
  end
87
86
  end
88
87
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/github/client'
3
+ require "ossy/github/client"
4
4
 
5
5
  module Ossy
6
6
  module Github
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/container'
3
+ require "ossy/container"
4
4
 
5
5
  module Ossy
6
6
  Import = Container.injector
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ossy/types'
4
- require 'ossy/struct'
3
+ require "ossy/types"
4
+ require "ossy/struct"
5
5
 
6
6
  module Ossy
7
7
  class Release < Ossy::Struct
@@ -12,7 +12,7 @@ module Ossy
12
12
  attribute? :added, Types::ChangeList
13
13
  attribute? :changed, Types::ChangeList
14
14
 
15
- def each(&block)
15
+ def each
16
16
  %i[fixed added changed].each do |type|
17
17
  yield(type, self[type]) unless self[type].empty?
18
18
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/struct'
3
+ require "dry/struct"
4
4
 
5
5
  module Ossy
6
6
  class Struct < Dry::Struct
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/types'
3
+ require "dry/types"
4
4
 
5
5
  module Ossy
6
6
  module Types
7
7
  include Dry.Types()
8
8
 
9
- Version = Types::String.constrained(eql: 'unreleased') |
10
- Types::String.constrained(format: %r[\d+\.\d+\.\d+])
9
+ Version = Types::String.constrained(eql: "unreleased") |
10
+ Types::String.constrained(format: /\d+\.\d+\.\d+/)
11
11
 
12
12
  Summary = Types::String.constrained(filled: true).optional
13
13
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ossy
4
- VERSION = '0.1.2'
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ossy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-23 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
- name: dry-inflector
14
+ name: dry-cli
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.1'
19
+ version: '0.5'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.1.2
22
+ version: 0.5.1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '0.1'
29
+ version: '0.5'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.1.2
32
+ version: 0.5.1
33
33
  - !ruby/object:Gem::Dependency
34
- name: dry-cli
34
+ name: dry-inflector
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.5'
39
+ version: '0.1'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.5.1
42
+ version: 0.1.2
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '0.5'
49
+ version: '0.1'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.5.1
52
+ version: 0.1.2
53
53
  - !ruby/object:Gem::Dependency
54
- name: dry-types
54
+ name: dry-struct
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
@@ -65,47 +65,47 @@ dependencies:
65
65
  - !ruby/object:Gem::Version
66
66
  version: '1.2'
67
67
  - !ruby/object:Gem::Dependency
68
- name: dry-struct
68
+ name: dry-system
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
- version: '1.2'
73
+ version: '0.14'
74
74
  type: :runtime
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
- version: '1.2'
80
+ version: '0.14'
81
81
  - !ruby/object:Gem::Dependency
82
- name: dry-system
82
+ name: dry-types
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
- version: '0.14'
87
+ version: '1.2'
88
88
  type: :runtime
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: '0.14'
94
+ version: '1.2'
95
95
  - !ruby/object:Gem::Dependency
96
- name: http
96
+ name: faraday
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '4.1'
101
+ version: '1.0'
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: '4.1'
108
+ version: '1.0'
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: tilt
111
111
  requirement: !ruby/object:Gem::Requirement
@@ -166,16 +166,16 @@ dependencies:
166
166
  name: rubocop
167
167
  requirement: !ruby/object:Gem::Requirement
168
168
  requirements:
169
- - - '='
169
+ - - "~>"
170
170
  - !ruby/object:Gem::Version
171
- version: 0.71.0
171
+ version: '1.6'
172
172
  type: :development
173
173
  prerelease: false
174
174
  version_requirements: !ruby/object:Gem::Requirement
175
175
  requirements:
176
- - - '='
176
+ - - "~>"
177
177
  - !ruby/object:Gem::Version
178
- version: 0.71.0
178
+ version: '1.6'
179
179
  description: Ossy is your ruby gem maintenance helper
180
180
  email:
181
181
  - piotr.solnica@gmail.com
@@ -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
@@ -216,7 +217,7 @@ metadata:
216
217
  homepage_uri: https://github.com/solnic/ossy
217
218
  source_code_uri: https://github.com/solnic/ossy
218
219
  changelog_uri: https://github.com/solnic/ossy
219
- post_install_message:
220
+ post_install_message:
220
221
  rdoc_options: []
221
222
  require_paths:
222
223
  - lib
@@ -231,8 +232,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
232
  - !ruby/object:Gem::Version
232
233
  version: '0'
233
234
  requirements: []
234
- rubygems_version: 3.0.3
235
- signing_key:
235
+ rubygems_version: 3.2.3
236
+ signing_key:
236
237
  specification_version: 4
237
238
  summary: Ossy is your ruby gem maintenance helper
238
239
  test_files: []