fukuzatsu 2.1.1 → 2.2.1

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: 2f07664e5fec8ebb4806db7425780356672dbff2
4
- data.tar.gz: d53ab4e6300ee913f663ab334cb71599a89a7d7b
3
+ metadata.gz: eb84e0a6f11ae010959c1aa9d657c22bae0983d1
4
+ data.tar.gz: 159ee1f749fa2e8527194ed519627b5a5167897e
5
5
  SHA512:
6
- metadata.gz: 32d568e9018a733ea7e9a3b98c3df9cabad1917aa5ce0d2ba96f2ade60d7f65677afae5939ffaa80db506aa8bff44b827f3407d3b160df05e050fdfde69c411f
7
- data.tar.gz: 097cbc999cd38da8c69eab575c8143754f1498b97a5f6b861682b6d2057be2531ff9114f4dd7e756526d37517a0a0b5c54d601fb583b8d9ff5c55e030fdc83b1
6
+ metadata.gz: 780f5c5b5fbe79f397c34eea73253d001fbc2fe18eee713210b0774886f3a8f14383322935242fc97e4d2e83ee733db81c25c606034d4e2e0b992148e86aa714
7
+ data.tar.gz: fd6bf7dc7e6efccba8badae0d4f4273fbffb88fa44876364022ab392d32e257c10b182dc58255808fbd336856a9f2bd2e55311622499e99207e89296b4074230
@@ -1,13 +1,13 @@
1
- # CODE OF CONDUCT
2
-
3
- This project has adopted version 0.4 of the [Contributor Covenant](https://github.com/bantik/contributor_covenant/).
1
+ # Contributor Code of Conduct
4
2
 
5
3
  As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
6
4
 
7
- If any participant in this project has issues or takes exception with a contribution, they are obligated to provide constructive feedback and never resort to personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
8
 
9
9
  Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
10
 
11
11
  Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
12
 
13
- We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, ability or disability, ethnicity, religion, or level of experience.
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
+ spec.required_ruby_version = '>= 2.1'
20
21
 
21
22
  spec.add_dependency "analyst", ">= 0.16.0"
22
23
  spec.add_dependency "ephemeral"
@@ -19,8 +19,8 @@ require_relative "fukuzatsu/summary"
19
19
  require_relative "fukuzatsu/version"
20
20
 
21
21
  module Fukuzatsu
22
- def self.new(path_to_files, formatter=:text, threshold=0)
23
- Fukuzatsu::Parser.new(path_to_files, formatters[formatter], threshold)
22
+ def self.new(path_to_files, formatter=:text, threshold=0, output_path=nil)
23
+ Fukuzatsu::Parser.new(path_to_files, formatters[formatter], threshold, output_path)
24
24
  end
25
25
 
26
26
  def self.formatters
@@ -8,12 +8,13 @@ module Fukuzatsu
8
8
  desc_text = "Formats are text (default, to STDOUT), html, and csv. "
9
9
  desc_text << "Example: fuku check foo/ -f html"
10
10
 
11
- desc "check PATH_TO_FILE [-f FORMAT] [-t MAX_COMPLEXITY_ALLOWED]", desc_text
11
+ desc "check PATH_TO_FILE [-f FORMAT] [-t MAX_COMPLEXITY_ALLOWED] [-o OUTPUT_PATH]", desc_text
12
12
  method_option :format, :type => :string, :default => 'text', :aliases => "-f"
13
13
  method_option :threshold, :type => :numeric, :default => 0, :aliases => "-t"
14
+ method_option :output, :type => :string, :aliases => "-o"
14
15
 
15
16
  def check(path="./")
16
- Fukuzatsu.new(path, formatter, options['threshold']).report
17
+ Fukuzatsu.new(path, formatter, options['threshold'], options['output']).report
17
18
  end
18
19
 
19
20
  default_task :check
@@ -4,24 +4,24 @@ module Fukuzatsu
4
4
 
5
5
  module Base
6
6
 
7
- BASE_OUTPUT_DIRECTORY = "doc/fukuzatsu/"
8
-
9
7
  def self.included(klass)
10
8
  klass.send(:attr_accessor, :summary)
11
9
  klass.send(:attr_accessor, :source)
10
+ klass.send(:attr_accessor, :base_output_path)
12
11
  klass.extend(ClassMethods)
13
12
  end
14
13
 
15
- def initialize(source: nil, summary:nil)
14
+ def initialize(source: nil, summary:nil, base_output_path:)
16
15
  self.source = source
17
16
  self.summary = summary
17
+ self.base_output_path = base_output_path
18
18
  end
19
19
 
20
20
  def export
21
21
  begin
22
22
  File.open(path_to_results, 'w') {|outfile| outfile.write(content)}
23
23
  rescue Exception => e
24
- puts "Unable to write output: #{e} #{e.backtrace}"
24
+ puts "Unable to write output to #{path_to_results}: #{e} #{e.backtrace}"
25
25
  end
26
26
  end
27
27
 
@@ -30,7 +30,7 @@ module Fukuzatsu
30
30
  end
31
31
 
32
32
  def output_directory
33
- BASE_OUTPUT_DIRECTORY + file_extension.gsub(".","")
33
+ self.base_output_path + "/" + file_extension.gsub(".","")
34
34
  end
35
35
 
36
36
  def output_path
@@ -49,11 +49,11 @@ module Fukuzatsu
49
49
 
50
50
  module ClassMethods
51
51
 
52
- def index(summaries)
52
+ def index(summaries, base_output_path)
53
53
  end
54
54
 
55
- def reset_output_directory
56
- directory = new.output_directory
55
+ def reset_output_directory(base_output_path)
56
+ directory = new(base_output_path: base_output_path).output_directory
57
57
  begin
58
58
  FileUtils.remove_dir(directory)
59
59
  rescue Errno::ENOENT
@@ -61,9 +61,10 @@ module Fukuzatsu
61
61
  FileUtils.mkpath(directory)
62
62
  end
63
63
 
64
- def explain(count)
65
- puts "Processed #{count} file(s). Results written to #{new.output_directory}."
64
+ def writes_to_file_system?
65
+ true
66
66
  end
67
+
67
68
  end
68
69
  end
69
70
 
@@ -8,8 +8,8 @@ module Fukuzatsu
8
8
 
9
9
  include Formatters::Base
10
10
 
11
- def self.index(summaries)
12
- Fukuzatsu::Formatters::HtmlIndex.new(summaries).export
11
+ def self.index(summaries, base_output_path)
12
+ Fukuzatsu::Formatters::HtmlIndex.new(summaries, base_output_path).export
13
13
  end
14
14
 
15
15
  def columns
@@ -8,8 +8,9 @@ module Fukuzatsu
8
8
 
9
9
  attr_reader :summaries
10
10
 
11
- def initialize(summaries)
11
+ def initialize(summaries, base_output_path)
12
12
  @summaries = summaries
13
+ @base_output_path = base_output_path
13
14
  end
14
15
 
15
16
  def content
@@ -6,8 +6,8 @@ module Fukuzatsu
6
6
 
7
7
  include Formatters::Base
8
8
 
9
- def self.index(summaries)
10
- Fukuzatsu::Formatters::JsonIndex.new(summaries).export
9
+ def self.index(summaries, base_output_path)
10
+ Fukuzatsu::Formatters::JsonIndex.new(summaries, base_output_path).export
11
11
  end
12
12
 
13
13
  def as_json
@@ -19,7 +19,7 @@ module Fukuzatsu
19
19
  }
