waffle-maker 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71db571599237aa72ae48350e7d1d6436b4d695d915ec0a65c1aa1af0eefe6d9
4
- data.tar.gz: 488435761c228e78e9aa713af706f7c650310c042501a769bb59abb1167cc86c
3
+ metadata.gz: 0ebb5a5ef50022b6f2b5d888212de4d8a21d87259d7bbb0dfa5521f1acee757e
4
+ data.tar.gz: fa130768309be193fc8a2c3c91653a8e97d9985b93bc12b83ed5e81d3efba0ae
5
5
  SHA512:
6
- metadata.gz: ba73930d703b1725ec8fe204b4c8d77b2b8223b38afda57006c2f1290ff62f50c97b740366cf04d4f5294e4107061286b8dc4037aba6b7568d4474895e1f1e0a
7
- data.tar.gz: f3174679237267adc0b8d0344bf45164250be567f5372d232955036f9e1fcf0df35fbe62ac11c1148253caa521fe7d13e28c01eb968791242ffa8b9c61400882
6
+ metadata.gz: 42cb1bbba00d716b11eb216ccc393c589afa318d66aec8eed3aa61aeb6e55885db3d0c3170e0fb27103606d498d20db7cea1dbae16ae0c26df2496b53b9062c9
7
+ data.tar.gz: 35fa40fdcc868c1a87dc5b46423c048b59d39e2681cc0ae174cc678801f6a12d866fd47ab6d22bc8b8bc075a27d65b41e3b5d2d36967e5f4c34bd55e068e9cc3
@@ -24,13 +24,14 @@ module Waffle
24
24
  o.banner = "Usage: #{$0}"
25
25
  o.on("-f number", "Column number that contains the rails path") { |v| options[:f] << v.to_i }
26
26
  o.on("-w number", "Column number that contains the waf path") { |v| options[:w] << v.to_i }
27
+ o.on("--silent-error", "Hide parsing errors, default is false") { |v| options[:silent_error] << v }
27
28
  }.parse!(argv)
28
29
  end
29
30
  end
30
31
 
31
32
  # @override
32
33
  def default_options
33
- {f: 2, w: 2}
34
+ { f: 2, w: 2, silent_error: false }
34
35
  end
35
36
 
36
37
  def execute
@@ -42,7 +43,7 @@ module Waffle
42
43
  private
43
44
 
44
45
  def routes
45
- @routes ||= Waffle::Maker::Route.new(options[:f]).paths
46
+ @routes ||= Waffle::Maker::Route.new(options[:f], options[:silent_error]).paths
46
47
  end
47
48
 
48
49
  def wafs
@@ -3,7 +3,8 @@
3
3
  module Waffle
4
4
  module Maker
5
5
  class Formatter
6
- def initialize
6
+ def initialize(silent_error = false)
7
+ @silent_error = silent_error
7
8
  @buffer = []
8
9
  end
9
10
 
@@ -17,7 +18,11 @@ module Waffle
17
18
 
18
19
  def section(routes)
19
20
  routes.each do |r|
20
- @buffer << [r[:name], r[:verb], r[:path], r[:reqs]].join(",")
21
+ begin
22
+ @buffer << [r[:name], r[:verb], r[:path], r[:reqs]].join(",").tap { |line| CSV.parse(line) }
23
+ rescue CSV::MalformedCSVError => e
24
+ puts "[ERROR] name:#{r[:name]} verb: #{r[:verb]} path:#{r[:path]} reqs:#{r[:reqs]} message:#{e}" unless @silent_error
25
+ end
21
26
  end
22
27
  end
23
28
 
@@ -5,10 +5,11 @@ require 'csv'
5
5
  module Waffle
6
6
  module Maker
7
7
  class Route
8
- attr_accessor :path_position
8
+ attr_accessor :path_position, :silent_error
9
9
 
10
- def initialize(path_position)
10
+ def initialize(path_position, silent_error)
11
11
  self.path_position = path_position
12
+ self.silent_error = silent_error
12
13
  end
13
14
 
14
15
  def all
@@ -28,15 +29,30 @@ module Waffle
28
29
 
29
30
  private
30
31
 
32
+ class Rails
33
+ class << self
34
+ def routes
35
+ ::Rails.application.routes.routes
36
+ end
37
+
38
+ def inspector
39
+ ::ActionDispatch::Routing::RoutesInspector.new(Waffle::Maker::Route::Rails.routes)
40
+ end
41
+
42
+ # @param [Boolean] silent_error
43
+ def formatted_inspector(silent_error)
44
+ Waffle::Maker::Route::Rails.inspector.format(Waffle::Maker::Formatter.new(silent_error))
45
+ end
46
+ end
47
+ end
48
+
31
49
  # [
32
50
  # ["home", "GET", "/home(.:format)", "homes#show"],
33
51
  # ["user", "GET", "/user(.:format)", "users#show"],
34
52
  # ...
35
53
  # ]
36
54
  def rails
37
- routes = ::Rails.application.routes.routes
38
- inspector = ::ActionDispatch::Routing::RoutesInspector.new(routes)
39
- CSV.parse(inspector.format(Waffle::Maker::Formatter.new))
55
+ CSV.parse(Waffle::Maker::Route::Rails.formatted_inspector(silent_error))
40
56
  end
41
57
  end
42
58
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Waffle
4
4
  module Maker
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waffle-maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - chibicco
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-24 00:00:00.000000000 Z
11
+ date: 2020-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,8 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.7.6.2
112
+ rubygems_version: 3.0.3
114
113
  signing_key:
115
114
  specification_version: 4
116
115
  summary: Find waf logs that match rails routing.