learn-open 1.1.59 → 1.2.0

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: 6c130640cdfeb17cf3c88ead41889edb49cc4651
4
- data.tar.gz: 9aeff17f2238e87a892057aa69ccf1ab497fa0f0
3
+ metadata.gz: 7330aa259179cd5f2c28ba41d279ac632266ba03
4
+ data.tar.gz: a70cf18a1f3791570d59a3185de77a2f9b572501
5
5
  SHA512:
6
- metadata.gz: ab0646d2f5ed19e082628d9dd48b1670b4734572526073d335b6bb15a413256868832bf54afbc8fd32689676cf1ac4b1fe87571b96a5abe396012335225bec2e
7
- data.tar.gz: 0c66e4d2e2442579f9ad2f29aead91950701319ab6e63e30b1b53f06468872138a3bd5d0c45c5f56085f9e3f960010bc99594875997eb3ee060bb18e788a6ce6
6
+ metadata.gz: e3cdc0b4da3b50bb866ac3257b5ac8f6b723276eeaa1fa998342af876d9cf4bc866cfd5745a004b3f870285e7523f1c3d5af0a7cd250ebc3e9b4b9eb9c03fc8f
7
+ data.tar.gz: f6e7f8a06fa9feb544a8682defa64d5b139ed20d93a33c7559f87ff60ad3c171986f921b5fba666f82968f50d41281da8a533ecfac7a65eda5c82aceb4e7912e
data/learn-open.gemspec CHANGED
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_runtime_dependency "netrc"
24
24
  spec.add_runtime_dependency "git"
25
- spec.add_runtime_dependency "learn-web", ">= 1.4.2"
25
+ spec.add_runtime_dependency "learn-web", ">= 1.5.0"
26
26
  end
@@ -1,15 +1,15 @@
1
1
  module LearnOpen
2
2
  class Opener
3
- attr_reader :editor, :client, :lessons_dir, :file_path, :get_next_lesson
4
- attr_accessor :lesson, :repo_dir, :lesson_is_lab, :lesson_id, :later_lesson
3
+ attr_reader :editor, :client, :lessons_dir, :file_path, :get_next_lesson, :token
4
+ attr_accessor :lesson, :repo_dir, :lesson_is_lab, :lesson_id, :later_lesson, :dot_learn
5
5
 
6
6
  def self.run(lesson:, editor_specified:, get_next_lesson:)
7
7
  new(lesson, editor_specified, get_next_lesson).run
8
8
  end
9
9
 
10
10
  def initialize(lesson, editor, get_next_lesson)
11
- _login, token = Netrc.read['learn-config']
12
- @client = LearnWeb::Client.new(token: token)
11
+ _login, @token = Netrc.read['learn-config']
12
+ @client = LearnWeb::Client.new(token: @token)
13
13
 
14
14
  @lesson = lesson
15
15
  @editor = editor
@@ -39,6 +39,29 @@ module LearnOpen
39
39
 
40
40
  private
41
41
 
42
+ def ping_fork_completion(retries=3)
43
+ begin
44
+ Timeout::timeout(15) do
45
+ client.submit_event(
46
+ event: 'fork',
47
+ learn_oauth_token: token,
48
+ repo_name: repo_dir,
49
+ base_org_name: lesson.split('/')[0],
50
+ forkee: { full_name: nil }
51
+ )
52
+ end
53
+ rescue Timeout::Error
54
+ if retries > 0
55
+ puts "There was a problem forking and cloning this lesson. Retrying..."
56
+ ping_fork_completion(retries-1)
57
+ else
58
+ puts "There is an issue connecting to Learn. Please try again."
59
+ File.write(file_path, 'ERROR: Error connecting to Learn')
60
+ exit
61
+ end
62
+ end
63
+ end
64
+
42
65
  def warn_if_necessary
43
66
  temp_args = nil
44
67
 
@@ -83,18 +106,21 @@ module LearnOpen
83
106
  self.lesson_is_lab = current_lesson.lab
84
107
  self.lesson_id = current_lesson.id
85
108
  self.later_lesson = false
109
+ self.dot_learn = current_lesson.dot_learn
86
110
  elsif !lesson && get_next_lesson
87
111
  puts "Getting next lesson..."
88
112
  self.lesson = get_next_lesson_forked_repo
89
113
  self.lesson_is_lab = next_lesson.lab
90
114
  self.lesson_id = next_lesson.id
91
115
  self.later_lesson = false
116
+ self.dot_learn = next_lesson.dot_learn
92
117
  else
93
118
  puts "Looking for lesson..."
94
- self.lesson = ensure_correct_lesson.repo_slug
119
+ self.lesson = ensure_correct_lesson.clone_repo
95
120
  self.lesson_is_lab = correct_lesson.lab
96
121
  self.lesson_id = correct_lesson.lesson_id
97
122
  self.later_lesson = correct_lesson.later_lesson
123
+ self.dot_learn = correct_lesson.dot_learn
98
124
  end
99
125
 
100
126
  self.repo_dir = lesson.split('/').last
@@ -111,7 +137,7 @@ module LearnOpen
111
137
  def get_current_lesson_forked_repo(retries=3)
112
138
  begin
113
139
  Timeout::timeout(15) do
114
- current_lesson.forked_repo
140
+ current_lesson.clone_repo
115
141
  end
116
142
  rescue Timeout::Error
117
143
  if retries > 0
@@ -128,7 +154,7 @@ module LearnOpen
128
154
  def get_next_lesson_forked_repo(retries=3)
129
155
  begin
130
156
  Timeout::timeout(15) do
131
- next_lesson.forked_repo
157
+ next_lesson.clone_repo
132
158
  end
133
159
  rescue Timeout::Error
134
160
  if retries > 0
@@ -167,18 +193,21 @@ module LearnOpen
167
193
  if !repo_exists?
168
194
  File.write(file_path, 'Forking repository...')
169
195
  puts "Forking lesson..."
170
- begin
171
- Timeout::timeout(15) do
172
- client.fork_repo(repo_name: repo_dir)
173
- end
174
- rescue Timeout::Error
175
- if retries > 0
176
- puts "There was a problem forking this lesson. Retrying..."
177
- fork_repo(retries-1)
178
- else
179
- puts "There is an issue connecting to Learn. Please try again."
180
- File.write(file_path, 'ERROR: Error connecting to Learn')
181
- exit
196
+
197
+ if !dot_learn || dot_learn[:github] != false
198
+ begin
199
+ Timeout::timeout(15) do
200
+ client.fork_repo(repo_name: repo_dir)
201
+ end
202
+ rescue Timeout::Error
203
+ if retries > 0
204
+ puts "There was a problem forking this lesson. Retrying..."
205
+ fork_repo(retries-1)
206
+ else
207
+ puts "There is an issue connecting to Learn. Please try again."
208
+ File.write(file_path, 'ERROR: Error connecting to Learn')
209
+ exit
210
+ end
182
211
  end
183
212
  end
184
213
  end
@@ -213,6 +242,10 @@ module LearnOpen
213
242
  end
214
243
  end
215
244
  end
245
+
246
+ if dot_learn && dot_learn[:github] == false
247
+ ping_fork_completion
248
+ end
216
249
  end
217
250
 
218
251
  def repo_exists?
@@ -242,10 +275,10 @@ module LearnOpen
242
275
  File.write(file_path, 'ERROR: Problem parsing lesson data. Try again.')
243
276
  exit
244
277
  end
245
- rescue NoMethodError => e
278
+ rescue NoMethodError, Errno::ENOENT => e
246
279
  if xcodeproj_file? || xcworkspace_file?
247
280
  true
248
- elsif e.message.match(/for false:FalseClass/)
281
+ elsif e.message.match(/for false:FalseClass/) || e.message.match(/No such file or directory/)
249
282
  false
250
283
  else
251
284
  puts "Sorry, there seems to be a problem with this lesson. Please submit a bug report to bugs@learn.co and try again later."
@@ -1,3 +1,3 @@
1
1
  module LearnOpen
2
- VERSION = '1.1.59'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: learn-open
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.59
4
+ version: 1.2.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: 2016-04-06 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 1.4.2
75
+ version: 1.5.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 1.4.2
82
+ version: 1.5.0
83
83
  description:
84
84
  email:
85
85
  - learn@flatironschool.com