rubytube 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b12cdf8d2dc05d51f957f67a932c9845cf60dfbecac9b183217a521a57bad129
4
+ data.tar.gz: 6ca47773a0d13cf4ea479e628445835a7fccd7de02ea2e0aa7d7151f2f1806fe
5
+ SHA512:
6
+ metadata.gz: 657e712bcd49674523a2fafa60f1a026b247d18bd8b5ec4390e2e6c95d4145e652016687d2060033e9fa48738c9e4a4a7e8b46abf6117025f6b33ce8a591f89b
7
+ data.tar.gz: 6d5ff0d1faf7a6b6951a814430d3b2029f5a72281853d7ef2aaecd70e24e3cab78c7df330dec48e63d73928c8bb9a1d92f16e2ff2bb07cbf515a67cc19dcafd4
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-09-15
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at stardustkids83@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rubytube.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "standard", "~> 1.3"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 nightswinger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # RubyTube
2
+
3
+ RubyTube is a Ruby implementation of the popular Python library, pytube. This library facilitates the downloading and streaming of YouTube videos, offering the robust functionality of pytube in a Ruby-friendly format.
4
+
5
+ ## Installation
6
+
7
+ $ gem install rubytube
8
+
9
+ ## Quick Start
10
+
11
+ ```ruby
12
+ require 'rubytube'
13
+
14
+ # Initialize with video URL
15
+ video = RubyTube.new('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
16
+
17
+ # Download video
18
+ video.download(filename: 'my_video.mp4')
19
+ ```
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[spec standard]
@@ -0,0 +1,369 @@
1
+ module RubyTube
2
+ class Cipher
3
+ attr_accessor :transform_plan, :transform_map, :js_func_patterns, :throttling_plan, :throttling_array, :calculation_plan, :calculation_n
4
+
5
+ def initialize(js)
6
+ self.transform_plan = get_transform_plan(js)
7
+
8
+ var_regex = %r"^\$*\w+\W"
9
+ var_match = @transform_plan[0].match(var_regex)
10
+
11
+ if var_match.nil?
12
+ raise "RegexMatchError, caller: __init__, pattern: #{var_regex.source}"
13
+ end
14
+
15
+ var = var_match[0][0..-2]
16
+
17
+ self.transform_map = get_transform_map(js, var)
18
+
19
+ self.js_func_patterns = [
20
+ %r"\w+\.(\w+)\(\w,(\d+)\)",
21
+ %r"\w+\[(\"\w+\")\]\(\w,(\d+)\)"
22
+ ]
23
+
24
+ self.throttling_array = get_throttling_function_array(js)
25
+ self.throttling_plan = get_throttling_plan(js)
26
+ end
27
+
28
+ def calculate_n(initial_n)
29
+ throttling_array.map! do |item|
30
+ item == 'b' ? initial_n : item
31
+ end
32
+
33
+ throttling_plan.each do |step|
34
+ curr_func = throttling_array[step[0].to_i]
35
+
36
+ unless curr_func.respond_to?(:call)
37
+ raise ExtractError.new('calculate_n', 'curr_func')
38
+ end
39
+
40
+ first_arg = throttling_array[step[1].to_i]
41
+
42
+ case step.length
43
+ when 2
44
+ curr_func.call(first_arg)
45
+ when 3
46
+ second_arg = throttling_array[step[2].to_i]
47
+ curr_func.call(first_arg, second_arg)
48
+ end
49
+ end
50
+
51
+ initial_n.join
52
+ end
53
+
54
+ def get_signature(ciphered_signature)
55
+ signature = ciphered_signature.split('')
56
+
57
+ transform_plan.each do |js_func|
58
+ name, argument = parse_function(js_func)
59
+ signature = transform_map[name].call(signature, argument)
60
+ end
61
+
62
+ signature.join('')
63
+ end
64
+
65
+ private
66
+
67
+ def parse_function(js_func)
68
+ js_func_patterns.each do |pattern|
69
+ regex = Regexp.new(pattern)
70
+ parse_match = js_func.match(regex)
71
+
72
+ if parse_match
73
+ fn_name = parse_match[1]
74
+ fn_arg = parse_match[2]
75
+
76
+ return [fn_name, fn_arg]
77
+ end
78
+
79
+ raise RegexMatchError.new('parse_function', 'js_func_patterns')
80
+ end
81
+ end
82
+
83
+ def get_initial_function_name(js)
84
+ function_patterns = [
85
+ %r"\b[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*encodeURIComponent\s*\(\s*(?<sig>[a-zA-Z0-9$]+)\(", # noqa: E501
86
+ %r"\b[a-zA-Z0-9]+\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*encodeURIComponent\s*\(\s*(?<sig>[a-zA-Z0-9$]+)\(", # noqa: E501
87
+ %r'(?:\b|[^a-zA-Z0-9$])(?<sig>[a-zA-Z0-9$]{2})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)', # noqa: E501
88
+ %r'(?<sig>[a-zA-Z0-9$]+)\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)', # noqa: E501
89
+ %r'(?<quote>["\'])signature\k<quote>\s*,\s*(?<sig>[a-zA-Z0-9$]+)\(',
90
+ %r"\.sig\|\|(?<sig>[a-zA-Z0-9$]+)\(",
91
+ %r"yt\.akamaized\.net/\)\s*\|\|\s*.*?\s*[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*(?:encodeURIComponent\s*\()?\s*(?<sig>[a-zA-Z0-9$]+)\(", # noqa: E501
92
+ %r"\b[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*(?<sig>[a-zA-Z0-9$]+)\(", # noqa: E501
93
+ %r"\b[a-zA-Z0-9]+\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*(?<sig>[a-zA-Z0-9$]+)\(", # noqa: E501
94
+ %r"\bc\s*&&\s*a\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?<sig>[a-zA-Z0-9$]+)\(", # noqa: E501
95
+ %r"\bc\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?<sig>[a-zA-Z0-9$]+)\(", # noqa: E501
96
+ %r"\bc\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?<sig>[a-zA-Z0-9$]+)\(", # noqa: E501
97
+ ]
98
+
99
+ function_patterns.each do |pattern|
100
+ regex = Regexp.new(pattern)
101
+ function_match = js.match(regex)
102
+ if function_match
103
+ return function_match[:sig]
104
+ end
105
+ end
106
+
107
+ raise RegexMatchError.new('get_initial_function_name', 'multiple')
108
+ end
109
+
110
+ def get_transform_plan(js)
111
+ name = Regexp.escape(get_initial_function_name(js))
112
+ pattern = "#{name}=function\\(\\w\\)\\{[a-z=\\.\(\"\\)]*;(.*);(?:.+)\\}"
113
+
114
+ Utils.regex_search(pattern, js, 1).split(';')
115
+ end
116
+
117
+ def get_transform_object(js, var)
118
+ escaped_var = Regexp.escape(var)
119
+ pattern = "var #{escaped_var}={(.*?)};"
120
+ regex = Regexp.new(pattern, Regexp::MULTILINE)
121
+ transform_match = regex.match(js)
122
+
123
+ if transform_match.nil?
124
+ raise RegexMatchError.new('get_transform_object', pattern)
125
+ end
126
+
127
+ transform_match[1].gsub("\n", " ").split(", ")
128
+ end
129
+
130
+ def get_transform_map(js, var)
131
+ transform_obejct = get_transform_object(js, var)
132
+ mapper = {}
133
+
134
+ transform_obejct.each do |obj|
135
+ name, function = obj.split(':')
136
+ fn = map_functions(function)
137
+ mapper[name] = fn
138
+ end
139
+
140
+ mapper
141
+ end
142
+
143
+ def reverse(arr)
144
+ # Ruby equivalent of JavaScript's Array.reverse()
145
+ arr.reverse!
146
+ end
147
+
148
+ def splice(arr, index)
149
+ # Ruby equivalent of JavaScript's Array.splice(0, index)
150
+ arr.shift(index.to_i)
151
+ end
152
+
153
+ def swap(arr, index)
154
+ # Ruby equivalent of the JavaScript swapping function
155
+ temp = arr[0]
156
+ arr[0] = arr[index.to_i % arr.length]
157
+ arr[index.to_i % arr.length] = temp
158
+ end
159
+
160
+ def push(arr, val)
161
+ arr.push(val)
162
+ end
163
+
164
+ def throttling_mod_func(d, e)
165
+ (e % d.length + d.length) % d.length
166
+ end
167
+
168
+ def throttling_unshift(d, e)
169
+ e = throttling_mod_func(d, e)
170
+ new_arr = d[-e..-1] + d[0...-e]
171
+ d.clear
172
+ new_arr.each { |el| d << el }
173
+ end
174
+
175
+ def throttling_cipher_function(d, e)
176
+ h = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'.split('')
177
+ f = 96
178
+ self_arr = e.split('')
179
+
180
+ copied_array = d.clone
181
+
182
+ copied_array.each_with_index do |l, m|
183
+ bracket_val = (h.index(l) - h.index(self_arr[m]) + m - 32 + f) % h.length
184
+ self_arr << h[bracket_val]
185
+ d[m] = h[bracket_val]
186
+ f -= 1
187
+ end
188
+ end
189
+
190
+ def throttling_nested_splice(d, e)
191
+ e = throttling_mod_func(d, e)
192
+ inner_splice = js_splice(d, e, 1, d[0])
193
+ js_splice(d, 0, 1, inner_splice[0])
194
+ end
195
+
196
+ def throttling_prepend(d, e)
197
+ start_len = d.length
198
+
199
+ e = throttling_mod_func(d, e)
200
+
201
+ new_arr = d[-e..-1] + d[0...-e]
202
+
203
+ d.clear.concat(new_arr)
204
+
205
+ end_len = d.length
206
+ raise 'Length mismatch' unless start_len == end_len
207
+ end
208
+
209
+ def js_splice(arr, start, delete_count=nil, *items)
210
+ if start.is_a? Integer
211
+ start = arr.length if start > arr.length
212
+ start += arr.length if start < 0
213
+ else
214
+ start = 0
215
+ end
216
+
217
+ delete_count = arr.length - start if delete_count.nil? || delete_count >= arr.length - start
218
+ deleted_elements = arr[start, delete_count]
219
+
220
+ new_arr = arr[0...start] + items + arr[(start + delete_count)..-1]
221
+
222
+ arr.clear.concat(new_arr)
223
+
224
+ deleted_elements
225
+ end
226
+
227
+ def map_functions(function)
228
+ mapper = [
229
+ # function(a){a.reverse()}
230
+ [%r"{\w\.reverse\(\)}", method(:reverse)],
231
+ # function(a,b){a.splice(0,b)}
232
+ [%r"{\w\.splice\(0,\w\)}", method(:splice)],
233
+ # function(a,b){var c=a[0];a[0]=a[b%a.length];a[b]=c}
234
+ [%r"{var\s\w=\w\[0\];\w\[0\]=\w\[\w\%\w.length\];\w\[\w\]=\w}", method(:swap)],
235
+ # function(a,b){var c=a[0];a[0]=a[b%a.length];a[b%a.length]=c}
236
+ [%r"{var\s\w=\w\[0\];\w\[0\]=\w\[\w\%\w.length\];\w\[\w\%\w.length\]=\w}", method(:swap)]
237
+ ]
238
+
239
+ mapper.each do |pattern, fn|
240
+ return fn if Regexp.new(pattern).match?(function)
241
+ end
242
+
243
+ raise RegexMatchError.new('map_functions', 'multiple')
244
+ end
245
+
246
+ def get_throttling_function_name(js)
247
+ function_patterns = [
248
+ %r'a\.[a-zA-Z]\s*&&\s*\([a-z]\s*=\s*a\.get\("n"\)\)\s*&&.*?\|\|\s*([a-z]+)',
249
+ %r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
250
+ ]
251
+
252
+ function_patterns.each do |pattern|
253
+ regex = Regexp.new(pattern)
254
+ function_match = js.match(regex)
255
+ next unless function_match
256
+
257
+ if function_match.captures.length == 1
258
+ return function_match[1]
259
+ end
260
+
261
+ idx = function_match[2]
262
+ if idx
263
+ idx = idx.tr('[]', '')
264
+ array_match = js.match(/var #{Regexp.escape(function_match[1])}\s*=\s*(\[.+?\])/)
265
+ if array_match
266
+ array = array_match[1].tr('[]', '').split(',')
267
+ array = array.map(&:strip)
268
+ return array[idx.to_i]
269
+ end
270
+ end
271
+ end
272
+
273
+ raise RegexMatchError.new('get_throttling_function_name', 'multiple')
274
+ end
275
+
276
+ def get_throttling_function_code(js)
277
+ name = Regexp.escape(get_throttling_function_name(js))
278
+
279
+ pattern_start = %r"#{name}=function\(\w\)"
280
+ regex = Regexp.new(pattern_start)
281
+ match = js.match(regex)
282
+
283
+ code_lines_list = Parser.find_object_from_startpoint(js, match.end(0)).split("\n")
284
+ joined_lines = code_lines_list.join("")
285
+
286
+ "#{match[0]}#{joined_lines}"
287
+ end
288
+
289
+ def get_throttling_function_array(js)
290
+ raw_code = get_throttling_function_code(js)
291
+
292
+ array_regex = /,c=\[/
293
+ match = raw_code.match(array_regex)
294
+ array_raw = Parser.find_object_from_startpoint(raw_code, match.end(0) - 1)
295
+ str_array = Parser.throttling_array_split(array_raw)
296
+
297
+ converted_array = []
298
+ str_array.each do |el|
299
+ begin
300
+ converted_array << Integer(el)
301
+ next
302
+ rescue ArgumentError
303
+ # Not an integer value.
304
+ end
305
+
306
+ if el == 'null'
307
+ converted_array << nil
308
+ next
309
+ end
310
+
311
+ if el.start_with?('"') && el.end_with?('"')
312
+ converted_array << el[1..-2]
313
+ next
314
+ end
315
+
316
+ if el.start_with?('function')
317
+ mapper = [
318
+ [%r"{for\(\w=\(\w%\w\.length\+\w\.length\)%\w\.length;\w--;\)\w\.unshift\(\w.pop\(\)\)}", method(:throttling_unshift)],
319
+ [%r"{\w\.reverse\(\)}", method(:reverse)],
320
+ [%r"{\w\.push\(\w\)}", method(:push)],
321
+ [%r";var\s\w=\w\[0\];\w\[0\]=\w\[\w\];\w\[\w\]=\w}", method(:swap)],
322
+ [%r"case\s\d+", method(:throttling_cipher_function)],
323
+ [%r"\w\.splice\(0,1,\w\.splice\(\w,1,\w\[0\]\)\[0\]\)", method(:throttling_nested_splice)],
324
+ [%r";\w\.splice\(\w,1\)}", method(:js_splice)],
325
+ [%r"\w\.splice\(-\w\)\.reverse\(\)\.forEach\(function\(\w\){\w\.unshift\(\w\)}\)", method(:throttling_prepend)],
326
+ [%r"for\(var \w=\w\.length;\w;\)\w\.push\(\w\.splice\(--\w,1\)\[0\]\)}", method(:reverse)],
327
+ ]
328
+
329
+ found = false
330
+ mapper.each do |pattern, fn|
331
+ if el.match?(pattern)
332
+ converted_array << fn
333
+ found = true
334
+ end
335
+ end
336
+ next if found
337
+ end
338
+
339
+ converted_array << el
340
+ end
341
+
342
+ converted_array.map! { |el| el.nil? ? converted_array : el }
343
+ converted_array
344
+ end
345
+
346
+ def get_throttling_plan(js)
347
+ raw_code = get_throttling_function_code(js)
348
+
349
+ transform_start = "try{"
350
+ plan_regex = Regexp.new(transform_start)
351
+ match = raw_code.match(plan_regex)
352
+
353
+ transform_plan_raw = Parser.find_object_from_startpoint(raw_code, match.end(0) - 1)
354
+ step_regex = %r"c\[(\d+)\]\(c\[(\d+)\](,c(\[(\d+)\]))?\)"
355
+ matches = transform_plan_raw.scan(step_regex)
356
+ transform_steps = []
357
+
358
+ matches.each do |match|
359
+ if match[3]
360
+ transform_steps.push([match[0], match[1], match[3]])
361
+ else
362
+ transform_steps.push([match[0], match[1]])
363
+ end
364
+ end
365
+
366
+ transform_steps
367
+ end
368
+ end
369
+ end