projectionist-projects 0.1.4 → 0.1.5

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: d94b54468a1ad385f2304a3fd79eb825367656f5
4
- data.tar.gz: 08d9a4dec50141c88a7cf1e467e6c0eb53235cbd
3
+ metadata.gz: 40746ac517a182e5545f3b07fa2303a6be98a5dc
4
+ data.tar.gz: e2ed7f12192d3f09fe8df0a93a653c59991fee5b
5
5
  SHA512:
6
- metadata.gz: fc99640426ee0002b05fa9dcd97862dcbaba9378e840d41f250a1fc3baf30870de07f6c8e4ab5fb5271304d447b31774cd9f8e6e6bf03a55b3bfe5b56dad84a2
7
- data.tar.gz: b0f1554a2492b15ce6bb5bb60df039214df38cf4b7d71c91368ec1a8bf4989a0fe13afdacb4762f3f0c8ae0ea7a82de90a30cd5b4c93ea99455672dfb0e44874
6
+ metadata.gz: 08e0477173ced8c3c9efc0710e4af3ca610ced7e03f9002ea073c3bbd5e8ca55ed79f9fe396577ebc37bc1065d4ecab725bbae7bac6469517665920f9cdc79c9
7
+ data.tar.gz: 3ed9329b0af5904e870e70713cdf5272059dbb8b48602bd9c94b6991277043cce9963532742ead9d337a12ca22ebe736f0f9d0e57db5c61f49be8fb4ab097052
@@ -26,8 +26,22 @@ end
26
26
 
27
27
  def setup_cache_directory
28
28
  unless File.exist? DOWNLOAD_DIRECTORY
29
- puts "create projection-projects cache directory (y/N)? #{DOWNLOAD_DIRECTORY}"
30
- mkdir_p DOWNLOAD_DIRECTORY if "y" == gets.strip.downcase
29
+ mkdir_p DOWNLOAD_DIRECTORY
30
+ end
31
+ end
32
+
33
+ def download_files(downloads: [], confirm: true)
34
+ catch(:server_unavailable) do
35
+ results = Projectionist::Projects.fetch
36
+ projects = results.map { |result| result[:project] }
37
+ maximum = results.map(&:length).max
38
+ filtered = downloads.any? ? (downloads & projects) : projects
39
+
40
+ filtered.each do |project|
41
+ puts "downloading: #{colorize(project.ljust(maximum), :bold, :blue)}"
42
+ Projectionist::Projects.download project: project, confirm: confirm
43
+ end
44
+ return
31
45
  end
32
46
  end
33
47
 
@@ -56,6 +70,7 @@ parser = OptionParser.new do |opts|
56
70
 
57
71
  opts.on("-s", "--setup") do
58
72
  setup_cache_directory
73
+ download_files confirm: false
59
74
  exit
60
75
  end
61
76
 
@@ -79,21 +94,7 @@ parser = OptionParser.new do |opts|
79
94
  end
80
95
 
81
96
  opts.on("-d", "--download=DOWNLOADS", "Download projections from remote") do |downloads|
82
- downloads = (downloads || "").split(",").map(&:strip)
83
-
84
- catch(:server_unavailable) do
85
- results = Projectionist::Projects.fetch
86
- projects = results.map { |result| result[:project] }
87
- maximum = results.map(&:length).max
88
- filtered = downloads.any? ? (downloads & projects) : projects
89
-
90
- filtered.each do |project|
91
- puts "downloading: #{colorize(project.ljust(maximum), :bold, :blue)}"
92
- Projectionist::Projects.download project: project
93
- end
94
- exit
95
- end
96
-
97
+ download_files downloads: (downloads || "").split(",").map(&:strip)
97
98
  puts "The server is unavailable.. do you haz internets?"
98
99
  exit -1
99
100
  end
@@ -20,11 +20,11 @@ module Projectionist
20
20
  throw :server_unavailable
21
21
  end
22
22
 
23
- def self.download(project:, ask_to_overwrite: true, stdin: -> { gets })
23
+ def self.download(project:, confirm: true, stdin: -> { gets })
24
24
  normalized_project = "#{project}.projections.json"
25
25
  destination_file = File.join(DOWNLOAD_DIRECTORY, normalized_project)
26
26
 
27
- if ask_to_overwrite && File.exist?(destination_file)
27
+ if confirm && File.exist?(destination_file)
28
28
  print "Overwrite existing file? (y/N) "
29
29
  return unless stdin.call.strip.downcase == "y"
30
30
  end
@@ -1,5 +1,5 @@
1
1
  module Projectionist
2
2
  module Projects
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: projectionist-projects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy W. Rowe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-07 00:00:00.000000000 Z
11
+ date: 2016-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline