lense 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lense.rb +10 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eadd08f9d1e0606d63936551162eccf4c29c2849
4
- data.tar.gz: 3eacf0f096032253a0b69939e59c939ba3af8b15
3
+ metadata.gz: 9a915a6a7faec49f962b8c6662d4fd17e499e32f
4
+ data.tar.gz: d36577185dc9bcee082af20a468e0ee8ec746300
5
5
  SHA512:
6
- metadata.gz: a862ca67cacf9fe5e8c735f0b81fad29269f1a029aee4708dbdf2a720fe1e815344060cfa4e1884b2cf3d7741aae0623921469b509ea44fa3ca82929a4e0e48f
7
- data.tar.gz: 754b219133e7e15f16c660396ddd9897041cb4e3d17e8407e6a24f549ab612d27a283136dfeba090353690e95bde9e6a179a9fa17ef790e5b5640a15967232e7
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.5'
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
- username, project_name = repo.split '/'
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.open(File.join(temp_dir,tar_fname), 'w') { |f| f.write tar_str }
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
- `cd #{project_name} && tar -x#{TARFLAGS}f #{tar_fname}`
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lense
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Zubieta