advance 0.1.13 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +1 -1
- data/lib/advance/version.rb +1 -1
- data/lib/advance.rb +38 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 842391aeff4f6050e96a64caee6e31d599d9052639936baab5f50acefcac976c
|
4
|
+
data.tar.gz: 1034ef6eb9ce638ca3ca484064fcfec2e0cfc6cae47383e467fc37526a10badf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fb5dbf6d11989a1b7496ede0801fd8c43138194cf425cbbe5b7c05a9443c16f042e327348b19199458a50e4503b0033f55aaac2da79872fd3f7c19fbf057197
|
7
|
+
data.tar.gz: f19a3493ae52d4971fa907d736bcccaa2fd364e52814d55bfdf99ed0b679cd4438ff142904aef7d815f2201ef6581c9844ac742409b24175c61c67a1fccce48e
|
data/Gemfile.lock
CHANGED
data/lib/advance/version.rb
CHANGED
data/lib/advance.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
require_relative "./advance/version"
|
2
2
|
require "find"
|
3
|
+
require "fileutils"
|
3
4
|
require "open3"
|
4
5
|
require "team_effort"
|
5
6
|
|
@@ -18,6 +19,8 @@ module Advance
|
|
18
19
|
WHITE="\e[1;37m"
|
19
20
|
YELLOW="\e[33m"
|
20
21
|
|
22
|
+
puts "loading module"
|
23
|
+
|
21
24
|
def advance(processing_mode, label, command)
|
22
25
|
$redo_mode ||= :checking
|
23
26
|
$step ||= 0
|
@@ -32,7 +35,7 @@ module Advance
|
|
32
35
|
|
33
36
|
clean_previous_step_dirs(dir_prefix)
|
34
37
|
|
35
|
-
send(processing_mode,
|
38
|
+
send(processing_mode, command, previous_dir_path, dir_name)
|
36
39
|
end
|
37
40
|
|
38
41
|
def static(processing_mode, label, command)
|
@@ -46,7 +49,7 @@ module Advance
|
|
46
49
|
|
47
50
|
FileUtils.rm_rf dir_name
|
48
51
|
|
49
|
-
send(processing_mode,
|
52
|
+
send(processing_mode, command, previous_dir_path, dir_name)
|
50
53
|
end
|
51
54
|
|
52
55
|
def get_previous_dir_path
|
@@ -79,7 +82,7 @@ module Advance
|
|
79
82
|
dirs.find { |d| d =~ /^#{dir_prefix}/ }
|
80
83
|
end
|
81
84
|
|
82
|
-
def single(
|
85
|
+
def single(command, previous_dir_path, dir_name)
|
83
86
|
work_in_sub_dir(dir_name) do
|
84
87
|
if command =~ /\{previous_file\}/
|
85
88
|
command.gsub!("{previous_file}", previous_file_path(previous_dir_path))
|
@@ -94,7 +97,7 @@ module Advance
|
|
94
97
|
end
|
95
98
|
end
|
96
99
|
|
97
|
-
def multi(
|
100
|
+
def multi(command, previous_dir_path, dir_name)
|
98
101
|
no_feedback = false
|
99
102
|
work_in_sub_dir(dir_name) do
|
100
103
|
file_paths = Find.find(previous_dir_path).reject { |path| FileTest.directory?(path) || File.basename(path) == "log" }
|
@@ -108,8 +111,8 @@ module Advance
|
|
108
111
|
TeamEffort.work(file_paths, $cores, progress_proc: progress_proc) do |file_path|
|
109
112
|
begin
|
110
113
|
file = File.basename(file_path)
|
111
|
-
command.gsub!("{file_path}", file_path)
|
112
|
-
command.gsub!("{file}", file)
|
114
|
+
command.gsub!("{file_path}", file_path)
|
115
|
+
command.gsub!("{file}", file)
|
113
116
|
puts "#{YELLOW}#{command}#{RESET}"
|
114
117
|
work_in_sub_dir(file) do
|
115
118
|
do_command command, no_feedback
|
@@ -123,13 +126,14 @@ module Advance
|
|
123
126
|
end
|
124
127
|
|
125
128
|
def work_in_sub_dir(dir_name)
|
126
|
-
|
129
|
+
stripped_dir_name = strip_extensions(dir_name)
|
130
|
+
if $redo_mode == :checking && Dir.exist?(stripped_dir_name)
|
127
131
|
return
|
128
132
|
end
|
129
133
|
|
130
134
|
$redo_mode = :replacing
|
131
135
|
|
132
|
-
tmp_dir_name = "tmp_#{
|
136
|
+
tmp_dir_name = "tmp_#{stripped_dir_name}"
|
133
137
|
FileUtils.rm_rf tmp_dir_name
|
134
138
|
FileUtils.mkdir_p tmp_dir_name
|
135
139
|
FileUtils.cd tmp_dir_name
|
@@ -137,7 +141,31 @@ module Advance
|
|
137
141
|
yield
|
138
142
|
|
139
143
|
FileUtils.cd ".."
|
140
|
-
FileUtils.mv tmp_dir_name,
|
144
|
+
FileUtils.mv tmp_dir_name, stripped_dir_name
|
145
|
+
end
|
146
|
+
|
147
|
+
def strip_extensions(dir_name)
|
148
|
+
extensions = %w(
|
149
|
+
csv
|
150
|
+
csv_nh
|
151
|
+
geo_json
|
152
|
+
geojson
|
153
|
+
gz
|
154
|
+
json
|
155
|
+
tar
|
156
|
+
tgz
|
157
|
+
zip
|
158
|
+
)
|
159
|
+
|
160
|
+
changed_dir_name = dir_name
|
161
|
+
last_dir_name = nil
|
162
|
+
until last_dir_name == changed_dir_name do
|
163
|
+
last_dir_name = changed_dir_name
|
164
|
+
extensions.each do |extension|
|
165
|
+
changed_dir_name = changed_dir_name.gsub(%r(\.#{extension}$), "")
|
166
|
+
end
|
167
|
+
end
|
168
|
+
changed_dir_name
|
141
169
|
end
|
142
170
|
|
143
171
|
def previous_file_path(previous_dir_path)
|
@@ -173,11 +201,6 @@ module Advance
|
|
173
201
|
end
|
174
202
|
end
|
175
203
|
|
176
|
-
# def find_step_dir
|
177
|
-
# dirs = Dir.entries(".")
|
178
|
-
# dirs.find { |d| d =~ /^#{step_dir_prefix($step)}/ }
|
179
|
-
# end
|
180
|
-
#
|
181
204
|
def ensure_bin_on_path
|
182
205
|
advance_path = File.dirname(__FILE__)
|
183
206
|
add_dir_to_path(advance_path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: advance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- janemacfarlane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: team_effort
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.7.8
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: A framework for building data transformation pipelines
|