gemsurance 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 830b58bdd6e64daa65c79a0f4b0269576ffb4017
4
- data.tar.gz: c8089759dad68546a2a39a6eca578c7197536b0d
3
+ metadata.gz: ee5e6c4788cfdee5596726a63e3754436543e10d
4
+ data.tar.gz: 369e502b049c24f560bae6b9e958a625962589ea
5
5
  SHA512:
6
- metadata.gz: 4553a6dd50c705281e48bece4c12b120e665d3e05152e237f95bca8fab0512fd9c2a3fe3ed1c5782a83307d4db99448b28c2446a92347bedd58326bd07a2c322
7
- data.tar.gz: f3ac8590042d1b3ca4e9303c270ad52fda1f1b6f16f0b1af6cca2abcaadeb00304397e582a9ff9b06c52d0c9eb660cbff00967f16389b2e361b2cb19aaecde44
6
+ metadata.gz: 354aac34c082b8d85e4f344e9fb46eb99d747a8b6a5a9527961cc51e70a2171d1000a7b91a41b9d31022cba9f069464e23b21efbbf7c0a8e2104279eb9203026
7
+ data.tar.gz: bc326cda646e12e6bf041091f44ed15d034b16fdef2c5af88c7b037c25603db5933e1e97cba5e977e515426dc6908897a34eb1183f70ac75e0b2d1304cf49895
@@ -4,7 +4,9 @@ require 'erb'
4
4
  require 'gems'
5
5
 
6
6
  require 'gemsurance/gem_info_retriever'
7
- require 'gemsurance/html_formatter'
7
+ require 'gemsurance/formatters/base'
8
+ require 'gemsurance/formatters/html'
9
+ require 'gemsurance/formatters/yml'
8
10
  require 'gemsurance/runner'
9
11
  require 'gemsurance/version'
10
12
  require 'gemsurance/vulnerability'
@@ -21,6 +21,10 @@ module Gemsurance
21
21
  options[:output_file] = file
22
22
  end
23
23
 
24
+ opts.on("--format FORMAT", "Output report to given format (html & yml available). Html by default.") do |format|
25
+ options[:formatter] = format
26
+ end
27
+
24
28
  opts.on_tail("-h", "--help", "Show this help") do
25
29
  puts opts
26
30
  exit
@@ -0,0 +1,17 @@
1
+ module Gemsurance
2
+ module Formatters
3
+ class Base
4
+ def initialize(gem_infos)
5
+ @gem_infos = gem_infos
6
+ end
7
+
8
+ def output_path
9
+ File.join(File.dirname(__FILE__), "../templates/output.#{@extension}.erb")
10
+ end
11
+
12
+ def sorted_gems
13
+ @gem_infos.sort{ |a, b| a.name.downcase <=> b.name.downcase }
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ module Gemsurance
2
+ module Formatters
3
+ class Html < Base
4
+ def format
5
+ @extension = "html"
6
+ ERB.new(File.read(output_path)).result(binding)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Gemsurance
2
+ module Formatters
3
+ class Yml < Base
4
+ def format
5
+ @extension = "yml"
6
+ ERB.new(File.read(output_path), nil, '-').result(binding)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -2,7 +2,7 @@ module Gemsurance
2
2
  class Runner
3
3
  def initialize(options = {})
4
4
  @formatter = options.delete(:formatter) || :html
5
- @output_file = options.delete(:output_file) || 'gemsurance_report.html'
5
+ @output_file = options.delete(:output_file) || "gemsurance_report.#{@formatter}"
6
6
  @options = options
7
7
  end
8
8
 
@@ -69,7 +69,7 @@ module Gemsurance
69
69
 
70
70
  def generate_report(gem_infos)
71
71
  puts "Generating report..."
72
- output_data = Gemsurance.const_get(:"#{@formatter.to_s.capitalize}Formatter").new(gem_infos).format
72
+ output_data = Gemsurance::Formatters.const_get(:"#{@formatter.to_s.capitalize}").new(gem_infos).format
73
73
 
74
74
  File.open(@output_file, "w+") do |file|
75
75
  file.puts output_data
@@ -764,7 +764,7 @@
764
764
  </tr>
765
765
  </thead>
766
766
  <tbody>
767
- <% @gem_infos.sort { |a, b| a.name.downcase <=> b.name.downcase }.each do |gem_info| %>
767
+ <% sorted_gems.each do |gem_info| %>
768
768
  <%
769
769
  row_class = if gem_info.current?
770
770
  'success'
@@ -0,0 +1,25 @@
1
+ <%- sorted_gems.each do |gem_info| -%>
2
+ <%= gem_info.name %>:
3
+ in_gem_file: <%= gem_info.in_gem_file %>
4
+ bundle_version: <%= gem_info.current_version %>
5
+ newest_version: <%= gem_info.newest_version %>
6
+ <%- if gem_info.vulnerable? -%>
7
+ status: vulnerable
8
+ <%- elsif gem_info.outdated? -%>
9
+ status: outofdate
10
+ <%- elsif gem_info.current? -%>
11
+ status: uptodate
12
+ <%- else -%>
13
+ status: unknown
14
+ <%- end -%>
15
+ vulnerabilities:
16
+ <%- gem_info.vulnerabilities.each do |vulnerability| -%>
17
+ - title: '<%= vulnerability.title %>'
18
+ cve: <%= vulnerability.cve %>
19
+ url: <%= vulnerability.url %>
20
+ patched_versions: <%= (vulnerability.patched_versions || []).join(', ') %>
21
+ <%- end -%>
22
+ homepage_url: <%= gem_info.homepage_uri %>
23
+ source_code_url: <%= gem_info.source_code_uri %>
24
+ documentation_url: <%= gem_info.documentation_uri %>
25
+ <%- end -%>
@@ -1,3 +1,3 @@
1
1
  module Gemsurance
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemsurance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Kessler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -104,10 +104,13 @@ files:
104
104
  - bin/gemsurance
105
105
  - lib/gemsurance.rb
106
106
  - lib/gemsurance/cli.rb
107
+ - lib/gemsurance/formatters/base.rb
108
+ - lib/gemsurance/formatters/html.rb
109
+ - lib/gemsurance/formatters/yml.rb
107
110
  - lib/gemsurance/gem_info_retriever.rb
108
- - lib/gemsurance/html_formatter.rb
109
111
  - lib/gemsurance/runner.rb
110
112
  - lib/gemsurance/templates/output.html.erb
113
+ - lib/gemsurance/templates/output.yml.erb
111
114
  - lib/gemsurance/version.rb
112
115
  - lib/gemsurance/vulnerability.rb
113
116
  homepage: http://github.com/appfolio/gemsurance
@@ -1,11 +0,0 @@
1
- module Gemsurance
2
- class HtmlFormatter
3
- def initialize(gem_infos)
4
- @gem_infos = gem_infos
5
- end
6
-
7
- def format
8
- ERB.new(File.read(File.join(File.dirname(File.expand_path(__FILE__)), 'templates/output.html.erb'))).result(binding)
9
- end
10
- end
11
- end