advance 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -8
- data/lib/advance/version.rb +1 -1
- data/lib/advance.rb +16 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7f5948d846efa632c923c68ea86b89b1b785f6ffd58fda4f52fc0cac30579d1
|
4
|
+
data.tar.gz: c29928e7ed6662adb03144adf1029b2b5e834cfe3e2f90ee76babc007425646a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35da400978126d81ce5babf678b0ae68eb2c698fae75e39d28da4d4bdabd68dfc3294b3e7f44d045d5b612f614928e5c8027c1506a8bb2bae5eab72b4b9b3d26
|
7
|
+
data.tar.gz: 64d1afb3685a4bd9f2a70d7c07cdc1e0ff3f93c553ef3f82d6165ef92e8486622b0577a78f067ece3cdceeb39513ad73c85499396f732f81ddc87f0a433ce257
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -102,18 +102,17 @@ Since your command is transforming data, you need a way to specify the input
|
|
102
102
|
file or directory and the output file name. Advance provides a few tokens
|
103
103
|
that can be inserted in the command string for this purpose:
|
104
104
|
|
105
|
-
* **`{
|
106
|
-
the output of the previous step was a single output file. It is also used
|
105
|
+
* **`{input_file}`** indicates the output file from the previous. It is also used
|
107
106
|
to indicate the first file to be used and it finds that file in the current
|
108
107
|
working dir.
|
109
|
-
* **`{
|
110
|
-
|
111
|
-
`multi` step.
|
112
|
-
* **`{file}`** indicates an output file name, which is the basename from
|
113
|
-
`{file_path}`. Commands often process multiple files from previous steps,
|
108
|
+
* **`{file_name}`** indicates an output file name, which is the basename from
|
109
|
+
`{input_file}`. Commands often process multiple files from previous steps,
|
114
110
|
generating multiple output files. Those output files are placed in the
|
115
111
|
step directory.
|
116
|
-
* **`{
|
112
|
+
* **`{file_name_without_extension}`** is, well, {file_name} with the
|
113
|
+
extension removed. This is useful when you are transforming a file from
|
114
|
+
one type (with an extension) to another type, with a new extension.
|
115
|
+
* **`{input_dir}`** indicates the directory of the previous step.
|
117
116
|
|
118
117
|
**Example Script**
|
119
118
|
|
data/lib/advance/version.rb
CHANGED
data/lib/advance.rb
CHANGED
@@ -84,15 +84,15 @@ module Advance
|
|
84
84
|
|
85
85
|
def single(command, previous_dir_path, dir_name)
|
86
86
|
work_in_sub_dir(dir_name) do
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
87
|
+
input_file_path = previous_file_path(previous_dir_path)
|
88
|
+
basename = File.basename(input_file_path)
|
89
|
+
root_file_name = basename.gsub(%r(\.[^.]+$), '')
|
90
|
+
|
91
|
+
command.gsub!("{input_dir}", previous_dir_path)
|
92
|
+
command.gsub!("{input_file}", input_file_path)
|
93
|
+
command.gsub!("{file_name}", basename)
|
94
|
+
command.gsub!("{file_name_without_extension}", root_file_name)
|
95
|
+
|
96
96
|
do_command command
|
97
97
|
end
|
98
98
|
end
|
@@ -110,11 +110,14 @@ module Advance
|
|
110
110
|
end
|
111
111
|
TeamEffort.work(file_paths, $cores, progress_proc: progress_proc) do |file_path|
|
112
112
|
begin
|
113
|
-
|
114
|
-
|
115
|
-
|
113
|
+
basename = File.basename(file_path)
|
114
|
+
root_file_name = basename.gsub(%r(\.[^.]+$), '')
|
115
|
+
|
116
|
+
command.gsub!("{input_file}", file_path)
|
117
|
+
command.gsub!("{file_name}", basename)
|
118
|
+
command.gsub!("{file_name_without_extension}", root_file_name)
|
116
119
|
puts "#{YELLOW}#{command}#{RESET}"
|
117
|
-
work_in_sub_dir(
|
120
|
+
work_in_sub_dir(basename) do
|
118
121
|
do_command command, no_feedback
|
119
122
|
end
|
120
123
|
rescue
|