ossy 0.3.2 → 0.3.5

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: 692163075005596e24fcd369ab7a65bae9cf32fbaa9fd4ba7443059b398d7744
4
- data.tar.gz: aa9d30379da6adcace2c88605dd781e40395fb04eca3d483402f1214edcc8281
3
+ metadata.gz: 6dfcaeb6815bd2610808e28c1f5f6311f894879161a596b91430f7af3a7e90a6
4
+ data.tar.gz: d2b3e4697953c163b0c901e4ac53dc9a32281c9d61cd9e82afcda11597dce203
5
5
  SHA512:
6
- metadata.gz: ba6e94b22f3309d56f2df084ba0b27b4069d47aaa13b0789799d7b9b29b291dc64a974157ce90f74f0fbd2bbb9ae774acec296894ed0f885ce2dd0b810a2276c
7
- data.tar.gz: 131df202b10b86c1d2d147ce73c44bb8a9bc6de334afde09bec4c13f9d342344b51964bea6357d00e2ec176fa4cb14e91f545f5e053270d4562b4366a19c02df
6
+ metadata.gz: c140398ddc4f87af7383d80aa3c39813d78ac158fc029c458655d05d0a2151e6f0febee57ca623c1580bf56e51c2f2d2466d26c3f1556b2d6ef2d00c01ca1483
7
+ data.tar.gz: 64585144186b72cbaa1660fe9dbeb5a1e14d6b71c55ef0605500de54307451387d30e627d07695ace39caa3548f3157bf4babdd0cbc9e33357d449f29861c1ee
@@ -18,7 +18,7 @@ module Ossy
18
18
  KEYS = %w[version summary date fixed added changed].freeze
19
19
 
20
20
  def call(config_path:, message:)
21
- attrs = YAML.load(message)
21
+ attrs = YAML.safe_load(message)
22
22
  target = YAML.load_file(config_path)
23
23
 
24
24
  version = attrs["version"] || target[0]["version"]
@@ -22,6 +22,8 @@ module Ossy
22
22
 
23
23
  require "ossy/cli/templates/compile"
24
24
 
25
+ require "ossy/cli/metrics/rubocop"
26
+
25
27
  register "github", aliases: %w[gh] do |github|
26
28
  github.register "workflow", Github::Workflow, aliases: %w[w]
27
29
  github.register "membership", Github::Membership, aliases: %w[m]
@@ -46,6 +48,10 @@ module Ossy
46
48
  register "configs", aliases: %w[c] do |configs|
47
49
  configs.register "merge", Configs::Merge, aliases: %w[m]
48
50
  end
51
+
52
+ register "metrics", aliases: %w[m] do |configs|
53
+ configs.register "rubocop", Metrics::Rubocop, aliases: %w[rc]
54
+ end
49
55
  end
50
56
  end
51
57
  end
@@ -16,7 +16,7 @@ module Ossy
16
16
  argument :output_path, required: true, desc: "The path to the output file"
17
17
 
18
18
  option :identifiers, required: false, default: "",
19
- desc: "Key identifier that should be used for merging arrays of hashes"
19
+ desc: "Key identifier that should be used for merging arrays of hashes"
20
20
 
21
21
  def call(source_path:, target_path:, output_path:, **opts)
22
22
  puts "Merging #{source_path} + #{target_path} into #{output_path}"
@@ -49,9 +49,11 @@ module Ossy
49
49
  arr
50
50
  .map
51
51
  .with_index { |el, idx|
52
- (after = el.delete("_after")) ?
53
- [el, arr.index(arr.detect { |a| a[id].eql?(after) }) + 1] :
52
+ if (after = el.delete("_after"))
53
+ [el, arr.index(arr.detect { |a| a[id].eql?(after) }) + 1]
54
+ else
54
55
  [el, idx]
56
+ end
55
57
  }.sort_by(&:last).map(&:first)
56
58
  else
57
59
  (val1 + val2).uniq
@@ -17,8 +17,12 @@ module Ossy
17
17
  def call(repo:, tag:)
18
18
  result = client.tagger(repo: repo, tag: tag)
19
19
 
