unixoid-challenge 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: fb0161cd90643076d4f2b453a48bfc1542916857
4
- data.tar.gz: 2e3d355bc69d6d8efedb5c7b01173e02998d0f88
3
+ metadata.gz: 6eb5368f5c071103690171bd1efe6084cfb2f132
4
+ data.tar.gz: 5643f366e36987be9f0083696a1692e87d3ff1f6
5
5
  SHA512:
6
- metadata.gz: e674e0ff18ad0057dc87906755c72725f52b92e339309e5b73b91ddc7ebd45581368846c8ee32e3321d22c9f0c256aab50f3d81750353d9a0482baf2a65b20ee
7
- data.tar.gz: ec67b362cd57303a8aa2c1abc6ef2bcfb7f9e04892ffcb5ba13483988cad250f8d3cfbd39f681c45a93bbf81b904bca25b40af450029b81df5a42586c6853e50
6
+ metadata.gz: 5078d25f9c0efb1cd2b7d2d1418b6a340ef749e4e137bf742eaad4ecb32e4a5b951cee1053570231224c569d037a0466e54ac0215e856eb50d0707ec89ff183d
7
+ data.tar.gz: 15a42e7c7bf3e4bd6bfa765d897aed74eb29a0b174cf6f136bd3003eee274e5c2df10c52355792ee88b58b4216be2d0914cf0de690a1673a60713ced885bbb05
@@ -21,8 +21,12 @@ module Unixoid
21
21
  def push_to_github(file)
22
22
  github = Github.create_repo
23
23
  auth_fail! unless github.authenticated?
24
+
25
+ git = Git.new(github)
26
+ get_config(git) unless git.configured?
27
+
24
28
  puts "Submitting..."
25
- Git.submit(file, github)
29
+ git.submit(file)
26
30
  puts "Submitted!"
27
31
  end
28
32
 
@@ -39,6 +43,14 @@ module Unixoid
39
43
  puts render_results(results)
40
44
  end
41
45
 
46
+ def get_config(git)
47
+ puts 'Please enter your full name:'
48
+ name = gets.chomp
49
+ puts 'Please enter your e-mail address:'
50
+ email = gets.chomp
51
+ git.configure(name, email)
52
+ end
53
+
42
54
  def auth_fail!
43
55
  puts 'Incorrect login details. Please run unixoid-challenge again'.red
44
56
  exit 1
data/lib/unixoid/git.rb CHANGED
@@ -14,10 +14,6 @@ module Unixoid
14
14
  @runner = Runner.new
15
15
  end
16
16
 
17
- def self.submit(file, github)
18
- new(github).submit(file)
19
- end
20
-
21
17
  def submit(file)
22
18
  create_repo
23
19
  add(file)
@@ -51,6 +47,15 @@ module Unixoid
51
47
  run('git remote rm origin')
52
48
  end
53
49
 
50
+ def configured?
51
+ run('git config --get user.email', outcodes: [0, 1]) != '' && run('git config --get user.name', outcodes: [0, 1]) != ''
52
+ end
53
+
54
+ def configure(name, email)
55
+ run("git config --global user.name '#{name}'")
56
+ run("git config --global user.email '#{email}'")
57
+ end
58
+
54
59
  private
55
60
 
56
61
  def username
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unixoid-challenge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Joseph