Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Commit

Permalink
Prepare for formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
meganemura committed Mar 14, 2015
1 parent 7cb090e commit ff30d6e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/sloc/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def run(args = ARGV)
if help?
puts help
else
@runner.run(@paths)
puts @runner.run(@paths)
end
end

Expand Down
9 changes: 6 additions & 3 deletions lib/sloc/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ def initialize(options = {})
end

def run(paths)
# TODO: formatted output
require 'pp'
pp report(paths)
report(paths)

nil
end

def report(paths)
require 'pp'
PP.pp(raw_report(paths), '')
end

def raw_report(paths)
target_files = find_target_files(paths)

# TODO: count sloc
Expand Down
12 changes: 6 additions & 6 deletions spec/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
`git ls-files -z`.split("\x0")
end

describe '#report' do
describe '#raw_report' do
context 'with no options' do
it 'returns hash' do
expect(instance.report(files)).to be_a Hash
expect(instance.raw_report(files)).to be_a Hash
end
end

Expand All @@ -25,20 +25,20 @@
{ order: Sloc::Analyzer::REPORT_KEYS.sample }
end

let(:report) do
instance.report(files)
let(:raw_report) do
instance.raw_report(files)
end

let(:order) do
options[:order]
end

it 'returns hash' do
expect(report).to be_a Hash
expect(raw_report).to be_a Hash
end

it 'returns hash and it is ordered' do
report.each_cons(2) do |(_ak, av), (_bk, bv)|
raw_report.each_cons(2) do |(_ak, av), (_bk, bv)|
expect(av[order] <= bv[order]).to be true
end
end
Expand Down

0 comments on commit ff30d6e

Please sign in to comment.