ruby-beautify 0.96.0 → 0.97.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ # Test for already indented blocks
2
+ class There2 < There
3
+ def m1()
4
+ puts "m1"
5
+ end
6
+ def m2()
7
+ puts "m2"
8
+ end
9
+ def m3()
10
+ puts "m3"
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe "Usage Scenarios" do
4
+ files = Dir.glob("spec/usage_scenarios/*_pretty.rb")
5
+ scenarios = files.map do |f|
6
+ r = /.*\/(?<scenario>.*)_pretty.rb/.match(f)
7
+ r['scenario'] ||= nil
8
+ end
9
+
10
+ scenarios.each do |scenario|
11
+ it "will test: #{scenario}" do
12
+ scenario_file = "spec/usage_scenarios/#{scenario}.rb"
13
+ scenario_md5_sum = Digest::MD5.hexdigest RubyBeautify.pretty_string File.read scenario_file
14
+
15
+ scenario_pretty_file = "spec/usage_scenarios/#{scenario}_pretty.rb"
16
+ scenario_pretty_md5_sum = Digest::MD5.hexdigest File.read(scenario_pretty_file)
17
+ expect(scenario_md5_sum).to eq scenario_pretty_md5_sum
18
+ end
19
+ end
20
+ end
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.96.0
4
+ version: 0.97.0
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-17 00:00:00.000000000 Z
11
+ date: 2015-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -76,9 +76,27 @@ files:
76
76
  - lib/ruby-beautify/version.rb
77
77
  - ruby-beautify.gemspec
78
78
  - spec/bin/ruby-beautify_spec.rb
79
- - spec/example.rb
80
- - spec/example_beautified.rb
79
+ - spec/binary_scenarios/doubled_example.rb
80
+ - spec/binary_scenarios/overwrite.rb
81
+ - spec/binary_scenarios/overwrite_pretty.rb
82
+ - spec/binary_scenarios/small_example.rb
81
83
  - spec/spec_helper.rb
84
+ - spec/usage_scenarios/README.md
85
+ - spec/usage_scenarios/case.rb
86
+ - spec/usage_scenarios/case_pretty.rb
87
+ - spec/usage_scenarios/from_control.rb
88
+ - spec/usage_scenarios/from_control_pretty.rb
89
+ - spec/usage_scenarios/monolithic_example.rb
90
+ - spec/usage_scenarios/monolithic_example_pretty.rb
91
+ - spec/usage_scenarios/multiline_strings.rb
92
+ - spec/usage_scenarios/multiline_strings_pretty.rb
93
+ - spec/usage_scenarios/mutli_level.rb
94
+ - spec/usage_scenarios/mutli_level_pretty.rb
95
+ - spec/usage_scenarios/or_equals.rb
96
+ - spec/usage_scenarios/or_equals_pretty.rb
97
+ - spec/usage_scenarios/pre_indented.rb
98
+ - spec/usage_scenarios/pre_indented_pretty.rb
99
+ - spec/usage_scenarios_spec.rb
82
100
  homepage: https://github.com/erniebrodeur/ruby-beautify
83
101
  licenses: []
84
102
  metadata: {}
@@ -104,6 +122,24 @@ specification_version: 4
104
122
  summary: a cli tool (and module) to beautify ruby code.
105
123
  test_files:
106
124
  - spec/bin/ruby-beautify_spec.rb
107
- - spec/example.rb
108
- - spec/example_beautified.rb
125
+ - spec/binary_scenarios/doubled_example.rb
126
+ - spec/binary_scenarios/overwrite.rb
127
+ - spec/binary_scenarios/overwrite_pretty.rb
128
+ - spec/binary_scenarios/small_example.rb
109
129
  - spec/spec_helper.rb
