lense 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lense.rb +10 -5
- 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: 9a915a6a7faec49f962b8c6662d4fd17e499e32f
|
4
|
+
data.tar.gz: d36577185dc9bcee082af20a468e0ee8ec746300
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8373c25125c9dc51fe0efc74430a1e1c2cea955ac662e62a1acb1aa2c4ce5f517e6e2052da458aaca4dfa2928637989466ae3cce87a531bb04f4dbf456b9845c
|
7
|
+
data.tar.gz: 58a9688495471fc3abd4dc3ee4424abe9a3c0fd68ed0964d906357337caea00fcf17e29540756aa26ff738b7de62d995166961e1cb7d446b8ecd95caa91b5b2e
|
data/lib/lense.rb
CHANGED
@@ -7,7 +7,7 @@ require 'base64'
|
|
7
7
|
class LENSE
|
8
8
|
attr_reader :config, :current_course, :lense_file_hash
|
9
9
|
|
10
|
-
VERSION = '0.2.
|
10
|
+
VERSION = '0.2.6'
|
11
11
|
LENSE_DIR = File.join(ENV['HOME'],'.lense')
|
12
12
|
COURSES_DIR = File.join(LENSE_DIR,'courses')
|
13
13
|
CURRENT_COURSE_FILE = File.join(LENSE_DIR,'current_course')
|
@@ -265,14 +265,18 @@ class LENSE
|
|
265
265
|
|
266
266
|
def clone(repo)
|
267
267
|
exit_now!("Invalid repo name.") unless repo =~ /\A\w+\/\w+\Z/
|
268
|
+
username, project_name = repo.split '/'
|
269
|
+
|
268
270
|
say "making rest call"
|
269
271
|
response = RestClient.get "#{API_BASE}/#{repo}/pull", { params: { format: 'json' } }
|
270
272
|
repository = JSON.parse(response)
|
273
|
+
|
274
|
+
# reading and checking tar file
|
271
275
|
tar_str = Base64::decode64 repository["tar_file_base64"]
|
272
276
|
tar_hash = repository["tar_file_fingerprint"]
|
273
277
|
say "tar hash #{tar_hash}"
|
274
278
|
|
275
|
-
|
279
|
+
exit_now!("Failed download. Hash does not match.") unless hash_contents(tar_str) == tar_hash
|
276
280
|
|
277
281
|
say "making dirs ..."
|
278
282
|
# make repo dir in current directory
|
@@ -288,11 +292,12 @@ class LENSE
|
|
288
292
|
# write tar file to .lense/temp/hash.tar
|
289
293
|
tar_fname = "#{tar_hash}.tar"
|
290
294
|
say "writing tar file ... #{tar_fname}"
|
291
|
-
File.
|
295
|
+
rel_tar_path = File.join temp_dir, tar_fname
|
296
|
+
File.open(rel_tar_path, 'w') { |f| f.write tar_str }
|
292
297
|
|
293
|
-
say "untaring"
|
294
298
|
# cd into repo dir and untar
|
295
|
-
|
299
|
+
say "untaring to ... #{rel_tar_path}"
|
300
|
+
`cd #{project_name} && tar -x#{TARFLAGS}f #{rel_tar_path}`
|
296
301
|
|
297
302
|
say "done"
|
298
303
|
# read lensefile
|