codeshift 0.1.1 → 0.1.2
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/lib/codeshift/cli.rb +30 -2
- data/lib/codeshift/version.rb +1 -1
- 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: 6af6f02701bdb6430dd72cfc5dbd43b0e0e16c7382905d0c951c13366d60acde
|
4
|
+
data.tar.gz: 500607afbfeea607ca65d5c95eb3030c6a37adbf8bb22092a6e06ce6a68b1d63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e0613d86f951f5c664f9fa092b6c1f7c5a49e05fbe5b8c0aa58f1f67a1a10fd6df80359b94db2ecb293c601d467586b8c862d998d3f08749cf33e0bc171d4af
|
7
|
+
data.tar.gz: 43593a3b6f35c47ba04c810ce86124723d18500c0b4b60644996bc6800361415ad7feecf785989e4e395e88a48db62b046fe1fb0d4c8db5d2c59abd6eb9a3bcf
|
data/Gemfile.lock
CHANGED
data/lib/codeshift/cli.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'optparse'
|
2
|
+
require 'codeshift/codeshift_options'
|
3
|
+
require 'codeshift/codeshift_transformer'
|
4
|
+
require 'codeshift/version'
|
2
5
|
|
3
6
|
module CodeShift
|
4
7
|
class CLI
|
5
8
|
def initialize
|
9
|
+
@options = Codeshift::CodeshiftOptions.new
|
6
10
|
OptionParser.new do |opts|
|
7
11
|
opts.banner = "Usage: codeshift -t <transform-file> [path]"
|
8
12
|
|
@@ -10,11 +14,35 @@ module CodeShift
|
|
10
14
|
puts Codeshift::VERSION
|
11
15
|
exit
|
12
16
|
end
|
13
|
-
|
17
|
+
|
18
|
+
opts.on("-tTRANSFORM", "--transform=TRANSFORM", "path to the transform file. Can be either a local path or url\n (default: ./transform.rb)") do |f|
|
19
|
+
|
20
|
+
@options.transform = f
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on("-h", "--help", "Prints this help") do
|
24
|
+
puts opts
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end.parse!
|
28
|
+
|
29
|
+
@files = ARGV
|
14
30
|
end
|
15
31
|
|
16
32
|
def run
|
17
|
-
puts "
|
33
|
+
puts "Codeshift =>"
|
34
|
+
#puts paths
|
35
|
+
#puts @options.transform
|
36
|
+
paths = @files.length > 0 ? @files : []
|
37
|
+
paths.each do |path|
|
38
|
+
Dir.glob(path) do |file_path|
|
39
|
+
puts "Processing: #{file_path}"
|
40
|
+
code = File.read(file_path)
|
41
|
+
transform = File.read(@options.transform)
|
42
|
+
output = Codeshift::CodeshiftTransformer.new(code, transform).transform
|
43
|
+
File.write(file_path, output)
|
44
|
+
end
|
45
|
+
end
|
18
46
|
end
|
19
47
|
end
|
20
48
|
end
|
data/lib/codeshift/version.rb
CHANGED