130
+ - spec/usage_scenarios/README.md
131
+ - spec/usage_scenarios/case.rb
132
+ - spec/usage_scenarios/case_pretty.rb
133
+ - spec/usage_scenarios/from_control.rb
134
+ - spec/usage_scenarios/from_control_pretty.rb
135
+ - spec/usage_scenarios/monolithic_example.rb
136
+ - spec/usage_scenarios/monolithic_example_pretty.rb
137
+ - spec/usage_scenarios/multiline_strings.rb
138
+ - spec/usage_scenarios/multiline_strings_pretty.rb
139
+ - spec/usage_scenarios/mutli_level.rb
140
+ - spec/usage_scenarios/mutli_level_pretty.rb
141
+ - spec/usage_scenarios/or_equals.rb
142
+ - spec/usage_scenarios/or_equals_pretty.rb
143
+ - spec/usage_scenarios/pre_indented.rb
144
+ - spec/usage_scenarios/pre_indented_pretty.rb
145
+ - spec/usage_scenarios_spec.rb
@@ -1,151 +0,0 @@
1
- require 'ripper'
2
-
3
- module Here
4
- class There
5
- def why?(argument = nil)
6
- @array = [
7
- 1,
8
- 2,
9
- 3
10
- ]
11
- hash = {
12
- one:1,
13
- two:2,
14
- three:3
15
- }
16
- end
17
-
18
- # a comment
19
- def why_not?(argument: {})
20
- @array = [4,5,6]
21
- hash = {four:4, five:5, six:6}
22
- s = "a #{"complex"} string."
23
- end
24
-
25
- def complex_method(one, two, three, four)
26
- regex = /regex/
27
- end
28
-
29
- def with_block
30
- run = Proc.new { |argument| puts arugment }
31
- run do |arugment|
32
- puts argument
33
- end
34
- end
35
- end
36
- end
37
-
38
- h = Here::There.new
39
-
40
- h.why?({
41
- here: 'there',
42
- there: 'here'
43
- })
44
-
45
- h.with_block {
46
- puts 'yahooie'
47
- }
48
-
49
-
50
- h.complex_method('asdkjasflkjdglksjglksfgjlfkgjdf',
51
- 'alfkjsdlkfjsflgkjfglk',
52
- 'alfkjsdlkfjsflgkjfglk',
53
- 'alfkjsdlkfjsflgkjfglk'
54
- )
55
-
56
- h.complex_method('asdkjasflkjdglksjglksfgjlfkgjdf',
57
- 'alfkjsdlkfjsflgkjfglk',
58
- 'alfkjsdlkfjsflgkjfglk',
59
- 'alfkjsdlkfjsflgkjfglk'
60
- ).map do |i|
61
- i
62
- end.map! { |i| i }
63
-
64
- if 1 > 0
65
- puts 'something'
66
- elsif 1 < 0
67
- puts 'never!'
68
- else
69
- puts 'not likely.'
70
- end
71
-
72
- #Test for different if-statement formatting
73
- if 1 > 0 then puts 'something'
74
- else puts 'nothing' end
75
- puts "This line should stay the same"
76
-
77
- # Test for already indented blocks
78
- class There2 < There
79
- def m1()
80
- puts "m1"
81
- end
82
- def m2()
83
- puts "m2"
84
- end
85
- def m3()
86
- puts "m3"
87
- end
88
- end
89
-
90
- # Test for multiline string
91
- def m (x)
92
- puts "This is multi-line string. It's line1 \
93
- It's line 2\
94
- And this is\n line3
95
- This line should not be mutated"
96
- puts "This is multi line interpolated string #{
97
- x
98
- }"
99
- end
100
-
101
- # Test to validate case statements
102
- def case_test opts=nil
103
- case test_case
104
- when 'Passing'
105
- call(:pass)
106
- when 'Failing'
107
- call(:fail)
108
- when 'Error'
109
- call(:error)
110
- end
111
- end
112
-
113
- # Test for variable assignment from an if statement
114
- @products = if params[:category]
115
- Category.find(params[:category]).products
116
- else
117
- Product.all
118
- end
119
-
120
- # Test for variable assignment from a block
121
- response = begin
122
- if true?
123
- api_call(test)
124
- else
125
- rejected
126
- end
127
- rescue
128
- 'FALSE'
129
- end
130
-
131
- # Test or-equals
132
- def expensive_value
133
- @expensive_value ||= begin
134
- if conn.active?
135
- expensive_call
136
- else
137
- :none
138
- end
139
- end
140
- end
141
-
142
- # Test multiple or-equals
143
- def expensive_value
144
- @expensive_value ||= @cached_value ||= begin
145
- if conn.active?
146
- expensive_call
147
- else
148
- :none
149
- end
150
- end
151
- end
@@ -1,151 +0,0 @@
1
- require 'ripper'
2
-
3
- module Here
4
- class There
5
- def why?(argument = nil)
6
- @array = [
7
- 1,
8
- 2,
9
- 3
10
- ]
11
- hash = {
12
- one:1,
13
- two:2,
14
- three:3
15
- }
16
- end
17
-
18
- # a comment
19
- def why_not?(argument: {})
20
- @array = [4,5,6]
21
- hash = {four:4, five:5, six:6}
22
- s = "a #{"complex"} string."
23
- end
24
-
25
- def complex_method(one, two, three, four)
26
- regex = /regex/
27
- end
28
-
29
- def with_block
30
- run = Proc.new { |argument| puts arugment }
31
- run do |arugment|
32
- puts argument
33
- end
34
- end
35
- end
36
- end
37
-
38
- h = Here::There.new
39
-
40
- h.why?({
41
- here: 'there',
42
- there: 'here'
43
- })
44
-
45
- h.with_block {
46
- puts 'yahooie'
47
- }
48
-
49
-
50
- h.complex_method('asdkjasflkjdglksjglksfgjlfkgjdf',
51
- 'alfkjsdlkfjsflgkjfglk',
52
- 'alfkjsdlkfjsflgkjfglk',
53
- 'alfkjsdlkfjsflgkjfglk'
54
- )
55
-
56
- h.complex_method('asdkjasflkjdglksjglksfgjlfkgjdf',
57
- 'alfkjsdlkfjsflgkjfglk',
58
- 'alfkjsdlkfjsflgkjfglk',
59
- 'alfkjsdlkfjsflgkjfglk'
60
- ).map do |i|
61
- i
62
- end.map! { |i| i }
63
-
64
- if 1 > 0
65
- puts 'something'
66
- elsif 1 < 0
67
- puts 'never!'
68
- else
69
- puts 'not likely.'
70
- end
71
-
72
- #Test for different if-statement formatting
73
- if 1 > 0 then puts 'something'
74
- else puts 'nothing' end
75
- puts "This line should stay the same"
76
-
77
- # Test for already indented blocks
78
- class There2 < There
79
- def m1()
80
- puts "m1"
81
- end
82
- def m2()
83
- puts "m2"
84
- end
85
- def m3()
86
- puts "m3"
87
- end
88
- end
89
-
90
- # Test for multiline string
91
- def m (x)
92
- puts "This is multi-line string. It's line1 \
93
- It's line 2\
94
- And this is\n line3
95
- This line should not be mutated"
96
- puts "This is multi line interpolated string #{
97
- x
98
- }"
99
- end
100
-
101
- # Test to validate case statements
102
- def case_test opts=nil
103
- case test_case
104
- when 'Passing'
105
- call(:pass)
106
- when 'Failing'
107
- call(:fail)
108
- when 'Error'
109
- call(:error)
110
- end
111
- end
112
-
113
- # Test for variable assignment from an if statement
114
- @products = if params[:category]
115
- Category.find(params[:category]).products
116
- else
117
- Product.all
118
- end
119
-
120
- # Test for variable assignment from a block
121
- response = begin
122
- if true?
123
- api_call(test)
124
- else
125
- rejected
126
- end
127
- rescue
128
- 'FALSE'
129
- end
130
-
131
- # Test or-equals
132
- def expensive_value
133
- @expensive_value ||= begin
134
- if conn.active?
135
- expensive_call
136
- else
137
- :none
138
- end
139
- end
140
- end
141
-
142
- # Test multiple or-equals
143
- def expensive_value
144
- @expensive_value ||= @cached_value ||= begin
145
- if conn.active?
146
- expensive_call
147
- else
148
- :none
149
- end
150
- end
151
- end