codeshift 0.1.4 → 0.1.5

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: e9bec08f9af71588e83552ba7820875ff85f89c9582250ac093d2945c765599d
4
- data.tar.gz: 979cd551ab1884d24a7234d3a8a053a631dfee729cea3ccb6f9d994263824752
3
+ metadata.gz: efb8efffb312f3bf4fb538adfe09a2ba6f053ea9266424275377f1d97bbc7777
4
+ data.tar.gz: 60370e7389310a2f2269b72eef85791a3cc98d56cc56d2a7e1a1e72eae89291a
5
5
  SHA512:
6
- metadata.gz: 3a8499b6af79b25c065586ea257740652f766e22b58c0e8962a9f18414e0eee2d554aa6455303043f2bc17ff6e4e95363f62baf056f95c05ed4817e3e8c3bef3
7
- data.tar.gz: d66ba6b9f7aded016d2238f0feb5ce570f3f57ba7d9953763e12520430ac64fcae573cb9fedd17b3823e17587828cd56843313c309cda8ca0c306be4b69dc739
6
+ metadata.gz: 22e5b17c0d43e595fa432d8073d211a796d3b4a9b83167df2f977fd38090483cd4d27b265f69d2dd0304372100bc476859e51727b5af42ff782547b3b25b6994
7
+ data.tar.gz: 00471cc3a8aef2549dddf7c456e0e1f8d47c83b2a475f4f49dac5704010d7aa397ad1a26f24d355393ab20d815bb96d07a802c5e4d7663e25cef6179cf3ec77b
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Codeshift
2
2
 
3
- A Ruby codemod CLI to transform your source code using AST(Abstract Syntax Trees) and the [parser](https://github.com/whitequark/parser) gem. It is typically used on ruby codebase like RAILS applications and other stuff.
3
+ A Ruby codemod CLI to transform your source code using AST(Abstract Syntax Trees) and the [parser](https://github.com/whitequark/parser) gem.
4
+ It is typically used on ruby codebase like RAILS applications and other stuff.
4
5
 
5
6
  ## Installation
6
7
 
@@ -74,7 +75,30 @@ end
74
75
 
75
76
  ```
76
77
 
78
+ ## Options
79
+ Usage: codeshift -t <transform-file> [path]
80
+ * --version Print version number
81
+ * -t, --transform=TRANSFORM path to the transform file. Can be either a local path or url
82
+ (default: ./transform.rb)
83
+ * -h, --help Prints this help
77
84
 
85
+ ### tranfrom-file
86
+ The transform file could be a local file or a remote url. For example you can use like
87
+
88
+ ```sh
89
+ $ codeshift -t https://gist.githubusercontent.com/[user]/.../transform.rb ~/Desktop/test/ruby/**/*.rb
90
+ ```
91
+
92
+ ### path
93
+ The path could be a list of directories or files separated by space.
94
+
95
+ ```sh
96
+ $ codeshift -t transform.rb ~/app/legacy/ruby/**/*.rb ~/app/old/**/*.rb
97
+ ```
98
+
99
+ ```sh
100
+ $ codeshift -t transform.rb ~/code/legacy/app/models/account.rb ~/old/app/models/customer.rb
101
+ ```
78
102
 
79
103
  ## Development
80
104
 
@@ -84,7 +108,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
84
108
 
85
109
  ## Contributing
86
110
 
87
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/codeshift. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
111
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rajasegar/codeshift. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
88
112
 
89
113
  ## License
90
114
 
data/lib/codeshift/cli.rb CHANGED
@@ -30,23 +30,23 @@ module CodeShift
30
30
  @files = ARGV
31
31
  end
32
32
 
33
+ def process_file(file_path)
34
+ puts "Processing: #{file_path}"
35
+ code = File.read(file_path)
36
+ transform = open(@options.transform) { |f| f.read }
37
+ output = Codeshift::CodeshiftTransformer.new(code, transform).transform
38
+ File.write(file_path, output)
39
+ end
40
+
33
41
  def run
34
42
  paths = @files.length > 0 ? @files : []
35
43
  paths.each do |path|
36
44
  if File.directory?(path)
37
45
  Dir.glob(path) do |file_path|
38
- puts "Processing: #{file_path}"
39
- code = File.read(file_path)
40
- transform = open(@options.transform) { |f| f.read }
41
- output = Codeshift::CodeshiftTransformer.new(code, transform).transform
42
- File.write(file_path, output)
46
+ process_file file_path
43
47
  end
44
48
  else
45
- puts "Processing: #{path}"
46
- code = File.read(path)
47
- transform = open(@options.transform) { |f| f.read }
48
- output = Codeshift::CodeshiftTransformer.new(code, transform).transform
49
- File.write(path, output)
49
+ process_file path
50
50
  end
51
51
  end
52
52
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Codeshift
2
4
  class CodeshiftOptions
3
5
  attr_accessor :file_path
@@ -5,9 +7,7 @@ module Codeshift
5
7
 
6
8
  def initialize
7
9
  @file_path = nil
8
- @transform = "./transform.rb"
10
+ @transform = './transform.rb'
9
11
  end
10
-
11
-
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module Codeshift
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeshift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajasegar Chandran
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-30 00:00:00.000000000 Z
11
+ date: 2019-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler