code_web 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: 29bda801a6f5634ec882c6633c08647ce1833308
4
- data.tar.gz: d6b58d6ee533c2dd7ff66a4c86f39d1ad5d77cf0
3
+ metadata.gz: 9b78e826e03736b6ad03ecca86454dd8a21e77d3
4
+ data.tar.gz: 17716b11fbfca39fa06742ed670c806e3e37fba4
5
5
  SHA512:
6
- metadata.gz: 2219f31b3e506ed95f633bc9bbb68b1984533ea6e7e391095da3634fc203b8e2d1a5755035c8df2dd02289e7d060a19db7b66d84db72328012cdec0b57f057d4
7
- data.tar.gz: ae10f2d3cce4ead971d55654b2ab3d61a142f7cb024d85ec0789708c4321bbb05ec7eb3301002cfa5646f37ee5f0a362e513cc67cda5fe023e667e0db84d93b2
6
+ metadata.gz: d198666367ffbafea550fecc6cd5eac0190bb6b2511293aefd9f3353aebabbb3053f8c35db2a4e049351e9f5a2a0a530a76aea4a797d2aca75334aaf69c56bf2
7
+ data.tar.gz: 88ab6844ea0c04842467c103c187d0b9ac45df5590c01969c8887a3e854ffd28880c9c63748479bd729524343ab3c40844b812800d0c786ce44a448d472d8a0a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,3 @@
1
- # Change Log
2
-
3
1
  # Change Log
4
2
  All notable changes to this project will be documented in this file.
5
3
 
@@ -8,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
8
6
 
9
7
  ## [Unreleased]
10
8
 
9
+ ## [0.0.6] - 2017-06-13
10
+ - filenames in output, but only show first one
11
+ - added flag `--url` to link to github instead of local filesystem
12
+ - removed empty spans in output when blank or all of text fits in screen
13
+ - removed first blank line in report output
14
+
11
15
  ## [0.0.5] - 2017-05-16
12
16
  - added a changelog (sorry olivier)
13
17
  - fixed gem metadata
@@ -19,5 +23,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
19
23
  - added flags for byebug and pry to allow debugging of issues (sorry not more stable)
20
24
 
21
25
 
22
- [Unreleased]: https://github.com/kbrock/code_web/compare/v0.0.5...HEAD
26
+ [Unreleased]: https://github.com/kbrock/code_web/compare/v0.0.6...HEAD
27
+ [0.0.6]: https://github.com/kbrock/code_web/compare/v0.0.5...v0.0.6
23
28
  [0.0.5]: https://github.com/kbrock/code_web/compare/v0.0.4...v0.0.5
data/lib/code_web/cli.rb CHANGED
@@ -16,6 +16,10 @@ module CodeWeb
16
16
  def verbose=(val) ; code_parser.verbose = val ; end
17
17
  def debug=(val) ; code_parser.debug = val ; end
18
18
  def debug? ; code_parser.debug? ; end
19
+ # @attribute base_url [rw]
20
+ # @return url for files (i.e.: https://github.com/ManageIQ/manageiq/blob/master)
21
+ # defaults to local filesystem
22
+ attr_accessor :base_url
19
23
 
20
24
  # @attribute report_generator [rw]
21
25
  # @return class that runs the report (i.e.: TextReport, HtmlReport)
@@ -57,6 +61,7 @@ module CodeWeb
57
61
  opt.banner = "Usage: code_web regex [file_name ...]"
58
62
  # opt.on('-n', '--requests=count', Integer, "Number of requests (default: #{requests})") { |v| options[:requests] = v }
59
63
  opt.on('-t', '--text', 'Use text reports') { |v| self.report_generator = ::CodeWeb::TextReport }
64
+ opt.on('u', '--url URL', 'Base url (e.g.: https://github.com/miq/miq/blob/master)') { |v| self.base_url = v }
60
65
  opt.on('-a', '--arg ARG_REGEX', 'Only files with hash argument') { |v| self.arg_regex = Regexp.new(v) }
61
66
  opt.on('-o', '--output FILENAME', 'Output filename') { |v| self.output = (v == '-') ? STDOUT : File.new(v,'w') }
