gh_coab 0.1.1 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25df3d014958ba15317f16e7e9bfcc5096cfdec5766f54aed282d0d26df89d32
4
- data.tar.gz: 128bb9a219f9579766f592734c5fc0baaf281f208452b96da3f5e6828a375cb4
3
+ metadata.gz: a90a5e5b80bf4e34cba67e8a6888afaf9fbbd8a06ded6cfc3d5805b7da7abbcb
4
+ data.tar.gz: 7b257bb422c0ca8570bec5f14f100c3e1edfdbfcfa276914ce568b8c89802843
5
5
  SHA512:
6
- metadata.gz: e69ebc0ec3f0170fda882bff6f723da5066b0b123105f84dce1ca2fe4185a58ee9ce18f0e6d7ba6cb136f10009517346137e7d778b03bd3c6d839cdd4143f4f9
7
- data.tar.gz: 1fdcd02d10c18cf627d32a6f7ca51eb826e9ebc670817897fa02849078cf2205672777570b2c79e9510b30bc38c230fb59c456d1a3169d6a4db5f5d875d9b476
6
+ metadata.gz: 968f5f5062ae81bc5df48f33cf14597164137aa40650923bb8644ca4774615e8b2072cae867c8bfbfb4edeb0339377c1fe1343ad41e05cf8f88d1fd3ef0a2ac2
7
+ data.tar.gz: b3595c0a2381004f8dac3c0e63bab319e3ccba6294bdc0facf99c618c58483219b0ec9007f5454ffbb61ef6fefcb593860e48576620cb6d0ddda5775d257c261
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gh_coab (0.1.0)
4
+ gh_coab (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,24 +1,21 @@
1
1
  # GhCoab
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gh_coab`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ This is a very simple gem. It helps you get the "Co-authored-by" text to add a co-author to a commit. You call the method in your terminal `gh_coab s -u <GITHUB_USERNAME>` and the gem does an api call to the public events of the author to find emails associated with it.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
7
 
11
8
  Install the gem and add to the application's Gemfile by executing:
12
9
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
10
+ $ bundle add gh_coab
14
11
 
15
12
  If bundler is not being used to manage dependencies, install the gem by executing:
16
13
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
+ $ gem install gh_coab
18
15
 
19
16
  ## Usage
20
17
 
21
- TODO: Write usage instructions here
18
+ `gh_coab s -u <GITHUB_USERNAME>`
22
19
 
23
20
  ## Development
24
21
 
data/exe/gh_coab CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "bundler/setup"
5
- require "gh_coab"
5
+ require_relative "../lib/gh_coab.rb"
6
6
 
7
7
  GhCoab::CLI.start
8
8
  # You can add fixtures and/or initialization code here to make experimenting
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "net/http"
2
4
  require "benchmark"
3
5
  require "json"
@@ -45,11 +47,7 @@ class GhClient
45
47
  unless success?(response)
46
48
  error_message = "ERROR - code: #{response.code} - #{response.message} - #{response.body}"
47
49
 
48
- fail(
49
- client_error_class.new(
50
- error_message
51
- )
52
- )
50
+ raise client_error_class, error_message
53
51
  end
54
52
 
55
53
  parsed_response
@@ -68,11 +66,9 @@ class GhClient
68
66
  rescue JSON::ParserError
69
67
  Rails.logger.error("Failed to parse response that was expected to be JSON: #{body}")
70
68
 
71
- if raise_on_parsing_error
72
- raise raise_on_parsing_error.new, "Could not parse response: #{body}"
73
- else
74
- {}
75
- end
69
+ raise raise_on_parsing_error.new, "Could not parse response: #{body}" if raise_on_parsing_error
70
+
71
+ {}
76
72
  end
77
73
  end
78
74
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "gh_service"
2
4
  module GhCoab
3
5
  class GhCoab
@@ -5,6 +7,8 @@ module GhCoab
5
7
  def self.write_coab(username)
6
8
  name = service.get_name(username)
7
9
  emails = service.get_emails(username)
10
+ emails.select! { |email| email[:name].downcase == name.downcase && !email[:email].nil? }
11
+ emails = emails.map { |email| email[:email] }
8
12
  coabs = emails.map do |email|
9
13
  "#{COAB}#{name} <#{email}>"
10
14
  end
@@ -5,6 +5,7 @@ class GhService
5
5
  class GhClientError < StandardError; end
6
6
 
7
7
  attr_reader :client_error_class
8
+
8
9
  def initialize
9
10
  @client_error_class = GhClientError
10
11
  end
@@ -13,8 +14,9 @@ class GhService
13
14
  response = client.get_events(username)
14
15
  response.map do |event|
15
16
  next if event.dig(:payload, :commits).nil?
17
+
16
18
  event[:payload][:commits].map do |commit|
17
- commit[:author][:email]
19
+ {name: commit[:author][:name], email: commit[:author][:email]}
18
20
  end
19
21
  end.flatten.uniq.compact
20
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GhCoab
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/gh_coab.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "thor"
2
4
  require_relative "gh_coab/gh_coab"
3
5
  # frozen_string_literal: true
@@ -9,16 +11,15 @@ module GhCoab
9
11
 
10
12
  class CLI < Thor
11
13
  desc "show <GH_USERNAME>", "Displays the co-author name and emails"
12
-
14
+
13
15
  option :username, aliases: "-u", required: true, type: :string
14
-
15
-
16
+
16
17
  def show
17
18
  GhCoab.write_coab(options[:username])
18
19
  end
19
20
  desc "s <GH_USERNAME>", "Displays the co-author name and emails"
20
21
  option :username, aliases: "-u", required: true, type: :string
21
22
 
22
- alias_method :s, :show
23
+ alias_method :s, :show
23
24
  end
24
25
  end
metadata CHANGED
@@ -1,16 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gh_coab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - george kosmopoulos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-06 00:00:00.000000000 Z
11
+ date: 2023-10-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Get co-authors from github
13
+ description: "Get co-authors from github \n in your terminal type gh_coab s -u <github_username>
14
+ \n or gh_coab show -u <github_username> \n and you will get the message you need
15
+ to add to your commit message to add co-authors"
14
16
  email:
15
17
  - gkosmo1@hotmail.com
16
18
  executables:
@@ -34,13 +36,13 @@ files:
34
36
  - lib/gh_coab/gh_service.rb
35
37
  - lib/gh_coab/version.rb
36
38
  - sig/gh_coab.rbs
37
- homepage: https://www.github.com/gkosmo/coab
39
+ homepage: https://www.github.com/gkosmo/gh_coab
38
40
  licenses:
39
41
  - MIT
40
42
  metadata:
41
- homepage_uri: https://www.github.com/gkosmo/coab
42
- source_code_uri: https://www.github.com/gkosmo/coab
43
- changelog_uri: https://www.github.com/gkosmo/coab
43
+ homepage_uri: https://www.github.com/gkosmo/gh_coab
44
+ source_code_uri: https://www.github.com/gkosmo/gh_coab
45
+ changelog_uri: https://www.github.com/gkosmo/gh_coab
44
46
  post_install_message:
45
47
  rdoc_options: []
46
48
  require_paths: