learn-co 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/learn +1 -1
- data/learn-co.gemspec +1 -0
- data/lib/learn/cli.rb +20 -0
- data/lib/learn/internet_connection.rb +14 -4
- data/lib/learn/options_sanitizer.rb +4 -2
- data/lib/learn/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f2adf6bebf6ba87dc15c14bc8310b1d3658ccf6
|
4
|
+
data.tar.gz: d127d6070c3ff8f5f0adfa0091d978913cbfecac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7031829ea2fd08d73f321d48f1c74000e1ef360be05c0e629f4ed4b19248f004444a52e3b4edbb1a6be36862fe44026d222adc1a2ac514f3d45d2a771d74e0f
|
7
|
+
data.tar.gz: 4d5f8c11428cfd03cc6d8846ee7c053d3b7fe930102544443c2bccc7d87b865b315c673a3ddc5ea3b1fb8b7e53bed8c589043a120d9f45ac9951b9aa58097b86
|
data/bin/learn
CHANGED
data/learn-co.gemspec
CHANGED
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_runtime_dependency "learn-open", ">= 1.1.51"
|
27
27
|
spec.add_runtime_dependency "learn-submit", ">= 1.0.12"
|
28
28
|
spec.add_runtime_dependency "learn-doctor", ">= 1.0.2"
|
29
|
+
spec.add_runtime_dependency "learn-generate", ">= 1.0.1"
|
29
30
|
spec.add_runtime_dependency "thor"
|
30
31
|
end
|
data/lib/learn/cli.rb
CHANGED
@@ -79,5 +79,25 @@ module Learn
|
|
79
79
|
def doctor
|
80
80
|
system('learn-doctor')
|
81
81
|
end
|
82
|
+
|
83
|
+
desc 'new lab-name -t|--template template-name', 'Generate a new lesson repo using a Learn.co template', hide: true
|
84
|
+
option :template, required: false, type: :string, aliases: ['t']
|
85
|
+
option :list, required: false, type: :boolean
|
86
|
+
def new(*lab_name)
|
87
|
+
has_internet = Learn::InternetConnection.internet_connection?
|
88
|
+
template = options[:template]
|
89
|
+
list = options[:list]
|
90
|
+
|
91
|
+
if list
|
92
|
+
system("learn-generate --list #{has_internet ? '--internet' : ''}")
|
93
|
+
else
|
94
|
+
if template && template != 'template'
|
95
|
+
system("learn-generate #{template} #{lab_name.join} #{has_internet ? '--internet' : ''}")
|
96
|
+
else
|
97
|
+
puts "You must specify a template with -t or --template"
|
98
|
+
exit
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
82
102
|
end
|
83
103
|
end
|
@@ -4,6 +4,7 @@ require 'timeout'
|
|
4
4
|
module Learn
|
5
5
|
class InternetConnection
|
6
6
|
attr_accessor :connection
|
7
|
+
attr_reader :silent
|
7
8
|
|
8
9
|
STATUS_URI = URI('https://learn.co/p/gem_status')
|
9
10
|
SUCCESS_STATUS = 'this is a boring message to prove you can connect to the internet'
|
@@ -13,12 +14,17 @@ module Learn
|
|
13
14
|
new.no_connection?
|
14
15
|
end
|
15
16
|
|
17
|
+
def self.internet_connection?
|
18
|
+
new(silent: true).connection?
|
19
|
+
end
|
20
|
+
|
16
21
|
def self.test_connection
|
17
22
|
new
|
18
23
|
end
|
19
24
|
|
20
|
-
def initialize
|
25
|
+
def initialize(silent: false)
|
21
26
|
@connection = false
|
27
|
+
@silent = silent
|
22
28
|
|
23
29
|
test_connection
|
24
30
|
end
|
@@ -32,16 +38,16 @@ module Learn
|
|
32
38
|
self.connection = true
|
33
39
|
else
|
34
40
|
self.connection = false
|
35
|
-
puts NO_INTERNET_MESSAGE
|
41
|
+
puts NO_INTERNET_MESSAGE if !silent
|
36
42
|
end
|
37
43
|
end
|
38
44
|
rescue Timeout::Error
|
39
45
|
self.connection = false
|
40
|
-
puts NO_INTERNET_MESSAGE
|
46
|
+
puts NO_INTERNET_MESSAGE if !silent
|
41
47
|
rescue SocketError => e
|
42
48
|
if e.message.match(/getaddrinfo: nodename nor servname provided/)
|
43
49
|
self.connection = false
|
44
|
-
puts NO_INTERNET_MESSAGE
|
50
|
+
puts NO_INTERNET_MESSAGE if !silent
|
45
51
|
end
|
46
52
|
end
|
47
53
|
end
|
@@ -49,5 +55,9 @@ module Learn
|
|
49
55
|
def no_connection?
|
50
56
|
!connection
|
51
57
|
end
|
58
|
+
|
59
|
+
def connection?
|
60
|
+
connection
|
61
|
+
end
|
52
62
|
end
|
53
63
|
end
|
@@ -3,7 +3,8 @@ module Learn
|
|
3
3
|
attr_reader :args
|
4
4
|
|
5
5
|
SANITIZE_LIST = {
|
6
|
-
'-e' => '--editor'
|
6
|
+
'-e' => '--editor',
|
7
|
+
'-t' => '--template'
|
7
8
|
}
|
8
9
|
|
9
10
|
KNOWN_COMMANDS = [
|
@@ -18,7 +19,8 @@ module Learn
|
|
18
19
|
'whoami',
|
19
20
|
'directory',
|
20
21
|
'next',
|
21
|
-
'doctor'
|
22
|
+
'doctor',
|
23
|
+
'new'
|
22
24
|
]
|
23
25
|
|
24
26
|
KNOWN_TEST_FLAGS = [
|
data/lib/learn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: learn-co
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flatiron School
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.0.2
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: learn-generate
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.0.1
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.0.1
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: thor
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|