20
20
  if summary.is_class_or_module?
21
21
  result[:average_complexity] = summary.average_complexity
22
- result[:methods] = summary.summaries.map { |s| Json.new(summary: s).as_json }
22
+ result[:methods] = summary.summaries.map { |s| Json.new(summary: s, base_output_path: self.base_output_path).as_json }
23
23
  end
24
24
  result
25
25
  end
@@ -8,12 +8,13 @@ module Fukuzatsu
8
8
 
9
9
  attr_reader :summaries
10
10
 
11
- def initialize(summaries)
11
+ def initialize(summaries, base_output_path)
12
12
  @summaries = summaries
13
+ @base_output_path = base_output_path
13
14
  end
14
15
 
15
16
  def content
16
- summaries.map { |summary| Json.new(summary: summary).as_json }.to_json
17
+ summaries.map { |summary| Json.new(summary: summary, base_output_path: self.base_output_path).as_json }.to_json
17
18
  end
18
19
 
19
20
  def filename
@@ -9,9 +9,7 @@ module Fukuzatsu
9
9
 
10
10
  include Formatters::Base
11
11
 
12
- def self.explain(count); end
13
-
14
- def self.reset_output_directory
12
+ def self.reset_output_directory(args)
15
13
  end
16
14
 
17
15
  def self.writes_to_file_system?
