lense 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/lense +2 -2
  3. data/lib/lense.rb +19 -18
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec156c1811be9d14df4746757856bf6df747adbc
4
- data.tar.gz: 3833cf6a368d6b0f795fc4a9783a0d6ea705dff1
3
+ metadata.gz: 48127f642dcb072a7efa9f4d06f27a2c3e876d37
4
+ data.tar.gz: d7d70a6dd8266744ea3f505cc584ff788d39dd8d
5
5
  SHA512:
6
- metadata.gz: c977bc392c01f297c73303bd64cb28e7bbd1c6fc6243a7f65f1708bffb4ec2165a39e0da9d7dca0ea9b998103b2e972721ab5411221ae76a1477f85b4651328f
7
- data.tar.gz: dd1bcafeb6e86a4204a96147cb40864c94a73598e6ad012ead7dc14a4d1191770b76a0e7177699e8f10a686ec0f59a0f053675e1d3d177d84c681971d8d1391a
6
+ metadata.gz: 155623f8e880665d2bc61ec35f9a628cab6d72867c3007f98340bca1477eded15d8fae7e064997cfa19268d42f36a00fb347835c72a9802dddcaace7cd16c7f1
7
+ data.tar.gz: 130d36f3322ed64512efa4a892088ff3233ca563ce5fbe273a76b45ba21705a24130c6f1f145f13f26400463868f427a438dcda680e28333bb81eb5242d5298b
data/bin/lense CHANGED
@@ -74,14 +74,14 @@ end
74
74
  command :pull do |c|
75
75
  c.action do |global_options,options,args|
76
76
  exit_now!('Must supply a LENSE repository.') if args.count < 1
77
- LENSE_APP.pull args[0]
77
+ LENSE_APP.install_repo args[0], :pull
78
78
  end
79
79
  end
80
80
 
81
81
  command :clone do |c|
82
82
  c.action do |global_options,options,args|
83
83
  exit_now!('Must supply a LENSE repository.') if args.count < 1
84
- LENSE_APP.clone args[0]
84
+ LENSE_APP.install_repo args[0], :clone
85
85
  end
86
86
  end
87
87
 
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.7'
10
+ VERSION = '0.2.8'
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')
@@ -257,18 +257,12 @@ class LENSE
257
257
  exit_now!("Invalid repo name.") unless repo =~ /\A\w+\/\w+\Z/
258
258
  end
259
259
 
260
- def pull(repo)
261
- exit_now!("Invalid repo name.") unless repo =~ /\A\w+\/\w+\Z/
262
- response = RestClient.get "#{API_BASE}/#{repo}/pull", { params: { format: 'json' } }
263
- repository = JSON.parse(response)
264
- end
265
-
266
- def clone(repo)
260
+ def install_repo(repo,action)
267
261
  exit_now!("Invalid repo name.") unless repo =~ /\A\w+\/\w+\Z/
268
262
  username, project_name = repo.split '/'
269
263
 
270
264
  say "making rest call"
271
- response = RestClient.get "#{API_BASE}/#{repo}/pull", { params: { format: 'json' } }
265
+ response = RestClient.get "#{API_BASE}/#{repo}/#{action.to_s}", { params: { format: 'json' } }
272
266
  repository = JSON.parse(response)
273
267
 
274
268
  # reading and checking tar file
@@ -278,16 +272,23 @@ class LENSE
278
272
 
279
273
  exit_now!("Failed download. Hash does not match.") unless hash_contents(tar_str) == tar_hash
280
274
 
281
- say "making dirs ..."
282
- # make repo dir in current directory
283
- Dir.mkdir project_name unless File.directory? project_name
275
+ if action == :clone
276
+ say "making dirs ..."
277
+ # make repo dir in current directory
278
+ Dir.mkdir project_name unless File.directory? project_name
284
279
 
285
- # make .lense dir and .lense/temp
286
- proj_lense_dir = File.join project_name, '.lense'
287
- Dir.mkdir proj_lense_dir unless File.directory? proj_lense_dir
280
+ # make .lense dir and .lense/temp
281
+ proj_lense_dir = File.join project_name, '.lense'
282
+ Dir.mkdir proj_lense_dir unless File.directory? proj_lense_dir
288
283
 
289
- temp_dir = File.join proj_lense_dir, 'temp'
290
- Dir.mkdir temp_dir unless File.directory? temp_dir
284
+ temp_dir = File.join proj_lense_dir, 'temp'
285
+ Dir.mkdir temp_dir unless File.directory? temp_dir
286
+
287
+ working_dir = "cd #{project_name} "
288
+ else
289
+ temp_dir = '.lense/temp'
290
+ working_dir = 'true'
291
+ end
291
292
 
292
293
  # write tar file to .lense/temp/hash.tar
293
294
  tar_fname = "#{tar_hash}.tar"
@@ -297,7 +298,7 @@ class LENSE
297
298
 
298
299
  # cd into repo dir and untar
299
300
  say "untaring to ... #{rel_tar_path}"
300
- `cd #{project_name} && tar -x#{TARFLAGS}f .lense/temp/#{tar_fname}`
301
+ `#{working_dir} && tar -x#{TARFLAGS}f .lense/temp/#{tar_fname}`
301
302
 
302
303
  say "done"
303
304
  # 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.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Zubieta