ballantine 0.1.4.pre.beta3 → 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: faa1e978d804f0d6db7c1c8b2d0d46a1fee27cd0a1f11c811b34f700fa99ac4d
4
- data.tar.gz: 17a176cabd94e64d662bde533f605b6d36ebc19f301f6f77df3afc7870fdfedb
3
+ metadata.gz: 7dc81ef643fe888582cb999e267066d56fde114d898a234122ea2165b79a6153
4
+ data.tar.gz: 823bb10cd43e75743c26fc61b65d2512229438b7232a3e779a20a53e7ff9bad1
5
5
  SHA512:
6
- metadata.gz: 014f30ad7a7764ef9d2d8619a62c541de3e23115e9d9eddebf16da3d1e6f958fc5d2567f57d3072907f8df1d398ca9ff8e8f785675095ad95e8adabfa76e0080
7
- data.tar.gz: eed48b827efdbab0ff935444936431ac08a8ef97b15a9291679ec45f64ea9b56a295ad4ae40049749d516d385e7daaad18017449638af38d7c0579cf2be155ff
6
+ metadata.gz: f55eb551e6c00ea8b6b1c59abfdae3d69742b7eab52cf8739a51d4d38918b4f77fe8f69f5e88c6418dec0e57cb4bb3892ea36ae64540ff19f79f31a01a5e3af0
7
+ data.tar.gz: 7abba991f1cb76e9f56d1685e06cd490d66bc48d6dff53d3078eae7ef42fe627028ee0b791aafb8ea1c9b82975e9ee36461d7a2d2f448518ab3d33870681a346
@@ -36,6 +36,8 @@ module Ballantine
36
36
 
37
37
  # @return [Boolean]
38
38
  def print_commits
39
+ conf.print_log(binding) if conf.verbose
40
+
39
41
  puts "\n" + "@#{name}".green
40
42
  commits_hash.each do |repo_name, commits|
41
43
  count, word = retrieve_count_and_word(commits)
@@ -52,6 +54,8 @@ module Ballantine
52
54
  # reference: https://api.slack.com/messaging/composing/layouts#building-attachments
53
55
  # @return [Hash]
54
56
  def slack_message
57
+ conf.print_log(binding) if conf.verbose
58
+
55
59
  message = commits_hash.map do |repo_name, commits|
56
60
  count, word = retrieve_count_and_word(commits)
57
61
  "*#{repo_name}*: #{count} new #{word}\n" \
@@ -66,6 +70,8 @@ module Ballantine
66
70
 
67
71
  private
68
72
 
73
+ def conf; Config.instance end
74
+
69
75
  # @param [Array<Commit>] commits
70
76
  # @param [Array(Integer, String)] count, word
71
77
  def retrieve_count_and_word(commits)
@@ -22,8 +22,12 @@ module Ballantine
22
22
  end
23
23
 
24
24
  Config::AVAILABLE_ENVIRONMENTS.each { |env| option env, type: :boolean, default: false, desc: "Set envirment to `#{env}'." }
25
+ option "verbose", type: :boolean, default: false, desc: "Print a progress."
25
26
  desc "config [--env] [KEY] [VALUE]", "Set ballantine's configuration"
26
27
  def config(key = nil, value = nil)
28
+ conf.verbose = options["verbose"]
29
+ puts "$ ballantine config #{key} #{value}" if conf.verbose
30
+
27
31
  # check environment value
28
32
  if Config::AVAILABLE_ENVIRONMENTS.map { |key| !options[key] }.reduce(:&)
29
33
  raise NotAllowed, "Set environment value (#{Config::AVAILABLE_ENVIRONMENTS.map { |key| "`--#{key}'" }.join(", ")})"
@@ -38,15 +42,16 @@ module Ballantine
38
42
  value ? conf.set_data(key, value) : conf.print_data(key)
39
43
  end
40
44
 
41
- desc "diff [TARGET] [SOURCE]", "Diff commits between TARGET and SOURCE"
45
+ option "verbose", type: :boolean, default: false, desc: "Print a progress."
42
46
  option Config::TYPE_SLACK, type: :boolean, aliases: "-s", default: false, desc: "Send to slack using slack webhook URL."
47
+ desc "diff [TARGET] [SOURCE]", "Diff commits between TARGET and SOURCE"
43
48
  def diff(target, source = %x(git rev-parse --abbrev-ref HEAD).chomp)
49
+ conf.verbose = options["verbose"]
50
+ puts "$ ballantine diff #{target} #{source}" if conf.verbose
51
+
44
52
  # validate arguments
45
53
  validate(target, source, **options)
46
54
 
47
- # check commits are newest
48
- system("git pull -f &> /dev/null")
49
-
50
55
  # init instance variables
51
56
  init_variables(target, source, **options)
52
57
 
@@ -55,8 +60,6 @@ module Ballantine
55
60
 
56
61
  # print commits
57
62
  print_commits(target, source, **options)
58
-
59
- exit(0)
60
63
  end
61
64
 
62
65
  desc "version", "Display version information about ballntine"
@@ -75,6 +78,8 @@ module Ballantine
75
78
  # @param [Hash] options
76
79
  # @return [NilClass] nil
77
80
  def validate(target, source, **options)
81
+ conf.print_log(binding) if conf.verbose
82
+
78
83
  if Dir[".git"].empty?
79
84
  raise NotAllowed, "ERROR: There is no \".git\" in #{Dir.pwd}."
80
85
  end
@@ -99,6 +104,11 @@ module Ballantine
99
104
  # @param [Hash] options
100
105
  # @return [Boolean]
101
106
  def init_variables(target, source, **options)
107
+ conf.print_log(binding) if conf.verbose
108
+
109
+ # check commits are newest
110
+ system("git pull -f &> /dev/null")
111
+
102
112
  conf.print_type = options[Config::TYPE_SLACK] ? Config::TYPE_SLACK : Config::TYPE_TERMINAL
103
113
  @repo = Repository.find_or_create_by(
104
114
  path: Dir.pwd,
@@ -113,6 +123,8 @@ module Ballantine
113
123
  # @param [Hash] options
114
124
  # @return [Boolean]
115
125
  def check_commits(**options)
126
+ conf.print_log(binding) if conf.verbose
127
+
116
128
  repo.check_commits
117
129
 
118
130
  true
@@ -123,6 +135,8 @@ module Ballantine
123
135
  # @param [Hash] options
124
136
  # @return [Boolean]
125
137
  def print_commits(target, source, **options)
138
+ conf.print_log(binding) if conf.verbose
139
+
126
140
  authors = Author.all
127
141
  if authors.empty?
128
142
  raise ArgumentError, "ERROR: There is no commits between \"#{target}\" and \"#{source}\""
@@ -132,7 +146,7 @@ module Ballantine
132
146
 
133
147
  case conf.print_type
134
148
  when Config::TYPE_TERMINAL
135
- puts_r "Check commits before #{repo.name.red} deployment. (#{target.cyan} <- #{source.cyan})", "#{repo.url}/compare/#{repo.from.hash}...#{repo.to.hash}".gray
149
+ puts_r "Check commits before #{repo.name.red} deployment. (#{target.cyan}...#{source.cyan})", "#{repo.url}/compare/#{repo.from.hash}...#{repo.to.hash}".gray
136
150
  puts "Author".yellow + ": #{number}"
137
151
  puts_r "#{"Last commit".blue}: #{repo.to.hash.yellow} #{repo.to.subject}", repo.to.url.gray
138
152
  authors.map(&:print_commits)
@@ -149,7 +163,7 @@ module Ballantine
149
163
  request.content_type = "application/json"
150
164
  request.body = JSON.dump({
151
165
  "text" => ":white_check_mark: *#{repo.name}* deployment request by <@#{actor}>" \
152
- " (\`<#{repo.url}/tree/#{repo.from.hash}|#{target}>\` <- \`<#{repo.url}/tree/#{repo.to.hash}|#{source}>\` <#{repo.url}/compare/#{repo.from.hash}...#{repo.to.hash}|compare>)" \
166
+ " (\`<#{repo.url}/tree/#{repo.from.hash}|#{target}>\`<#{repo.url}/compare/#{repo.from.hash}...#{repo.to.hash}|...>\`<#{repo.url}/tree/#{repo.to.hash}|#{source}>\`)" \
153
167
  "\n:technologist: Author: #{number}\nLast commit: #{repo.to.slack_message}",
154
168
  "attachments" => messages,
155
169
  })
@@ -15,9 +15,10 @@ module Ballantine
15
15
  AVAILABLE_KEYS = [
16
16
  KEY_SLACK_WEBHOOK,
17
17
  ].freeze
18
+ AVAILABLE_PRINT_INSTANCE_VARIABLES = [:@name, :@from, :@to].freeze
18
19
 
19
20
  attr_reader :data, :loaded
20
- attr_accessor :env, :print_type
21
+ attr_accessor :env, :print_type, :verbose
21
22
 
22
23
  class << self
23
24
  # @note singleton method
@@ -33,6 +34,8 @@ module Ballantine
33
34
  @env = ENV_LOCAL
34
35
  @data = {}
35
36
  @loaded = false
37
+ @print_type = TYPE_TERMINAL
38
+ @verbose = false
36
39
  end
37
40
 
38
41
  # @param [Hash] options
@@ -98,6 +101,18 @@ module Ballantine
98
101
  @data[key]
99
102
  end
100
103
 
104
+ # @param [Binding] binding
105
+ # @return [NilClass]
106
+ def print_log(binding)
107
+ method = caller(1..1)[0][/`([^']*)'/, 1]
108
+
109
+ puts [
110
+ "#{binding.receiver.class.name}##{method}",
111
+ (binding.receiver.instance_variables & AVAILABLE_PRINT_INSTANCE_VARIABLES).map { |var| "#{var}:#{binding.receiver.instance_variable_get(var).inspect}" }.join(" "),
112
+ binding.receiver.method(method).parameters.map { |_, arg| arg }.map { |arg| "#{arg}:#{binding.local_variable_get(arg)}" }.join(" "),
113
+ ].compact.join("\t")
114
+ end
115
+
101
116
  private
102
117
 
103
118
  def file_path(env = @env)
@@ -59,6 +59,8 @@ module Ballantine
59
59
  # @param [String] source
60
60
  # @return [Boolean]
61
61
  def init_variables(target, source)
62
+ conf.print_log(binding) if conf.verbose
63
+
62
64
  current_revision = %x(git rev-parse --abbrev-ref HEAD).chomp
63
65
 
64
66
  foo = lambda do |hash, context|
@@ -98,6 +100,8 @@ module Ballantine
98
100
 
99
101
  # @return [Boolean]
100
102
  def check_commits
103
+ conf.print_log(binding) if conf.verbose
104
+
101
105
  authors = retrieve_authors
102
106
  authors.each do |author|
103
107
  commits = retrieve_commits(author)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ballantine
4
- VERSION = "0.1.4-beta3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ballantine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4.pre.beta3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - oohyun15
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-29 00:00:00.000000000 Z
11
+ date: 2023-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -72,9 +72,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
72
  version: '3.1'
73
73
  required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ">"
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
- version: 1.3.1
77
+ version: '0'
78
78
  requirements: []
79
79
  rubygems_version: 3.3.26
80
80
  signing_key: