advance 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 842391aeff4f6050e96a64caee6e31d599d9052639936baab5f50acefcac976c
4
- data.tar.gz: 1034ef6eb9ce638ca3ca484064fcfec2e0cfc6cae47383e467fc37526a10badf
3
+ metadata.gz: d7f5948d846efa632c923c68ea86b89b1b785f6ffd58fda4f52fc0cac30579d1
4
+ data.tar.gz: c29928e7ed6662adb03144adf1029b2b5e834cfe3e2f90ee76babc007425646a
5
5
  SHA512:
6
- metadata.gz: 6fb5dbf6d11989a1b7496ede0801fd8c43138194cf425cbbe5b7c05a9443c16f042e327348b19199458a50e4503b0033f55aaac2da79872fd3f7c19fbf057197
7
- data.tar.gz: f19a3493ae52d4971fa907d736bcccaa2fd364e52814d55bfdf99ed0b679cd4438ff142904aef7d815f2201ef6581c9844ac742409b24175c61c67a1fccce48e
6
+ metadata.gz: 35da400978126d81ce5babf678b0ae68eb2c698fae75e39d28da4d4bdabd68dfc3294b3e7f44d045d5b612f614928e5c8027c1506a8bb2bae5eab72b4b9b3d26
7
+ data.tar.gz: 64d1afb3685a4bd9f2a70d7c07cdc1e0ff3f93c553ef3f82d6165ef92e8486622b0577a78f067ece3cdceeb39513ad73c85499396f732f81ddc87f0a433ce257
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- advance (0.2.0)
4
+ advance (0.2.1)
5
5
  team_effort
6
6
 
7
7
  GEM
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
- * **`{previous_file}`** indicates the output file from the previous step when
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
- * **`{file_path}`** indicates an output file from the previous step when the
110
- previous step generated multiple output files and the current step is a
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
- * **`{previous_dir}`** indicates the directory of the previous step.
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
 
@@ -1,3 +1,3 @@
1
1
  module Advance
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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
- if command =~ /\{previous_file\}/
88
- command.gsub!("{previous_file}", previous_file_path(previous_dir_path))
89
- end
90
- if command =~ /\{previous_dir\}/
91
- command.gsub!("{previous_dir}", previous_dir_path)
92
- end
93
- if command =~ /\{file\}/
94
- command.gsub!("{file}", File.basename(previous_file_path(previous_dir_path)))
95
- end
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
- file = File.basename(file_path)
114
- command.gsub!("{file_path}", file_path)
115
- command.gsub!("{file}", file)
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(file) do
120
+ work_in_sub_dir(basename) do
118
121
  do_command command, no_feedback
119
122
  end
120
123
  rescue
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: advance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - janemacfarlane