20
- if result && result[:verified].equal?(true)
21
- puts result[:tagger]["name"]
20
+ return unless result
21
+
22
+ tagger = result[:tagger]
23
+
24
+ if tagger["email"].include?("users.noreply.github.com") || result[:verified].equal?(true)
25
+ puts tagger["name"]
22
26
  end
23
27
  end
24
28
  end
@@ -0,0 +1,38 @@
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 Metrics
14
+ class Rubocop < Commands::Core
15
+ include Import[run_rubocop: "engine.rubocop.run"]
16
+
17
+ desc "Runs rubocop"
18
+
19
+ argument :path, required: true, desc: "The path to file(s)"
20
+ option :format, required: true, desc: "Output format"
21
+ option :do_exit, required: false,
22
+ desc: "Whether the command should exit with the same status as rubocop"
23
+ option :silence, required: false,
24
+ desc: "Whether the rubocop output should be displayed"
25
+
26
+ def call(path:, silence: "false", do_exit: "true", args: [], **opts)
27
+ result, output = run_rubocop.(path: path, args: args, **opts)
28
+
29
+ warn output if silence.eql?("false") && !result.success?
30
+
31
+ exit(result.exitstatus) if do_exit.eql?("true")
32
+
33
+ [result, output]
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -7,7 +7,7 @@ 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
13
  config.root = Pathname(__dir__).join("../../")
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "open3"
4
+
5
+ require "ossy/cli/commands/core"
6
+ require "ossy/struct"
7
+
8
+ module Ossy
9
+ module Engine
10
+ module Rubocop
11
+ # {
12
+ # "metadata" : {
13
+ # "ruby_platform" : "x86_64-darwin20",
14
+ # "ruby_version" : "2.7.2",
15
+ # "ruby_engine" : "ruby",
16
+ # "ruby_patchlevel" : "137",
17
+ # "rubocop_version" : "1.6.1"
18
+ # },
19
+ # "files" : [
20
+ # {
21
+ # "offenses" : [],
22
+ # "path" : "spec/spec_helper.rb"
23
+ # }
24
+ # ],
25
+ # "summary" : {
26
+ # "target_file_count" : 1,
27
+ # "inspected_file_count" : 1,
28
+ # "offense_count" : 0
29
+ # }
30
+ # }
31
+ #
32
+ # # json["files"] element
33
+ # {"path"=>"spec/fixtures/rubocop/bad.rb",
34
+ # "offenses"=>
35
+ # [{"severity"=>"convention",
36
+ # "message"=> "blablabla",
37
+ # "cop_name"=>"Style/StringLiterals",
38
+ # "corrected"=>false,
39
+ # "correctable"=>true,
40
+ # "location"=>
41
+ # {"start_line"=>3,
42
+ # "start_column"=>1,
43
+ # "last_line"=>3,
44
+ # "last_column"=>30,
45
+ # "length"=>30,
46
+ # "line"=>3,
47
+ # "column"=>1}}]}
48
+ class Result < Ossy::Struct
49
+ attribute :summary do
50
+ attribute :offense_count, Types::Integer
51
+ end
52
+
53
+ def self.build(json)
54
+ klass =
55
+ case json["summary"]["offense_count"]
56
+ in 0 then Success
57
+ in 1.. then Failure
58
+ end
59
+ klass.new(json)
60
+ end
61
+
62
+ def failure?
63
+ !success?
64
+ end
65
+ end
66
+
67
+ class Success < Result
68
+ def success?
69
+ true
70
+ end
71
+ end
72
+
73
+ class Failure < Result
74
+ attribute :files, Types::Array do
75
+ attribute :path, Types::String
76
+ attribute :offenses, Types::Array do
77
+ attribute :severity, Types::String
78
+ attribute :cop_name, Types::String
79
+ attribute :location do
80
+ attribute :start_line, Types::Integer
81
+ attribute :start_column, Types::Integer
82
+ attribute :last_line, Types::Integer
83
+ attribute :last_column, Types::Integer
84
+ attribute :line, Types::Integer
85
+ attribute :column, Types::Integer
86
+ end
87
+ end
88
+ end
89
+
90
+ def success?
91
+ false
92
+ end
93
+ end
94
+
95
+ class Run < Ossy::CLI::Commands::Core
96
+ option :path, desc: "Path to file(s)"
97
+ option :format, desc: "Path to file(s)"
98
+
99
+ def call(path:, format: "json", args: [])
100
+ extra_opts = args.join(" ")
101
+ result, output = exec("rubocop #{path} --format #{format} #{extra_opts}".strip)
102
+
103
+ case format
104
+ when "json" then Result.build(JSON.parse(output))
105
+ else
106
+ [result, output]
107
+ end
108
+ end
109
+
110
+ def exec(cmd, opts = {})
111
+ Open3.popen3(cmd, opts) do |_stdin, stdout, _stderr, wait_thr|
112
+ [wait_thr.value, stdout.read]
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -75,7 +75,7 @@ module Ossy
75
75
 
76
76
  def http
77
77
  @http ||= Faraday.new(url: BASE_URL, headers: headers) do |conn|
78
- conn.basic_auth(settings.github_login, settings.github_token)
78
+ conn.request(:basic_auth, settings.github_login, settings.github_token)
79
79
  end
80
80
  end
81
81
 
data/lib/ossy/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ossy
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.5"
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.3.2
4
+ version: 0.3.5
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-03 00:00:00.000000000 Z
11
+ date: 2022-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -64,20 +64,40 @@ dependencies:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
66
  version: '1.2'
67
+ - !ruby/object:Gem::Dependency
68
+ name: dry-configurable
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.12'
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.13'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0.12'
84
+ - - "<"
85
+ - !ruby/object:Gem::Version
86
+ version: '0.13'
67
87
  - !ruby/object:Gem::Dependency
68
88
  name: dry-system
69
89
  requirement: !ruby/object:Gem::Requirement
70
90
  requirements:
71
91
  - - "~>"
72
92
  - !ruby/object:Gem::Version
73
- version: '0.14'
93
+ version: 0.18.1
74
94
  type: :runtime
75
95
  prerelease: false
76
96
  version_requirements: !ruby/object:Gem::Requirement
77
97
  requirements:
78
98
  - - "~>"
79
99
  - !ruby/object:Gem::Version
80
- version: '0.14'
100
+ version: 0.18.1
81
101
  - !ruby/object:Gem::Dependency
82
102
  name: dry-types
83
103
  requirement: !ruby/object:Gem::Requirement
@@ -140,14 +160,20 @@ dependencies:
140
160
  requirements:
141
161
  - - "~>"
142
162
  - !ruby/object:Gem::Version
143
- version: '10.0'
163
+ version: 12.3.3
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 12.3.3
144
167
  type: :development
145
168
  prerelease: false
146
169
  version_requirements: !ruby/object:Gem::Requirement
147
170
  requirements:
148
171
  - - "~>"
149
172
  - !ruby/object:Gem::Version
150
- version: '10.0'
173
+ version: 12.3.3
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: 12.3.3
151
177
  - !ruby/object:Gem::Dependency
152
178
  name: rspec
153
179
  requirement: !ruby/object:Gem::Requirement
@@ -199,9 +225,11 @@ files:
199
225
  - lib/ossy/cli/github/tagger.rb
200
226
  - lib/ossy/cli/github/update_file.rb
201
227
  - lib/ossy/cli/github/workflow.rb
228
+ - lib/ossy/cli/metrics/rubocop.rb
202
229
  - lib/ossy/cli/releases/generate.rb
203
230
  - lib/ossy/cli/templates/compile.rb
204
231
  - lib/ossy/container.rb
232
+ - lib/ossy/engine/rubocop/run.rb
205
233
  - lib/ossy/github/client.rb
206
234
  - lib/ossy/github/workflow.rb
207
235
  - lib/ossy/import.rb
@@ -232,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
260
  - !ruby/object:Gem::Version
233
261
  version: '0'
234
262
  requirements: []
235
- rubygems_version: 3.2.3
263
+ rubygems_version: 3.2.32
236
264
  signing_key:
237
265
  specification_version: 4
238
266
  summary: Ossy is your ruby gem maintenance helper