syntax_fix 0.0.1 → 0.0.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.
- data/CHANGELOG.md +5 -0
- data/README.md +4 -0
- data/bin/syntax_fix +14 -0
- data/lib/syntax_fix/checker.rb +7 -2
- data/lib/syntax_fix/version.rb +1 -1
- metadata +5 -5
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -28,6 +28,10 @@ Usage
|
|
28
28
|
|
29
29
|
`syntax_fix` command will check and rewrite all files with the new syntax (including nested files and directories)
|
30
30
|
|
31
|
+
`-h` or `--help` - output all the possible arguments that you can pass from a command line
|
32
|
+
|
33
|
+
`-v` or `--verbose` - be verbose about the actions
|
34
|
+
|
31
35
|
Contributing
|
32
36
|
============
|
33
37
|
|
data/bin/syntax_fix
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'syntax_fix'
|
3
|
+
require 'optparse'
|
3
4
|
|
4
5
|
checker = SyntaxFix::Checker.new
|
6
|
+
optparse = OptionParser.new do |opts|
|
7
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
8
|
+
puts opts
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
opts.on( '-v', '--verbose', 'Be verbose about the actions' ) do
|
12
|
+
checker.verbose = true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
optparse.parse!
|
16
|
+
|
17
|
+
puts 'Reading files...' if checker.verbose
|
5
18
|
checker.fix_code(File.expand_path('.'))
|
19
|
+
puts 'Done!' if checker.verbose
|
data/lib/syntax_fix/checker.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module SyntaxFix
|
2
2
|
class Checker
|
3
|
+
attr_accessor :verbose
|
4
|
+
|
3
5
|
def fix_code(path)
|
4
6
|
Dir.foreach(path) do |name|
|
5
7
|
current_item = SyntaxFix::DirFile.new([path, name].join('/'))
|
@@ -12,11 +14,14 @@ module SyntaxFix
|
|
12
14
|
return if !current_item.correct_file?
|
13
15
|
content = current_item.read_file
|
14
16
|
fixed_content = fix_syntax(content)
|
15
|
-
|
17
|
+
if content != fixed_content
|
18
|
+
current_item.write_file(fixed_content)
|
19
|
+
puts "#{current_item.path} [CHANGED]" if verbose
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
def fix_syntax(source)
|
19
|
-
source.gsub(
|
24
|
+
source.gsub(/([^\:])\:([a-zA-Z_0-9]*)(\s*)=\>(\s*)/){|match| "#{$1}#{$2}:#{$3.empty? || ($3+$4).empty? ? " " : $3}"}
|
20
25
|
end
|
21
26
|
end
|
22
27
|
end
|
data/lib/syntax_fix/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syntax_fix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-02-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70094412006620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70094412006620
|
25
25
|
description: Replace Ruby 1.8 syntax with the Ruby 1.9 syntax all over the project
|
26
26
|
email:
|
27
27
|
- parizhskiy@gmail.com
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
version: '0'
|
72
72
|
requirements: []
|
73
73
|
rubyforge_project: syntax_fix
|
74
|
-
rubygems_version: 1.8.
|
74
|
+
rubygems_version: 1.8.11
|
75
75
|
signing_key:
|
76
76
|
specification_version: 3
|
77
77
|
summary: Replace Ruby 1.8 syntax with the modern one
|