@@ -5,21 +5,29 @@ module Fukuzatsu
5
5
 
6
6
  class Parser
7
7
 
8
- attr_reader :path_to_files, :formatter, :threshold
8
+ attr_reader :path_to_files, :formatter, :threshold, :output_path
9
9
 
10
- def initialize(path_to_files, formatter, threshold)
10
+ DEFAULT_OUTPUT_DIRECTORY = "doc/fukuzatsu/"
11
+
12
+ def initialize(path_to_files, formatter, threshold, output_path=nil)
11
13
  @path_to_files = path_to_files
12
14
  @formatter = formatter
13
15
  @threshold = threshold
16
+ @output_path = output_path || DEFAULT_OUTPUT_DIRECTORY
17
+ end
18
+
19
+ def explain
20
+ puts "Processed #{summaries.count} file(s)."
21
+ puts "Results written to #{output_path}." if formatter.writes_to_file_system?
14
22
  end
15
23
 
16
24
  def report
17
- self.formatter.reset_output_directory
18
- self.formatter.index(summaries)
25
+ self.formatter.reset_output_directory(output_path)
26
+ self.formatter.index(summaries, output_path)
19
27
  summaries.uniq(&:container_name).each do |summary|
20
- self.formatter.new(summary: summary).export
28
+ self.formatter.new(summary: summary, base_output_path: self.output_path).export
21
29
  end
22
- self.formatter.explain(summaries.count)
30
+ explain
23
31
  check_complexity
24
32
  end
25
33
 
@@ -1,3 +1,3 @@
1
1
  module Fukuzatsu
2
- VERSION = "2.1.1"
2
+ VERSION = "2.2.1"
3
3
  end
@@ -29,7 +29,7 @@ describe Fukuzatsu::Formatters::Csv do
29
29
  )
30
30
  }
31
31
 
32
- let (:formatter) { Fukuzatsu::Formatters::Csv.new(summary: summary) }
32
+ let (:formatter) { Fukuzatsu::Formatters::Csv.new(summary: summary, base_output_path: nil) }
33
33
 
34
34
  describe "#rows" do
35
35
 
@@ -26,7 +26,7 @@ describe "Fukuzatsu::Formatters::HTML" do
26
26
  )
27
27
  }
28
28
 
29
- let (:formatter) { Fukuzatsu::Formatters::Html.new(summary: summary) }
29
+ let (:formatter) { Fukuzatsu::Formatters::Html.new(summary: summary, base_output_path: nil) }
30
30
 
31
31
  describe "#header" do
32
32
  it "returns an HTML-formatted header" do
@@ -29,7 +29,7 @@ describe "Fukuzatsu::Formatters::Json" do
29
29
  )
30
30
  }
31
31
 
32
- let (:formatter) { Fukuzatsu::Formatters::Json.new(summary: summary) }
32
+ let (:formatter) { Fukuzatsu::Formatters::Json.new(summary: summary, base_output_path: nil) }
33
33
 
34
34
  describe "#to_json" do
35
35
 
@@ -10,7 +10,7 @@ describe Fukuzatsu::Formatters::Text do
10
10
  )
11
11
  }
12
12
 
13
- let (:formatter) { Fukuzatsu::Formatters::Text.new(summary: summary) }
13
+ let (:formatter) { Fukuzatsu::Formatters::Text.new(summary: summary, base_output_path: nil) }
14
14
 
15
15
  describe "#header" do
16
16
  it "returns a header array" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fukuzatsu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coraline Ada Ehmke
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-26 00:00:00.000000000 Z
12
+ date: 2014-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: analyst
@@ -267,7 +267,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
267
267
  requirements:
268
268
  - - ">="
269
269
  - !ruby/object:Gem::Version
270
- version: '0'
270
+ version: '2.1'
271
271
  required_rubygems_version: !ruby/object:Gem::Requirement
272
272
  requirements:
273
273
  - - ">="