coauthor 0.1.1 → 0.1.2

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: 27fa07defdb28ea82b7334346226cd3bf5aef1a8705c461f49063b752efeb6d1
4
- data.tar.gz: dbd2fb5497a8cdbeeb373a76ded477b53ac75a44374bc2bf55a9ec8c4b709169
3
+ metadata.gz: ef5ccdf6d254fcc62b6abf008a2999a37bffc6676344dd2b41d0235fc4c66a2b
4
+ data.tar.gz: bdf16b2edf0735e212dc1e8a0b6f04d2004c7581d7d1330b077a10df36f535c9
5
5
  SHA512:
6
- metadata.gz: 8cdfc97fc4450f64341ec3a6119ec862c8c40e2fd75348675a7c9fda300f90c935b107a2b8d056732487f87c530040f14b8a055a0b6a5da235dfdfe5bf14b657
7
- data.tar.gz: 8f8b8aaff6a95e96256d3129e9540cfd33f67639c17e2376baf51edc881d00f8708331be5b7a35fceb49cb7b0f0ab655a3ecb6449efd98865490e38e012a5223
6
+ metadata.gz: 15aa27fb8cfb6f506a0504a22fc87ba6e94490660dffce3197d83b30038ab9c3eab83dfbc06d6c8c511c92ccd1180f24b48d52da7655ec604ff6566322f191be
7
+ data.tar.gz: c20b154b265bed9c0a60fc3e848302f8d1590e79ec7131c22e83a1e636f443c255faf1fb6d8e5b02bfa09fa8ac75a81ec42b7cb770f7cd57f72ed57156e6ef93
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Metrics/LineLength:
5
+ Max: 100
6
+
7
+ Style/AccessModifierDeclarations:
8
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,20 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coauthor (0.1.1)
4
+ coauthor (0.1.2)
5
5
  colorize (~> 0.8.1)
6
6
  thor (~> 0.20.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
+ ast (2.4.0)
11
12
  coderay (1.1.2)
12
13
  colorize (0.8.1)
13
14
  diff-lcs (1.3)
15
+ jaro_winkler (1.5.1)
14
16
  method_source (0.9.0)
17
+ parallel (1.12.1)
18
+ parser (2.5.1.2)
19
+ ast (~> 2.4.0)
20
+ powerpack (0.1.2)
15
21
  pry (0.11.3)
16
22
  coderay (~> 1.1.0)
17
23
  method_source (~> 0.9.0)
24
+ rainbow (3.0.0)
18
25
  rake (10.5.0)
19
26
  rspec (3.7.0)
20
27
  rspec-core (~> 3.7.0)
@@ -29,7 +36,17 @@ GEM
29
36
  diff-lcs (>= 1.2.0, < 2.0)
30
37
  rspec-support (~> 3.7.0)
31
38
  rspec-support (3.7.0)
39
+ rubocop (0.58.2)
40
+ jaro_winkler (~> 1.5.1)
41
+ parallel (~> 1.10)
42
+ parser (>= 2.5, != 2.5.1.1)
43
+ powerpack (~> 0.1)
44
+ rainbow (>= 2.2.2, < 4.0)
45
+ ruby-progressbar (~> 1.7)
46
+ unicode-display_width (~> 1.0, >= 1.0.1)
47
+ ruby-progressbar (1.10.0)
32
48
  thor (0.20.0)
49
+ unicode-display_width (1.4.0)
33
50
 
34
51
  PLATFORMS
35
52
  ruby
@@ -40,6 +57,7 @@ DEPENDENCIES
40
57
  pry (~> 0.11.0)
41
58
  rake (~> 10.0)
42
59
  rspec (~> 3.0)
60
+ rubocop (~> 0.58.2)
43
61
 
44
62
  BUNDLED WITH
45
- 1.16.0
63
+ 1.16.2
data/coauthor.gemspec CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency 'pry', '~> 0.11.0'
27
27
  spec.add_development_dependency 'rake', '~> 10.0'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'rubocop', '~> 0.58.2'
29
30
 
30
31
  spec.add_runtime_dependency 'colorize', '~> 0.8.1'
31
32
  spec.add_runtime_dependency 'thor', '~> 0.20.0'
data/lib/coauthor/cli.rb CHANGED
@@ -1,22 +1,30 @@
1
1
  require 'thor'
2
2
  require 'colorize'
3
- require 'coauthor/setup'
4
- require 'coauthor/constants'
3
+
4
+ Gem.find_files('coauthor/git/**/*.rb').each { |path| require path }
5
5
 
6
6
  module Coauthor
7
7
  class CLI < Thor
8
- include Constants
9
-
10
- desc 'setup', 'Create a configuration file for Github Coauthoring'
8
+ SETUP_DESCRIPTION = 'Create a template file for Github Coauthoring'.freeze
9
+ desc 'setup', SETUP_DESCRIPTION
11
10
  def setup
12
- Coauthor::Setup.new.call
11
+ puts SETUP_DESCRIPTION.colorize(:blue)
12
+ Coauthor::Git::Template.call
13
13
  end
14
14
 
15
- desc 'commit', 'Default command. Make a commit with the coauthor configuration'
15
+ COMMIT_DESCRIPTION = 'Git commit with the coauthor template file'.freeze
16
+ desc 'commit', COMMIT_DESCRIPTION
16
17
  def commit
17
- return system("git commit --template #{PAIR_CONFIG_FILE}") if File.file?(PAIR_FILE_PATH)
18
- puts `echo "Run coauthor setup before committing with Coauthor"`
18
+ puts COMMIT_DESCRIPTION.colorize(:blue)
19
+ Coauthor::Git::Commit.call
19
20
  end
20
21
  default_task :commit
22
+
23
+ GIT_USER_DESCRIPTION = 'Set the default git user for the current repository'.freeze
24
+ desc 'git_user', GIT_USER_DESCRIPTION
25
+ def git_user
26
+ puts GIT_USER_DESCRIPTION.colorize(:blue)
27
+ Coauthor::Git::User.call
28
+ end
21
29
  end
22
30
  end
@@ -0,0 +1,13 @@
1
+ require 'coauthor/constants'
2
+
3
+ module Coauthor
4
+ module Git
5
+ class Commit
6
+ include Constants
7
+ def self.call
8
+ return system("git commit --template #{PAIR_CONFIG_FILE}") if File.file?(PAIR_FILE_PATH)
9
+ puts('Run `coauthor setup` before committing with Coauthor').colorize(:red)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,34 @@
1
+ require 'coauthor/constants'
2
+ require 'coauthor/prompt'
3
+
4
+ module Coauthor
5
+ module Git
6
+ class Template
7
+ include Constants
8
+ attr_reader :credentials
9
+ def initialize(credentials:)
10
+ @credentials = credentials
11
+ write_file
12
+ end
13
+
14
+ def self.call
15
+ credentials = Prompt.fetch_user_info(user_count: 2)
16
+ return unless credentials
17
+ new(credentials: credentials)
18
+ rescue SystemExit, Interrupt
19
+ puts "\n...Template setup cancelled".colorize(:red)
20
+ end
21
+
22
+ private
23
+
24
+ def write_file
25
+ File.open(PAIR_FILE_PATH, 'w+') do |file|
26
+ credentials.each do |detail|
27
+ file.write("\nCo-authored-by: #{detail['name']} <#{detail['email']}>")
28
+ end
29
+ end
30
+ puts "...DONE! Coauthor file written to #{PAIR_CONFIG_FILE}\n".colorize(:green)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,29 @@
1
+ require 'coauthor/prompt'
2
+
3
+ module Coauthor
4
+ module Git
5
+ class User
6
+ attr_reader :name, :email
7
+ def initialize(name:, email:)
8
+ @name = name
9
+ @email = email
10
+ set_git_config
11
+ end
12
+
13
+ def self.call
14
+ user_info = Prompt.fetch_user_info.first
15
+ new(name: user_info['name'], email: user_info['email'])
16
+ rescue SystemExit, Interrupt
17
+ puts "\n...User setup cancelled".colorize(:red)
18
+ end
19
+
20
+ private
21
+
22
+ def set_git_config
23
+ system("git config user.name #{name}")
24
+ system("git config user.email #{email}")
25
+ puts "...DONE! Git repository author has been set to #{name} <#{email}>".colorize(:green)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ module Coauthor
2
+ module Prompt
3
+ def user_name
4
+ puts "Enter the user's name:".colorize(:yellow)
5
+ STDIN.gets.chomp
6
+ end
7
+ module_function :user_name
8
+
9
+ def user_email
10
+ puts "Enter the author's email:".colorize(:yellow)
11
+ STDIN.gets.chomp
12
+ end
13
+ module_function :user_email
14
+
15
+ def fetch_user_info(user_count: 1)
16
+ [].tap do |credentials|
17
+ user_count.times do
18
+ detail = {}
19
+ detail['name'] = user_name
20
+ detail['email'] = user_email
21
+ credentials << detail if detail.keys.any? && !detail.values.join.strip.empty?
22
+ end
23
+ end
24
+ end
25
+ module_function :fetch_user_info
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Coauthor
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coauthor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Vogel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-12 00:00:00.000000000 Z
11
+ date: 2018-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.58.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.58.2
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: colorize
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -104,6 +118,7 @@ extra_rdoc_files: []
104
118
  files:
105
119
  - ".gitignore"
106
120
  - ".rspec"
121
+ - ".rubocop.yml"
107
122
  - ".travis.yml"
108
123
  - Gemfile
109
124
  - Gemfile.lock
@@ -115,7 +130,10 @@ files:
115
130
  - lib/coauthor.rb
116
131
  - lib/coauthor/cli.rb
117
132
  - lib/coauthor/constants.rb
118
- - lib/coauthor/setup.rb
133
+ - lib/coauthor/git/commit.rb
134
+ - lib/coauthor/git/template.rb
135
+ - lib/coauthor/git/user.rb
136
+ - lib/coauthor/prompt.rb
119
137
  - lib/coauthor/version.rb
120
138
  homepage: https://github.com/avogel3/coauthor
121
139
  licenses:
@@ -1,48 +0,0 @@
1
- require 'coauthor/constants'
2
-
3
- module Coauthor
4
- class Setup
5
- include Constants
6
- attr_accessor :credentials
7
-
8
- def initialize
9
- @credentials = []
10
- end
11
-
12
- def call
13
- gather_coauthor_info
14
- write_coauthor_file
15
- rescue SystemExit, Interrupt
16
- puts "\n...Setup cancelled".colorize(:red)
17
- end
18
-
19
- private
20
-
21
- def gather_coauthor_info
22
- puts 'Welcome to Coauthor Setup'.colorize(:blue)
23
- 2.times do |n|
24
- detail = {}
25
- color = info_color(n + 1)
26
- print "Enter commiter #{n + 1}'s name: ".colorize(color)
27
- detail['name'] = STDIN.gets.chomp
28
- print "Enter commiter #{n + 1}'s email: ".colorize(color)
29
- detail['email'] = STDIN.gets.chomp
30
- credentials << detail
31
- end
32
- end
33
-
34
- def info_color(iter)
35
- iter.even? ? :magenta : :yellow
36
- end
37
-
38
- def write_coauthor_file
39
- File.open(PAIR_FILE_PATH, 'w+') do |file|
40
- file.puts
41
- credentials.each do |detail|
42
- file.write("\nCo-authored-by: #{detail['name']} <#{detail['email']}>")
43
- end
44
- end
45
- puts "...DONE! Coauthor file written to #{PAIR_CONFIG_FILE}\n".colorize(:green)
46
- end
47
- end
48
- end