rubocop_challenger 1.0.0.pre2 → 1.0.0.pre3

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: 3f9701abf6328e9334c2880ad0583f405c770b364a5b00d1e651e39d7518bbd1
4
- data.tar.gz: ab3a7266b6e803a624d58994ac9261011de5d4580136ffe56124fe59483c3ca8
3
+ metadata.gz: 2b73e8abe85be6a6a8673f84a8d35b4cc664e012c471bfeea3beb8b45d74366d
4
+ data.tar.gz: ab2c10f577db034299059b197558a675a19e3d69bb497b6cc17be250134dce65
5
5
  SHA512:
6
- metadata.gz: 6ad342a14f5a57cb096a701f4861937350af646b705038fcdb00d756bc09c25f3067daf73e0f2bca7ca94e4774eda19b67cf09b871930f4887b2cd11f2cb9493
7
- data.tar.gz: 4da482b7bbcb9f87a6f867179230ffc382d6e535b1bda83940f0a703a902f8d7904ca1910d12624617447b022f3b045e396900137f5d7e174e5d06d2fd5df9af
6
+ metadata.gz: b60e84618d97800b225baf93de7a65d7ff9f94e8ef1f2084686891e46f571df2e29dfe02b08233f377da8c039b7286e07b601d7763136a20e781ee5d184daef2
7
+ data.tar.gz: 70c231673f5c34dbc1fcf37b6a9fe3c9740b48e05801bf2bdac4ccfc8c706208412376de0db5aac9dbced8dc450f5fd37ede28c4b0deedd739b3ce0bc6c4a509
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-11-15 18:29:11 +0900 using RuboCop version 0.60.0.
3
+ # on 2018-11-17 00:50:17 +0900 using RuboCop version 0.60.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop_challenger (1.0.0.pre2)
4
+ rubocop_challenger (1.0.0.pre3)
5
5
  octokit
6
6
  rubocop
7
7
  rubocop-rspec
@@ -15,10 +15,7 @@ VERSION_FORMAT = /\A\d+\.\d+\.\d+(\.(pre|beta|rc)\d?)?\z/.freeze
15
15
  version = ARGV[0]
16
16
  rubocop = RubocopChallenger::Rubocop::Command.new
17
17
  pr_creater =
18
- RubocopChallenger::Github::PrCreater.new(
19
- access_token: ENV['GITHUB_ACCESS_TOKEN'],
20
- branch: "update/v#{version}"
21
- )
18
+ RubocopChallenger::Github::PrCreater.new(branch: "update/v#{version}")
22
19
 
23
20
  # Verifying
24
21
  exit_process 'usage: bin/create_release_pr VERSION' if version.nil?
@@ -5,15 +5,17 @@ require 'thor'
5
5
  module RubocopChallenger
6
6
  # To define CLI commands
7
7
  class CLI < Thor
8
- desc 'go', 'Run `$ rubocop --auto-correct` and create PR to GitHub repo'
8
+ include CommandLine
9
+
10
+ desc 'go', 'Run `$ rubocop --auto-correct` and create a PR to GitHub repo'
9
11
  option :email,
10
12
  required: true,
11
13
  type: :string,
12
- desc: 'Pull Request committer email'
14
+ desc: 'The Pull Request committer email'
13
15
  option :name,
14
16
  required: true,
15
17
  type: :string,
16
- desc: 'Pull Request committer name'
18
+ desc: 'The Pull Request committer name'
17
19
  option :file_path,
18
20
  type: :string,
19
21
  default: '.rubocop_todo.yml',
@@ -22,15 +24,14 @@ module RubocopChallenger
22
24
  option :template,
23
25
  type: :string,
24
26
  aliases: :t,
25
- desc: 'Pull Request template `erb` file path.' \
27
+ desc: 'A Pull Request template `erb` file path.' \
26
28
  'You can use variable that `title`, `rubydoc_url`, ' \
27
29
  '`description` and `examples` into the erb file.'
28
30
  option :mode,
29
31
  type: :string,
30
32
  default: 'most_occurrence',
31
- desc: 'Mode to select deletion target. ' \
32
- 'You can choice "most_occurrence", "least_occurrence", ' \
33
- 'or "random"'
33
+ desc: 'Mode to select deletion target. You can choice ' \
34
+ '"most_occurrence", "least_occurrence", or "random"'
34
35
  option :base,
35
36
  type: :string,
36
37
  default: 'master',
@@ -53,8 +54,8 @@ module RubocopChallenger
53
54
  regenerate_rubocop_todo
54
55
  create_pull_request(target_rule)
55
56
  rescue StandardError => e
56
- puts e.message
57
- exit!
57
+ color_puts e.message, CommandLine::RED
58
+ exit_process!
58
59
  end
59
60
 
60
61
  desc 'version', 'Show current version'
@@ -74,7 +75,6 @@ module RubocopChallenger
74
75
 
75
76
  def pr_creater
76
77
  @pr_creater ||= Github::PrCreater.new(
77
- access_token: ENV['GITHUB_ACCESS_TOKEN'],
78
78
  branch: "rubocop-challenge/#{timestamp}",
79
79
  user_name: options[:name],
80
80
  user_email: options[:email]
@@ -120,5 +120,10 @@ module RubocopChallenger
120
120
  def timestamp
121
121
  @timestamp ||= Time.now.strftime('%Y%m%d%H%M%S')
122
122
  end
123
+
124
+ # Exit process (Mainly for mock when testing)
125
+ def exit_process!
126
+ exit!
127
+ end
123
128
  end
124
129
  end
@@ -2,16 +2,29 @@
2
2
 
3
3
  module RubocopChallenger
4
4
  # To execute command line. You should inherit this class to use.
5
- class CommandLine
5
+ module CommandLine
6
6
  private
7
7
 
8
8
  # Execute a command
9
9
  #
10
10
  # @param command [String] The command you want to execute
11
- # @return [String] Execution result
11
+ # @return [String] The result in the execution
12
12
  def execute(command)
13
13
  puts "$ #{command}"
14
- `#{command}`.chomp
14
+ `#{command}`.chomp.tap do |result|
15
+ color_code = $CHILD_STATUS.success? ? GREEN : RED
16
+ color_puts(result, color_code)
17
+ end
18
+ end
19
+
20
+ RED = 31
21
+ GREEN = 32
22
+ YELLOW = 33
23
+ BLUE = 34
24
+ PING = 35
25
+
26
+ def color_puts(string, color_code)
27
+ puts "\e[#{color_code}m#{string}\e[0m"
15
28
  end
16
29
  end
17
30
  end
@@ -3,7 +3,9 @@
3
3
  module RubocopChallenger
4
4
  module Git
5
5
  # To execute git command
6
- class Command < CommandLine
6
+ class Command
7
+ include CommandLine
8
+
7
9
  def initialize(user_name: nil, user_email: nil)
8
10
  @user_name = user_name
9
11
  @user_email = user_email
@@ -6,13 +6,14 @@ module RubocopChallenger
6
6
  class PrCreater
7
7
  # Returns a new instance of Github::PrCreater
8
8
  #
9
- # @param access_token [String] The GitHub access token
9
+ # @note You have to set ENV['GITHUB_ACCESS_TOKEN']
10
10
  # @param branch [String] The branch where your changes are going to
11
11
  # implement.
12
12
  # @param user_name [String] The username to use for committer and author
13
13
  # @param user_email [String] The email to use for committer and author
14
- def initialize(access_token:, branch:, user_name: nil, user_email: nil)
15
- @access_token = access_token
14
+ def initialize(branch:, user_name: nil, user_email: nil)
15
+ raise "You have to set ENV['GITHUB_ACCESS_TOKEN']" if access_token.nil?
16
+
16
17
  @topic_branch = branch
17
18
  @git = Git::Command.new(user_name: user_name, user_email: user_email)
18
19
  @github = Github::Client.new(access_token, git.remote_url('origin'))
@@ -55,7 +56,7 @@ module RubocopChallenger
55
56
 
56
57
  private
57
58
 
58
- attr_reader :access_token, :git, :github, :topic_branch, :initial_sha1
59
+ attr_reader :git, :github, :topic_branch, :initial_sha1
59
60
 
60
61
  def git_condition_valid?
61
62
  !git.current_sha1?(initial_sha1) && git.current_branch?(topic_branch)
@@ -67,8 +68,14 @@ module RubocopChallenger
67
68
  yield
68
69
  end
69
70
 
71
+ def access_token
72
+ ENV['GITHUB_ACCESS_TOKEN']
73
+ end
74
+
75
+ # @note You *MUST NOT* use `#access_token` in the URL because this string
76
+ # will be output STDOUT via `RubocopChallenger::CommandLine` module.
70
77
  def github_token_url
71
- "https://#{access_token}@github.com/#{github.repository}"
78
+ "https://${GITHUB_ACCESS_TOKEN}@github.com/#{github.repository}"
72
79
  end
73
80
  end
74
81
  end
@@ -3,7 +3,9 @@
3
3
  module RubocopChallenger
4
4
  module Rubocop
5
5
  # To execute rubocop gem command (Mainly for mock when testing)
6
- class Command < CommandLine
6
+ class Command
7
+ include CommandLine
8
+
7
9
  def auto_correct
8
10
  run('--auto-correct')
9
11
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubocopChallenger
4
- VERSION = '1.0.0.pre2'
4
+ VERSION = '1.0.0.pre3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop_challenger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre2
4
+ version: 1.0.0.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryosuke_sato
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-15 00:00:00.000000000 Z
11
+ date: 2018-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit