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 +4 -4
- data/README.md +20 -17
- data/lib/unixoid/challenge.rb +2 -2
- data/lib/unixoid/controller.rb +1 -1
- data/lib/unixoid/git.rb +7 -6
- data/lib/unixoid/github.rb +4 -4
- data/lib/unixoid/runner.rb +5 -5
- data/lib/unixoid/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fa9de0ab3c14010e5594751ddc09736a9ea49ed
|
4
|
+
data.tar.gz: 591d1ced3321cdc228f6ad7fda0f5fec3cb41e9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/unixoid/challenge.rb
CHANGED
data/lib/unixoid/controller.rb
CHANGED
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
|
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
|
56
|
-
run("git config --global user.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
|
data/lib/unixoid/github.rb
CHANGED
@@ -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 "
|
39
|
+
%Q{curl -u ":username::password" #{GITHUB_URL} -d '{"name": "#{REPO_NAME}"}'}
|
40
40
|
end
|
41
41
|
|
42
42
|
def parse(response)
|
data/lib/unixoid/runner.rb
CHANGED
@@ -11,14 +11,14 @@ module Unixoid
|
|
11
11
|
@logger = Logger.new(LOG_FILE)
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.run(command,
|
15
|
-
new.run(command,
|
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(
|
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
|
data/lib/unixoid/version.rb
CHANGED