unixoid-challenge 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 821f642f54aed4725d643e4092c853a9b1b51271
4
- data.tar.gz: 734ade33d5ec3a3fb48b5fc1fdd1873848c11f3f
3
+ metadata.gz: 2fa9de0ab3c14010e5594751ddc09736a9ea49ed
4
+ data.tar.gz: 591d1ced3321cdc228f6ad7fda0f5fec3cb41e9c
5
5
  SHA512:
6
- metadata.gz: 14964894b315d387d5a3407c2082a77c3ccdcdb9979d215f99eb7bcea90a85b50bc259e0bd7ca9325a676cc861a566fe41c0a0d485bddaea950eb129032d938d
7
- data.tar.gz: bf6c3eb087b32b03029278d08c23117df98ed9bbf28b7b05bb153f61880d4ad016c3f0f5ffe98de5055a968ac82580dd59dfe9f8bdaf5119ae6646cd1e4aa613
6
+ metadata.gz: a196cce9b0bf40ecdd5995f4e52b3304d568b655516bc328daf4a796a996ef8c6d5e2ddeb16685edf904a1e5ed58a147a7077a47dd666bdb1cf03be009e09671
7
+ data.tar.gz: f1f70e41719d165ce4272eece4f83a2bb90663c9548eff6ef6bc0459271968bdb7b7ffdf154d17214b6f41e72b5b61752097210dc51c4ad0ea35c5fcfa80a164
data/README.md CHANGED
@@ -25,6 +25,26 @@ Then change into that directory using this next command:
25
25
  cd temp
26
26
  ```
27
27
 
28
+ Checking and submitting your progress
29
+ -------------------------------------
30
+
31
+ First, you will need to install the `unixoid-challenge` gem, like this:
32
+
33
+ ```sh
34
+ gem install unixoid-challenge
35
+ ```
36
+
37
+ At any point while going through the challenge you can check your progress by running:
38
+
39
+ ```sh
40
+ unixoid-challenge
41
+ ```
42
+
43
+ We recommend running this after each task to make sure you're on the right track.
44
+ __(make sure you are in the temp directory when you run "unixoid-challenge")__
45
+
46
+ This will tell you if you've completed the task, or which of the tasks above you still need to complete. It will also submit your results to GitHub (you'll need your username and password that you use to login to GitHub) so we can track your progress.
47
+
28
48
  Now use your command line skills to complete the following:
29
49
 
30
50
  1. Using one command, create a directory structure "my/private/files"
@@ -42,21 +62,4 @@ Now use your command line skills to complete the following:
42
62
  13. Create another file my/private/files/first-three-env.txt and output the first three env variables from a list of all of them sorted alphabetically
43
63
  14. Create another file my/private/files/commands.txt and output the contents of the `history` command to that file
44
64
 
45
- Checking and submitting your progress
46
- -------------------------------------
47
-
48
- First, you will need to install the `unixoid-challenge` gem, like this:
49
-
50
- ```sh
51
- gem install unixoid-challenge
52
- ```
53
65
 
54
- At any point while going through the challenge you can check your progress by running:
55
-
56
- ```sh
57
- unixoid-challenge
58
- ```
59
-
60
- __(make sure you are in the same directory that you completed the challenge in)__
61
-
62
- This will tell you if you've completed the task, or which of the tasks above you still need to complete. It will also submit your results to GitHub (you'll need your username and password that you use to login to GitHub) so we can track your progress.
@@ -1,6 +1,6 @@
1
1
  module Unixoid
2
2
  class Challenge
3
-
3
+
4
4
  RESULTS_FILE = 'unixoid_results.txt'
5
5
 
6
6
  def self.run_specs
@@ -17,6 +17,6 @@ module Unixoid
17
17
 
18
18
  def spec_file
19
19
  File.join(File.dirname(__FILE__), '..', '..','challenge_spec.rb')
20
- end
20
+ end
21
21
  end
22
22
  end
@@ -45,7 +45,7 @@ module Unixoid
45
45
 
46
46
  def get_config(git)
47
47
  puts 'Please enter your full name:'
48
- name = gets.chomp
48
+ name = gets.chomp
49
49
  puts 'Please enter your e-mail address:'
50
50
  email = gets.chomp
51
51
  git.configure(name, email)
data/lib/unixoid/git.rb CHANGED
@@ -8,7 +8,7 @@ module Unixoid
8
8
  extend Forwardable
9
9
 
10
10
  delegate run: :@runner
11
-
11
+
12
12
  def initialize(github)
13
13
  @github = github
14
14
  @runner = Runner.new
@@ -24,7 +24,7 @@ module Unixoid
24
24
  end
25
25
 
26
26
  def create_repo
27
- run('git init')
27
+ run('git init')
28
28
  end
29
29
 
30
30
  def add(file)
@@ -36,7 +36,7 @@ module Unixoid
36
36
  end
37
37
 
38
38
  def add_remote
39
- run("git remote add origin https://#{username}:#{password}@github.com/#{username}/unixoid_submission.git")
39
+ run("git remote add origin https://:username::password@github.com/:username/unixoid_submission.git", params: {username: username, password: password})
40
40
  end
41
41
 
42
42
  def push_results
@@ -50,12 +50,13 @@ module Unixoid
50
50
  def configured?
51
51
  run('git config --get user.email', outcodes: [0, 1]) != '' && run('git config --get user.name', outcodes: [0, 1]) != ''
52
52
  end
53
-
53
+
54
54
  def configure(name, email)
55
- run("git config --global user.name '#{name}'")
56
- run("git config --global user.email '#{email}'")
55
+ run("git config --global user.name :name", params: {name: name})
56
+ run("git config --global user.email :email", params: {email: email})
57
57
  end
58
58
 
59
+
59
60
  private
60
61
 
61
62
  def username
@@ -4,7 +4,7 @@ require 'json'
4
4
  module Unixoid
5
5
 
6
6
  class Github
7
-
7
+
8
8
  GITHUB_URL = 'https://api.github.com/user/repos'
9
9
  REPO_NAME = 'unixoid_submission'
10
10
 
@@ -17,7 +17,7 @@ module Unixoid
17
17
  end
18
18
 
19
19
  def create_repo
20
- parse @runner.run(command)
20
+ parse @runner.run(command, params: {username: username, password: password})
21
21
  self
22
22
  end
23
23
 
@@ -28,7 +28,7 @@ module Unixoid
28
28
  def password
29
29
  @password ||= ask_for_password
30
30
  end
31
-
31
+
32
32
  def authenticated?
33
33
  @response && @response['message'] != "Bad credentials"
34
34
  end
@@ -36,7 +36,7 @@ module Unixoid
36
36
  private
37
37
 
38
38
  def command
39
- %Q{curl -u "#{username}:#{password}" #{GITHUB_URL} -d '{"name": "#{REPO_NAME}"}'}
39
+ %Q{curl -u ":username::password" #{GITHUB_URL} -d '{"name": "#{REPO_NAME}"}'}
40
40
  end
41
41
 
42
42
  def parse(response)
@@ -11,14 +11,14 @@ module Unixoid
11
11
  @logger = Logger.new(LOG_FILE)
12
12
  end
13
13
 
14
- def self.run(command, opts = {})
15
- new.run(command, opts)
14
+ def self.run(command, params: {}, outcodes: {})
15
+ new.run(command, params: params, outcodes: outcodes)
16
16
  end
17
17
 
18
- def run(command, outcodes: [0])
19
- line = Cocaine::CommandLine.new(command, "", expected_outcodes: outcodes, swallow_stderr: true)
18
+ def run(command, params: {}, outcodes: [0])
19
+ line = Cocaine::CommandLine.new('', command, expected_outcodes: outcodes, swallow_stderr: true)
20
20
  begin
21
- log(:info, line.run)
21
+ log(:info, line.run(params))
22
22
  rescue Cocaine::ExitStatusError => error
23
23
  log(:error, error.message)
24
24
  end
@@ -1,5 +1,5 @@
1
1
  # coding: UTF-8
2
2
 
3
3
  module Unixoid
4
- VERSION = "0.1.1".freeze
4
+ VERSION = "0.1.2".freeze
5
5
  end
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Joseph