Skip to content

Commit 23018bc

Browse files
authored
Merge pull request #21 from fastruby/feature/bundler-stats
Add dependency on bundler-stats and improve output
2 parents cbeff8c + 601594d commit 23018bc

File tree

13 files changed

+161
-31
lines changed

13 files changed

+161
-31
lines changed

.github/workflows/test.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ on:
88
pull_request:
99
branches:
1010
- main
11-
env:
12-
COVERAGE: true
13-
CODECOV_TOKEN: d7028c0e-97c5-485f-85e5-f63daabeef63
1411
jobs:
1512
test-ruby-2-4-x:
1613
runs-on: ubuntu-latest
@@ -23,6 +20,10 @@ jobs:
2320
ruby-version: 2.4
2421
bundler-cache: true
2522
- name: Build and run tests
23+
env:
24+
COVERAGE: true
25+
TERM: xterm
26+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2627
run: |
2728
gem install bundler
2829
bundle install --jobs 4 --retry 3
@@ -38,6 +39,10 @@ jobs:
3839
ruby-version: 2.5
3940
bundler-cache: true
4041
- name: Build and run tests
42+
env:
43+
COVERAGE: true
44+
TERM: xterm
45+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4146
run: |
4247
gem install bundler
4348
bundle install --jobs 4 --retry 3
@@ -53,6 +58,10 @@ jobs:
5358
ruby-version: 2.6
5459
bundler-cache: true
5560
- name: Build and run tests
61+
env:
62+
COVERAGE: true
63+
TERM: xterm
64+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5665
run: |
5766
gem install bundler
5867
bundle install --jobs 4 --retry 3
@@ -68,6 +77,10 @@ jobs:
6877
ruby-version: 2.7
6978
bundler-cache: true
7079
- name: Build and run tests
80+
env:
81+
COVERAGE: true
82+
TERM: xterm
83+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7184
run: |
7285
gem install bundler
7386
bundle install --jobs 4 --retry 3
@@ -83,6 +96,10 @@ jobs:
8396
ruby-version: 3.0
8497
bundler-cache: true
8598
- name: Build and run tests
99+
env:
100+
COVERAGE: true
101+
TERM: xterm
102+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
86103
run: |
87104
gem install bundler
88105
bundle install --jobs 4 --retry 3

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
.byebug_history
12
*.gem
23
*.rbc
34
.bundle
45
.config
6+
.ruby-version
57
.yardoc
68
Gemfile.lock
79
InstalledFiles

Gemfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
source 'https://rubygems.org'
1+
source "https://rubygems.org"
22

3-
# Specify your gem's dependencies in rails_stats.gemspec
43
gemspec
4+
5+
group :development, :test do
6+
gem "bundler", ">= 1.6", "< 3.0"
7+
gem "byebug"
8+
gem "codecov"
9+
gem "minitest"
10+
gem "minitest-around"
11+
gem "minitest-spec-context"
12+
gem "simplecov"
13+
gem "simplecov-console"
14+
end

lib/rails_stats/app_statistics.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ class AppStatistics
33
attr_reader :statistics, :total, :test
44

55
def initialize(directory)
6+
@directories = []
67
@test = false
7-
@directory = directory
8-
@statistics = calculate_statistics
9-
@total = calculate_total
8+
@directory = directory
9+
@statistics = calculate_statistics
10+
@total = calculate_total
1011
end
1112

1213
def key_concepts
@@ -28,15 +29,15 @@ def calculate_statistics
2829
end
2930

3031
def directories
31-
return @directories if @directories
32-
out = []
32+
return @directories if @directories.any?
33+
3334
Dir.foreach(@directory) do |file_name|
3435
path = File.join(@directory, file_name)
3536
next unless File.directory?(path)
3637
next if (/^\./ =~ file_name)
3738
next if file_name == "assets" # doing separately
3839
next if file_name == "views" # TODO
39-
out << path
40+
@directories << path
4041
end
4142

4243
assets = File.join(@directory, "assets")
@@ -48,13 +49,13 @@ def directories
4849

4950
case file_name
5051
when "javascripts"
51-
out << path
52+
@directories << path
5253
# TODO when "css"
5354
end
5455
end
5556
end
5657

57-
out
58+
@directories
5859
end
5960
end
6061

lib/rails_stats/console_formatter.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
require "bundler/stats/cli"
2+
13
module RailsStats
24
class ConsoleFormatter < StatsFormatter
35
def to_s
6+
Bundler::Stats::CLI.start
7+
48
print_header
59
sorted_keys = @statistics.keys.sort
610
sorted_keys.each { |key| print_line(key, @statistics[key]) }

rails_stats.gemspec

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,5 @@ Gem::Specification.new do |spec|
1919
spec.require_paths = ["lib"]
2020

2121
spec.add_dependency "rake"
22-
spec.add_development_dependency "bundler", ">= 1.6", "< 3.0"
23-
spec.add_development_dependency "byebug"
24-
spec.add_development_dependency "codecov"
25-
spec.add_development_dependency "minitest"
26-
spec.add_development_dependency "minitest-around"
27-
spec.add_development_dependency "minitest-spec-context"
28-
spec.add_development_dependency "simplecov"
29-
spec.add_development_dependency "simplecov-console"
22+
spec.add_dependency "bundler-stats", ">= 2.1"
3023
end

test/dummy/lib/monkeypatches.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
puts "Monkeypatches go here"

test/dummy/spec/models/user_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class FooBar
2+
3+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
puts "This is a spec support file"

test/dummy/test/models/user_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class UserTest
2+
end

0 commit comments

Comments
 (0)