62
67
  opt.on('-e', '--error-out', 'exit on unknown tags') { |v| self.exit_on_error = true}
@@ -95,7 +100,7 @@ module CodeWeb
95
100
 
96
101
  def display_results
97
102
  STDOUT.puts "parsed #{files_parsed} files"
98
- report_generator.new(method_calls, class_map, arg_regex, output).report
103
+ report_generator.new(method_calls, class_map, arg_regex, base_url, output).report
99
104
  end
100
105
  end
101
106
  end
@@ -8,6 +8,7 @@ module CodeWeb
8
8
  # @return [Array<MethodCall>]
9
9
  attr_accessor :method_calls
10
10
  attr_accessor :arg_regex
11
+ attr_accessor :base_url
11
12
  def arg_regex? ; ! arg_regex.nil? ; end
12
13
 
13
14
  # @!attribute :class_map [rw]
@@ -17,15 +18,15 @@ module CodeWeb
17
18
  # @return [Map<Regexp,color>] regex expressing name of main file
18
19
  attr_accessor :class_map
19
20
 
20
- def initialize(method_calls, class_map={}, arg_regex=nil, out=STDOUT)
21
+ def initialize(method_calls, class_map={}, arg_regex=nil, base_url=nil, out=STDOUT)
21
22
  @method_calls = method_calls
22
23
  @class_map = class_map
23
24
  @arg_regex = arg_regex
25
+ @base_url = base_url
24
26
  @out = out
25
27
  end
26
28
 
