ossy 0.1.1 → 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: 965afe44b899667c0d9ea0c44e1b11bf056a16ff8054e3d595ad6c5ec9318af6
4
- data.tar.gz: 7d661d6bfea8f538ac3417c28e5e0a9868a542b14b8c8320a63cc7bdd6d18800
3
+ metadata.gz: 888c62267952b5f24a66741016179765c541c7fe9f28576ed892484b48e4ce52
4
+ data.tar.gz: '01885a2a26f4b3c8e02be23419c9165ade07ed4aeedd2c047c537d4793cd61f9'
5
5
  SHA512:
6
- metadata.gz: daba5695f37732e662a3fb25ab967b14270ce0fb444d1493730356baacfcddcc4d782afbaacbbdb8b2c272c0cfd45ace73fc004bca0e51a84b809684cf9d7256
7
- data.tar.gz: 70076b0610889382bf47f43dd779334a15ee84df083444fa4e89ad49109b6459c6bf918e0c52f29c286b9c02e176f9062472bb5f391ca106d640456d9d6e86cd
6
+ metadata.gz: a62e32830553990689776251581d2c9bdc91e3f3b40dee67b2c1f0fccfe114774ae9ad67552f92b6a10222a1484455c26251fc781d4bb5fa2478fd5264ee538c
7
+ data.tar.gz: 900e60b374b75b8ea0e957b60938fb9c6a3571136b111cef7731e4b113a950565ad33908279e5bacd11c33b9fdc99cca757e3ae6819cd094c4522bd3fd1af321
@@ -1,3 +1,31 @@
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
+
19
+ ## 0.1.2 2020-01-23
20
+
21
+ ### Fixed
22
+
23
+ - `ossy` executable no longer requires bundler/setup (@solnic)"
24
+
25
+ ### Changed
26
+
27
+ - Bump dep on dry-cli to >= 0.5.1 which fixed missing `set` require (@solnic)
28
+
1
29
  ## 0.1.1 2020-01-22
2
30
 
3
31
  ### Changed
data/README.md CHANGED
@@ -1,5 +1,15 @@
1
+ [gem]: https://rubygems.org/gems/ossy
2
+ [actions]: https://github.com/solnic/ossy/actions
3
+ [codacy]: https://www.codacy.com/manual/solnic/ossy
4
+ [inchpages]: http://inch-ci.org/github/solnic/ossy
5
+
1
6
  # Ossy
2
7
 
8
+ [![Gem Version](https://badge.fury.io/rb/ossy.svg)][gem]
9
+ [![CI Status](https://github.com/solnic/ossy/workflows/ci/badge.svg)][actions]
10
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/70550ec31fdc40edbd7e2c47f707c892)][codacy]
11
+ [![Inline docs](http://inch-ci.org/github/solnic/ossy.svg?branch=master)][inchpages]
12
+
3
13
  Ossy is a CLI tool that provides various commands that help with maintenance automation.
4
14
 
5
15
  ## Status
data/bin/ossy CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  # frozen_string_literal: true
4
4
 
5
- require 'bundler/setup'
6
5
  require 'ossy/cli'
7
6
 
8
7
  Ossy::CLI::Application.start
@@ -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,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,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.1'
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,51 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ossy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.0
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-22 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
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.1.2
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
47
  - - "~>"
45
48
  - !ruby/object:Gem::Version
46
- version: '0.5'
49
+ version: '0.1'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.1.2
47
53
  - !ruby/object:Gem::Dependency
48
- name: dry-types
54
+ name: dry-struct
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
51
57
  - - "~>"
@@ -59,47 +65,47 @@ dependencies:
59
65
  - !ruby/object:Gem::Version
60
66
  version: '1.2'
61
67
  - !ruby/object:Gem::Dependency
62
- name: dry-struct
68
+ name: dry-system
63
69
  requirement: !ruby/object:Gem::Requirement
64
70
  requirements:
65
71
  - - "~>"
66
72
  - !ruby/object:Gem::Version
67
- version: '1.2'
73
+ version: '0.14'
68
74
  type: :runtime
69
75
  prerelease: false
70
76
  version_requirements: !ruby/object:Gem::Requirement
71
77
  requirements:
72
78
  - - "~>"
73
79
  - !ruby/object:Gem::Version
74
- version: '1.2'
80
+ version: '0.14'
75
81
  - !ruby/object:Gem::Dependency
76
- name: dry-system
82
+ name: dry-types
77
83
  requirement: !ruby/object:Gem::Requirement
78
84
  requirements:
79
85
  - - "~>"
80
86
  - !ruby/object:Gem::Version
81
- version: '0.14'
87
+ version: '1.2'
82
88
  type: :runtime
83
89
  prerelease: false
84
90
  version_requirements: !ruby/object:Gem::Requirement
85
91
  requirements:
86
92
  - - "~>"
87
93
  - !ruby/object:Gem::Version
88
- version: '0.14'
94
+ version: '1.2'
89
95
  - !ruby/object:Gem::Dependency
90
- name: http
96
+ name: faraday
91
97
  requirement: !ruby/object:Gem::Requirement
92
98
  requirements:
93
99
  - - "~>"
94
100
  - !ruby/object:Gem::Version
95
- version: '4.1'
101
+ version: '1.0'
96
102
  type: :runtime
97
103
  prerelease: false
98
104
  version_requirements: !ruby/object:Gem::Requirement
99
105
  requirements:
100
106
  - - "~>"
101
107
  - !ruby/object:Gem::Version
102
- version: '4.1'
108
+ version: '1.0'
103
109
  - !ruby/object:Gem::Dependency
104
110
  name: tilt
105
111
  requirement: !ruby/object:Gem::Requirement
@@ -160,16 +166,16 @@ dependencies:
160
166
  name: rubocop
161
167
  requirement: !ruby/object:Gem::Requirement
162
168
  requirements:
163
- - - '='
169
+ - - "~>"
164
170
  - !ruby/object:Gem::Version
165
- version: 0.71.0
171
+ version: '1.6'
166
172
  type: :development
167
173
  prerelease: false
168
174
  version_requirements: !ruby/object:Gem::Requirement
169
175
  requirements:
170
- - - '='
176
+ - - "~>"
171
177
  - !ruby/object:Gem::Version
172
- version: 0.71.0
178
+ version: '1.6'
173
179
  description: Ossy is your ruby gem maintenance helper
174
180
  email:
175
181
  - piotr.solnica@gmail.com
@@ -193,6 +199,7 @@ files:
193
199
  - lib/ossy/cli/github/tagger.rb
194
200
  - lib/ossy/cli/github/update_file.rb
195
201
  - lib/ossy/cli/github/workflow.rb
202
+ - lib/ossy/cli/releases/generate.rb
196
203
  - lib/ossy/cli/templates/compile.rb
197
204
  - lib/ossy/container.rb
198
205
  - lib/ossy/github/client.rb
@@ -210,7 +217,7 @@ metadata:
210
217
  homepage_uri: https://github.com/solnic/ossy
211
218
  source_code_uri: https://github.com/solnic/ossy
212
219
  changelog_uri: https://github.com/solnic/ossy
213
- post_install_message:
220
+ post_install_message:
214
221
  rdoc_options: []
215
222
  require_paths:
216
223
  - lib
@@ -225,8 +232,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
232
  - !ruby/object:Gem::Version
226
233
  version: '0'
227
234
  requirements: []
228
- rubygems_version: 3.0.3
229
- signing_key:
235
+ rubygems_version: 3.2.3
236
+ signing_key:
230
237
  specification_version: 4
231
238
  summary: Ossy is your ruby gem maintenance helper
232
239
  test_files: []