ruby-beautify 0.97.0 → 0.97.1
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/README.md +15 -6
- data/WHATSNEW.md +4 -0
- data/bin/rbeautify +4 -4
- data/bin/ruby-beautify +4 -4
- data/lib/ruby-beautify.rb +18 -0
- data/lib/ruby-beautify/version.rb +1 -1
- data/spec/bin/ruby-beautify_spec.rb +26 -2
- data/spec/binary_scenarios/count_after.rb +3 -0
- data/spec/binary_scenarios/count_before.rb +3 -0
- data/spec/binary_scenarios/spaces_after.rb +3 -0
- data/spec/binary_scenarios/spaces_before.rb +3 -0
- data/spec/ruby-beautify.dotfile +1 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 845edab077c5c5bf51a6e33fa1cce9d9337c70b4
|
4
|
+
data.tar.gz: 334487716f67201c629c3ce0ee46dafd21a8943b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cd313b20304d0b0247015da7cfb8842a2a2bacf34ace4c2cca3256eb406b0022bb6be65c3cf95b4675989616a3e4b7e14ae8d790aed837c354959c91cf3c2c1
|
7
|
+
data.tar.gz: 4bf21cb165f737d4d97c4778bac5fb942b9cd4f519e34f691932b58b05f00aa941fd80b61ab1ec05c935026e0f79f5bff754a21462972b6601f1ebd02c4a039a
|
data/README.md
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
# Ruby Beautify
|
2
|
-
**Master** [](https://codeclimate.com/github/erniebrodeur/ruby-beautify) [](https://travis-ci.org/erniebrodeur/ruby-beautify) [](https://gemnasium.com/erniebrodeur/ruby-beautify)
|
3
|
-
|
4
|
-
**Development** [](https://travis-ci.org/erniebrodeur/ruby-beautify)
|
5
|
-
|
6
|
-
[](https://gitter.im/erniebrodeur/ruby-beautify?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
1
|
+
# Ruby Beautify [](https://travis-ci.org/erniebrodeur/ruby-beautify) [](https://gitter.im/erniebrodeur/ruby-beautify?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
7
2
|
|
8
3
|
This gem provides a cli binary named 'ruby-beautify' that will pretty up ruby code.
|
9
4
|
|
@@ -51,6 +46,19 @@ You can over write files in place, this is useful for doing an entire directory
|
|
51
46
|
|
52
47
|
`ruby-beautify --overwrite **/*.rb`
|
53
48
|
|
49
|
+
## Configuration file
|
50
|
+
|
51
|
+
It can use a configuration file like some of the other ruby projects out there. The config file consists of each argument on a new line. Something like this:
|
52
|
+
|
53
|
+
```
|
54
|
+
--spaces
|
55
|
+
--ident_count=2
|
56
|
+
```
|
57
|
+
|
58
|
+
Note, you'll have to add the equal sign between value and argument (tricky bit, that).
|
59
|
+
|
60
|
+
Placing this into a `.ruby-beautify` anywhere in your tree (like git) will work. This allows you to put it at the root of a project and have it change the defaults anywhere in the project.
|
61
|
+
|
54
62
|
## Bugs
|
55
63
|
|
56
64
|
Please feel free to open issues, I am actively working on this project again, thanks entirely to the ripper gem.
|
@@ -60,6 +68,7 @@ The gaps are getting smaller. I think we have most of the basic ruby use cases
|
|
60
68
|
## Todo
|
61
69
|
|
62
70
|
* Add vim style comment hinting.
|
71
|
+
* add specs/pipe testing (epic).
|
63
72
|
* remove the link to rbeautify (by 1.0).
|
64
73
|
|
65
74
|
Longer term I'd like to do some more to assignment, line wrapping, and spacing in/around keywords.
|
data/WHATSNEW.md
CHANGED
data/bin/rbeautify
CHANGED
@@ -3,6 +3,7 @@ require 'optparse'
|
|
3
3
|
require 'ruby-beautify'
|
4
4
|
|
5
5
|
include RubyBeautify
|
6
|
+
my_argv = config_argv
|
6
7
|
|
7
8
|
Options = OptionParser.new do |opts|
|
8
9
|
opts.on("-V", "--version", "Print version") { |version| puts RBeautify::VERSION;exit 0}
|
@@ -12,7 +13,7 @@ Options = OptionParser.new do |opts|
|
|
12
13
|
opts.on("--overwrite", "Overwrite files as you go (won't touch files that faile a syntax check).") { @overwrite = true }
|
13
14
|
opts.banner = "Usage: print ruby into a pretty format, or break trying."
|
14
15
|
end
|
15
|
-
Options.parse!
|
16
|
+
Options.parse!(my_argv)
|
16
17
|
|
17
18
|
@indent_token = "\t" unless @indent_token
|
18
19
|
@indent_count = 1 unless @indent_count
|
@@ -28,12 +29,11 @@ def print_or_die(content)
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
if ARGV.empty?
|
32
|
+
if my_argv.empty?
|
33
33
|
content = $stdin.read
|
34
34
|
print_or_die content
|
35
35
|
else
|
36
|
-
|
36
|
+
my_argv.each do |file|
|
37
37
|
if File.exist? file
|
38
38
|
fh = open(file)
|
39
39
|
content = fh.read
|
data/bin/ruby-beautify
CHANGED
@@ -3,6 +3,7 @@ require 'optparse'
|
|
3
3
|
require 'ruby-beautify'
|
4
4
|
|
5
5
|
include RubyBeautify
|
6
|
+
my_argv = config_argv
|
6
7
|
|
7
8
|
Options = OptionParser.new do |opts|
|
8
9
|
opts.on("-V", "--version", "Print version") { |version| puts RBeautify::VERSION;exit 0}
|
@@ -12,7 +13,7 @@ Options = OptionParser.new do |opts|
|
|
12
13
|
opts.on("--overwrite", "Overwrite files as you go (won't touch files that faile a syntax check).") { @overwrite = true }
|
13
14
|
opts.banner = "Usage: print ruby into a pretty format, or break trying."
|
14
15
|
end
|
15
|
-
Options.parse!
|
16
|
+
Options.parse!(my_argv)
|
16
17
|
|
17
18
|
@indent_token = "\t" unless @indent_token
|
18
19
|
@indent_count = 1 unless @indent_count
|
@@ -28,12 +29,11 @@ def print_or_die(content)
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
if ARGV.empty?
|
32
|
+
if my_argv.empty?
|
33
33
|
content = $stdin.read
|
34
34
|
print_or_die content
|
35
35
|
else
|
36
|
-
|
36
|
+
my_argv.each do |file|
|
37
37
|
if File.exist? file
|
38
38
|
fh = open(file)
|
39
39
|
content = fh.read
|
data/lib/ruby-beautify.rb
CHANGED
@@ -156,4 +156,22 @@ module RubyBeautify
|
|
156
156
|
output_string += "#{indent}#{string.lstrip}"
|
157
157
|
end
|
158
158
|
end
|
159
|
+
|
160
|
+
# try to find a config and return a modified argv, walks all the way to root
|
161
|
+
# looking for '.ruby-beautify' and then returns an argv with our new options.
|
162
|
+
def config_argv
|
163
|
+
target_dirs = Dir.pwd.split("/")
|
164
|
+
|
165
|
+
# sloppy walk method, not well tested but shouldn't get in the way.
|
166
|
+
while (target_dirs.any?)
|
167
|
+
target = "#{target_dirs.join("/")}/.ruby-beautify"
|
168
|
+
break if File.exist?(target)
|
169
|
+
target_dirs.pop
|
170
|
+
target = nil
|
171
|
+
end
|
172
|
+
|
173
|
+
return ARGV unless target
|
174
|
+
lines = open(target).readlines
|
175
|
+
return ARGV + lines.map {|l| l.chomp}
|
176
|
+
end
|
159
177
|
end
|
@@ -11,6 +11,13 @@ describe "Ruby Beautify" do
|
|
11
11
|
@overwrite_file = "spec/binary_scenarios/overwrite.rb"
|
12
12
|
@overwrite_target_file = "tmp/copied.rb"
|
13
13
|
@overwrite_pretty_file = "spec/binary_scenarios/overwrite_pretty.rb"
|
14
|
+
# Our space test.
|
15
|
+
@space_before = 'spec/binary_scenarios/spaces_before.rb'
|
16
|
+
@space_after = 'spec/binary_scenarios/spaces_after.rb'
|
17
|
+
@space_after_sum = Digest::MD5.hexdigest File.read @space_after
|
18
|
+
# our count test.
|
19
|
+
@count_before = 'spec/binary_scenarios/count_before.rb'
|
20
|
+
@count_after = 'spec/binary_scenarios/count_after.rb'
|
14
21
|
end
|
15
22
|
|
16
23
|
it "will work" do
|
@@ -36,6 +43,23 @@ describe "Ruby Beautify" do
|
|
36
43
|
FileUtils.rm @overwrite_target_file
|
37
44
|
end
|
38
45
|
|
39
|
-
it "will honor --
|
40
|
-
|
46
|
+
it "will honor --spaces" do
|
47
|
+
beautified_sum = Digest::MD5.hexdigest `bundle exec #{BEAUTIFY_BIN} --spaces #{@space_before}`
|
48
|
+
expect(beautified_sum).to eq(@space_after_sum)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "will honor the ident_count prefix" do
|
52
|
+
beautified_sum = Digest::MD5.hexdigest `bundle exec #{BEAUTIFY_BIN} --indent_count=3 #{@count_before}`
|
53
|
+
count_after_sum = Digest::MD5.hexdigest File.read @count_after
|
54
|
+
expect(beautified_sum).to eq(count_after_sum)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "will use a .ruby-beautify config file" do
|
58
|
+
FileUtils.cp "spec/ruby-beautify.dotfile", "tmp/.ruby-beautify"
|
59
|
+
Dir.chdir "tmp"
|
60
|
+
beautified_sum = Digest::MD5.hexdigest `bundle exec #{BEAUTIFY_BIN} ../#{@space_before}`
|
61
|
+
Dir.chdir ".."
|
62
|
+
FileUtils.rm "tmp/.ruby-beautify"
|
63
|
+
expect(beautified_sum).to eq(@space_after_sum)
|
64
|
+
end
|
41
65
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
--spaces
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-beautify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.97.
|
4
|
+
version: 0.97.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernie Brodeur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -76,10 +76,15 @@ files:
|
|
76
76
|
- lib/ruby-beautify/version.rb
|
77
77
|
- ruby-beautify.gemspec
|
78
78
|
- spec/bin/ruby-beautify_spec.rb
|
79
|
+
- spec/binary_scenarios/count_after.rb
|
80
|
+
- spec/binary_scenarios/count_before.rb
|
79
81
|
- spec/binary_scenarios/doubled_example.rb
|
80
82
|
- spec/binary_scenarios/overwrite.rb
|
81
83
|
- spec/binary_scenarios/overwrite_pretty.rb
|
82
84
|
- spec/binary_scenarios/small_example.rb
|
85
|
+
- spec/binary_scenarios/spaces_after.rb
|
86
|
+
- spec/binary_scenarios/spaces_before.rb
|
87
|
+
- spec/ruby-beautify.dotfile
|
83
88
|
- spec/spec_helper.rb
|
84
89
|
- spec/usage_scenarios/README.md
|
85
90
|
- spec/usage_scenarios/case.rb
|
@@ -122,10 +127,15 @@ specification_version: 4
|
|
122
127
|
summary: a cli tool (and module) to beautify ruby code.
|
123
128
|
test_files:
|
124
129
|
- spec/bin/ruby-beautify_spec.rb
|
130
|
+
- spec/binary_scenarios/count_after.rb
|
131
|
+
- spec/binary_scenarios/count_before.rb
|
125
132
|
- spec/binary_scenarios/doubled_example.rb
|
126
133
|
- spec/binary_scenarios/overwrite.rb
|
127
134
|
- spec/binary_scenarios/overwrite_pretty.rb
|
128
135
|
- spec/binary_scenarios/small_example.rb
|
136
|
+
- spec/binary_scenarios/spaces_after.rb
|
137
|
+
- spec/binary_scenarios/spaces_before.rb
|
138
|
+
- spec/ruby-beautify.dotfile
|
129
139
|
- spec/spec_helper.rb
|
130
140
|
- spec/usage_scenarios/README.md
|
131
141
|
- spec/usage_scenarios/case.rb
|