27
- TEMPLATE=%{
28
- <html>
29
+ TEMPLATE=%{<html>
29
30
  <head><style>
30
31
  table {border-collapse:collapse;}
31
32
  table, td, th { border:1px solid black; }
@@ -55,14 +56,18 @@ table, td, th { border:1px solid black; }
55
56
  <%- methods_with_type.group_by(:signature, arg_regex).each do |methods_by_signature| -%>
56
57
  <tr>
57
58
  <%- methods_with_type.arg_keys.each do |arg| -%>
58
- <td><%= simplified_argument(methods_by_signature.hash_arg[arg]) %></td>
59
+ <td><%= simplified_argument(methods_by_signature.hash_arg[arg]) if methods_by_signature.hash_arg.key?(arg) %></td>
59
60
  <%- end -%>
60
61
  <%- if display_yield_column -%>
61
62
  <td><%= methods_by_signature.f.yields? %></td>
62
63
  <%- end -%>
63
- <td><%- methods_by_signature.each_with_index do |method, i| -%>
64
- <%= method_link(method, i+1) %>
65
- <%- end -%></td>
64
+ <td>
65
+ <%- methods_by_signature.group_by(:filename).each do |methods_by_filename| -%>
66
+ <%- methods_by_filename.each_with_index do |method, i| -%>
67
+ <%= method_link(method, i == 0 ? nil : i+1) %>
68
+ <%- end -%>
69
+ <%- end -%>
70
+ </td>
66
71
  </tr>
67
72
  <%- end -%>
68
73
  </tbody>
@@ -81,9 +86,13 @@ table, td, th { border:1px solid black; }
81
86
  <%- if display_yield_column -%>
82
87
  <td><%= methods_by_signature.f.yields? ? 'yields' : 'no yield'%></td>
83
88
  <%- end -%>
84
- <td><%- methods_by_signature.each_with_index do |method, i| -%>
85
- <%= method_link(method, i+1) %>
86
- <%- end -%></td>
89
+ <td>
90
+ <%- methods_by_signature.group_by(:filename).each do |methods_by_filename| -%>
91
+ <%- methods_by_filename.each_with_index do |method, i| -%>
92
+ <%= method_link(method, i == 0 ? nil : i+1) %>
93
+ <%- end -%>
94
+ <%- end -%>
95
+ </td>
87
96
  </tr>
88
97
  <%- end -%>
89
98
  <%- end -%>
@@ -119,13 +128,17 @@ table, td, th { border:1px solid black; }
119
128
  def simplified_argument(arg)
120
129
  short_arg = case arg
121
130
  when nil
122
- nil
131
+ "nil"
123
132
  when String
124
133
  arg.split("::").last[0..12]
125
134
  else
126
135
  arg.to_s[0..12]
127
136
  end
128
- %{<span title="#{html_safe(arg)}">#{short_arg}</span>}
137
+ if short_arg == arg || short_arg == "nil"
138
+ short_arg
139
+ else
140
+ %{<span title="#{html_safe(arg)}">#{short_arg}</span>}
141
+ end
129
142
  end
130
143
 
131
144
  def html_safe(str)
@@ -142,7 +155,7 @@ table, td, th { border:1px solid black; }
142
155
  # add a class if the method is in a particular file
143
156
 
144
157
  def method_link(m, count=nil)
145
- name = count ? "[#{count}]" : m.signature
158
+ name = count ? "[#{count}]" : m.short_filename
146
159
  class_name = nil
147
160
  class_map.each_with_index do |(pattern, color), i|
148
161
  if m.filename =~ pattern
@@ -150,8 +163,17 @@ table, td, th { border:1px solid black; }
150
163
  break
151
164
  end
152
165
  end
153
- #NOTE: may want to CGI::escape(m.filename)
154
- %{<a href="subl://open?url=file://#{m.filename}&amp;line=#{m.line}" title="#{html_safe(m.signature)}"#{" class=\"#{class_name}\"" if class_name}>#{name}</a>}
166
+ url = if base_url
167
+ "#{m.filename.gsub(pwd, base_url)}#L#{m.line}"
168
+ else
169
+ #NOTE: may want to CGI::escape(m.filename)
170
+ "subl://open?url=file://#{m.filename}&amp;line=#{m.line}"
171
+ end
172
+ %{<a href="#{url}" title="#{html_safe(m.signature)}"#{" class=\"#{class_name}\"" if class_name}>#{name}</a>}
173
+ end
174
+
175
+ def pwd
176
+ @pwd ||= `pwd`.chomp
155
177
  end
156
178
  end
157
179
  end
@@ -5,11 +5,13 @@ module CodeWeb
5
5
  # @return [Array<MethodCall>]
6
6
  attr_accessor :method_calls
7
7
  attr_accessor :arg_regex
8
+ attr_accessor :base_url
8
9
  def arg_regex? ; ! arg_regex.nil? ; end
9
10
 
10
- def initialize(method_calls, class_map=nil, arg_regex=nil, out=STDOUT)
11
+ def initialize(method_calls, class_map=nil, arg_regex=nil, base_url=nil, out=STDOUT)
11
12
  @method_calls = method_calls
12
13
  @arg_regex = arg_regex
14
+ @base_url = base_url
13
15
  @out = out
14
16
  end
15
17
 
@@ -1,3 +1,3 @@
1
1
  module CodeWeb
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -5,13 +5,6 @@ require 'spec_helper'
5
5
  describe CodeWeb::CodeParser do
6
6
 
7
7
  context "method call" do
8
- it 'should add a method' do
9
- subject << CodeWeb::MethodCall.new(nil, "puts", ['"x"'], false )
10
- expect(method_calls('puts')).to eq([
11
- meth('puts',['"x"'])
12
- ])
13
- end
14
-
15
8
  it 'should support basic method call' do
16
9
  parse %{puts}
17
10
  expect(method_calls('puts')).to eq([
@@ -22,7 +15,7 @@ describe CodeWeb::CodeParser do
22
15
  it 'should support method call with arguments' do
23
16
  parse %{puts "x", :y, true, false}
24
17
  expect(method_calls('puts')).to eq([
25
- meth('puts',['"x"', :y, :true, :false])
18
+ meth('puts',['x', :y, true, false]) # may want x => '"x"'
26
19
  ])
27
20
  end
28
21
 
@@ -36,7 +29,7 @@ describe CodeWeb::CodeParser do
36
29
  it 'should support method call ob objects' do
37
30
  parse %{y.puts "x"}
38
31
  expect(method_calls('y.puts')).to eq([
39
- meth('y.puts',['"x"'])
32
+ meth(['y', :puts],['x'])
40
33
  ])
41
34
  end
42
35
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keenan Brock
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-16 00:00:00.000000000 Z
11
+ date: 2017-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby_parser