rails_stats_fb 2.1.0.pre1

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.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/test.yml +41 -0
  3. data/.gitignore +24 -0
  4. data/CHANGELOG.md +27 -0
  5. data/CODE_OF_CONDUCT.md +76 -0
  6. data/Gemfile +14 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +223 -0
  9. data/Rakefile +13 -0
  10. data/codecov.yml +2 -0
  11. data/lib/rails_stats/all.rb +14 -0
  12. data/lib/rails_stats/app_statistics.rb +62 -0
  13. data/lib/rails_stats/code_statistics.rb +24 -0
  14. data/lib/rails_stats/code_statistics_calculator.rb +93 -0
  15. data/lib/rails_stats/console_formatter.rb +73 -0
  16. data/lib/rails_stats/cucumber_statistics.rb +46 -0
  17. data/lib/rails_stats/gem_statistics.rb +31 -0
  18. data/lib/rails_stats/inflector.rb +605 -0
  19. data/lib/rails_stats/json_formatter.rb +81 -0
  20. data/lib/rails_stats/root_statistics.rb +42 -0
  21. data/lib/rails_stats/spec_statistics.rb +76 -0
  22. data/lib/rails_stats/stats_calculator.rb +169 -0
  23. data/lib/rails_stats/stats_formatter.rb +13 -0
  24. data/lib/rails_stats/tasks.rb +14 -0
  25. data/lib/rails_stats/test_statistics.rb +74 -0
  26. data/lib/rails_stats/util.rb +111 -0
  27. data/lib/rails_stats/version.rb +5 -0
  28. data/lib/rails_stats.rb +9 -0
  29. data/pull_request_template.md +9 -0
  30. data/rails_stats.gemspec +23 -0
  31. data/test/dummy/Gemfile +43 -0
  32. data/test/dummy/Rakefile +6 -0
  33. data/test/dummy/app/assets/config/manifest.js +2 -0
  34. data/test/dummy/app/assets/images/.keep +0 -0
  35. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  36. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  37. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  38. data/test/dummy/app/controllers/application_controller.rb +7 -0
  39. data/test/dummy/app/controllers/concerns/.keep +0 -0
  40. data/test/dummy/app/helpers/application_helper.rb +3 -0
  41. data/test/dummy/app/javascript/channels/consumer.js +6 -0
  42. data/test/dummy/app/javascript/channels/index.js +5 -0
  43. data/test/dummy/app/javascript/packs/application.js +16 -0
  44. data/test/dummy/app/jobs/application_job.rb +7 -0
  45. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  46. data/test/dummy/app/models/application_record.rb +3 -0
  47. data/test/dummy/app/models/comment.rb +3 -0
  48. data/test/dummy/app/models/concerns/.keep +0 -0
  49. data/test/dummy/app/models/pet.rb +2 -0
  50. data/test/dummy/app/models/user.rb +2 -0
  51. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  52. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  53. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  54. data/test/dummy/bin/rails +4 -0
  55. data/test/dummy/bin/rake +4 -0
  56. data/test/dummy/bin/setup +36 -0
  57. data/test/dummy/bin/yarn +11 -0
  58. data/test/dummy/config/application.rb +35 -0
  59. data/test/dummy/config/boot.rb +4 -0
  60. data/test/dummy/config/cable.yml +10 -0
  61. data/test/dummy/config/credentials.yml.enc +1 -0
  62. data/test/dummy/config/database.yml +85 -0
  63. data/test/dummy/config/environment.rb +5 -0
  64. data/test/dummy/config/environments/development.rb +62 -0
  65. data/test/dummy/config/environments/production.rb +112 -0
  66. data/test/dummy/config/environments/test.rb +49 -0
  67. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  68. data/test/dummy/config/initializers/assets.rb +14 -0
  69. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  70. data/test/dummy/config/initializers/content_security_policy.rb +30 -0
  71. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  72. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  73. data/test/dummy/config/initializers/inflections.rb +16 -0
  74. data/test/dummy/config/initializers/mime_types.rb +4 -0
  75. data/test/dummy/config/initializers/pagy.rb +1 -0
  76. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  77. data/test/dummy/config/locales/en.yml +33 -0
  78. data/test/dummy/config/master.key +1 -0
  79. data/test/dummy/config/puma.rb +38 -0
  80. data/test/dummy/config/routes.rb +3 -0
  81. data/test/dummy/config/spring.rb +6 -0
  82. data/test/dummy/config/storage.yml +34 -0
  83. data/test/dummy/config.ru +5 -0
  84. data/test/dummy/db/schema.rb +10 -0
  85. data/test/dummy/lib/monkeypatches.rb +1 -0
  86. data/test/dummy/package.json +10 -0
  87. data/test/dummy/spec/models/user_spec.rb +3 -0
  88. data/test/dummy/spec/support/support_file.rb +1 -0
  89. data/test/dummy/test/models/user_test.rb +2 -0
  90. data/test/dummy/test/support/test_helper.rb +1 -0
  91. data/test/fixtures/console-output.txt +43 -0
  92. data/test/lib/rails_stats/code_statistics_test.rb +23 -0
  93. data/test/lib/rails_stats/json_formatter_test.rb +293 -0
  94. data/test/test_helper.rb +27 -0
  95. metadata +228 -0
@@ -0,0 +1,42 @@
1
+ module RailsStats
2
+ class RootStatistics
3
+ attr_reader :statistics, :total, :test
4
+
5
+ ROOT_FOLDERS = {
6
+ "lib" => "Libraries",
7
+ "config" => "Configuration"
8
+ }
9
+
10
+ def initialize(directory)
11
+ @test = false
12
+ @directory = directory
13
+ @statistics = calculate_statistics
14
+ @total = calculate_total
15
+ end
16
+
17
+ private
18
+
19
+ def calculate_total
20
+ out = CodeStatisticsCalculator.new
21
+ @statistics.each do |key, stats|
22
+ out.add(stats)
23
+ end
24
+ out
25
+ end
26
+
27
+ def calculate_statistics
28
+ Util.calculate_statistics(directories) do |folder|
29
+ ROOT_FOLDERS[File.basename(folder)]
30
+ end
31
+ end
32
+
33
+ def directories
34
+ out = []
35
+ ROOT_FOLDERS.each do |folder, name|
36
+ out << File.join(@directory, folder)
37
+ end
38
+ out
39
+ end
40
+ end
41
+
42
+ end
@@ -0,0 +1,76 @@
1
+ module RailsStats
2
+ class SpecStatistics
3
+ attr_reader :statistics, :total, :test
4
+
5
+ SPEC_FOLDERS = ['controllers',
6
+ 'features',
7
+ 'helpers',
8
+ 'models',
9
+ 'requests',
10
+ 'routing',
11
+ 'integrations',
12
+ 'integration',
13
+ 'mailers',
14
+ 'lib',
15
+ 'acceptance',
16
+ 'factories']
17
+
18
+ def initialize(directory, key_concepts)
19
+ @test = true
20
+ @directory = directory
21
+ @key_concepts = key_concepts
22
+ @statistics = calculate_statistics
23
+ @total = calculate_total
24
+ end
25
+
26
+ private
27
+
28
+ def calculate_total
29
+ out = CodeStatisticsCalculator.new(true)
30
+ @statistics.each do |key, stats|
31
+ out.add(stats)
32
+ end
33
+ out
34
+ end
35
+
36
+ def calculate_statistics
37
+ out = {}
38
+ categorize_files.each do |key, list|
39
+ out[key] = Util.calculate_file_statistics(list)
40
+ end
41
+ out
42
+ end
43
+
44
+ def categorize_files
45
+ out = {}
46
+ Dir[File.join(@directory, "**", "*.rb")].each do |file_path|
47
+ if file_path =~ /.*_spec.rb$/
48
+ key = categorize_file(file_path)
49
+ else
50
+ key = "Spec Support"
51
+ end
52
+
53
+ out[key] ||= []
54
+ out[key] << file_path
55
+ end
56
+
57
+ out
58
+ end
59
+
60
+ def categorize_file(file_path)
61
+ types = (@key_concepts + SPEC_FOLDERS).uniq
62
+ types.each do |folder|
63
+ if file_path =~ /\/#{folder}\//
64
+ folder = Inflector.humanize(folder)
65
+ folder = Inflector.titleize(folder)
66
+ folder = Inflector.singularize(folder)
67
+ return "#{folder} Tests"
68
+ end
69
+ end
70
+
71
+ # something else
72
+ return "Other Tests"
73
+ end
74
+ end
75
+
76
+ end
@@ -0,0 +1,169 @@
1
+ module RailsStats
2
+ class StatsCalculator
3
+ RAILS_APP_FOLDERS = ['models',
4
+ 'controllers',
5
+ 'helpers',
6
+ 'mailers',
7
+ 'views',
8
+ 'assets']
9
+
10
+ def initialize(root_directory)
11
+ @root_directory = root_directory
12
+ @schema_path = File.join(@root_directory, "db", "schema.rb")
13
+ @structure_path = File.join(@root_directory, "db", "structure.sql")
14
+ @key_concepts = calculate_key_concepts
15
+ @projects = calculate_projects
16
+ @statistics = calculate_statistics
17
+ @code_loc = calculate_code
18
+ @test_loc = calculate_tests
19
+ @schema = calculate_create_table_calls
20
+ @polymorphic = calculate_polymorphic
21
+ @files_total, @code_total, @tests_total, @grand_total = calculate_totals
22
+ end
23
+
24
+ attr_reader :code_loc, :code_total, :files_total, :grand_total, :statistics, :test_loc, :tests_total, :schema, :schema_path, :structure_path, :polymorphic
25
+
26
+ private
27
+
28
+ def calculate_key_concepts
29
+ # returns names of main things like models, controllers, services, etc
30
+ concepts = {}
31
+ app_projects.each do |project|
32
+ project.key_concepts.each do |key|
33
+ concepts[key] = true
34
+ end
35
+ end
36
+
37
+ # TODO: maybe gem names?
38
+
39
+ concepts.keys
40
+ end
41
+
42
+ def calculate_projects
43
+ out = []
44
+ out += app_projects
45
+ out += calculate_root_projects
46
+ out += calculate_gem_projects
47
+ out += calculate_spec_projects
48
+ out += calculate_test_projects
49
+ out += calculate_cucumber_projects
50
+ out
51
+ end
52
+
53
+ def app_projects
54
+ @app_projects ||= calculate_app_projects
55
+ end
56
+
57
+ def calculate_app_projects
58
+ apps = Util.calculate_projects(@root_directory, "**", "app", RAILS_APP_FOLDERS)
59
+ apps.collect do |root_path|
60
+ AppStatistics.new(root_path)
61
+ end
62
+ end
63
+
64
+ def calculate_gem_projects
65
+ gems = Util.calculate_projects(@root_directory, "*", "**", "*.gemspec")
66
+ gems.collect do |root_path|
67
+ GemStatistics.new(root_path)
68
+ end
69
+ end
70
+
71
+ def calculate_spec_projects
72
+ specs = Util.calculate_shared_projects("spec", @root_directory, "**", "spec", "**", "*_spec.rb")
73
+ specs.collect do |root_path|
74
+ SpecStatistics.new(root_path, @key_concepts)
75
+ end
76
+ end
77
+
78
+ def calculate_test_projects
79
+ tests = Util.calculate_shared_projects("test", @root_directory, "**", "test", "**", "*_test.rb")
80
+ tests.collect do |root_path|
81
+ TestStatistics.new(root_path, @key_concepts)
82
+ end
83
+ end
84
+
85
+ def calculate_root_projects
86
+ [RootStatistics.new(@root_directory)]
87
+ end
88
+
89
+ def calculate_cucumber_projects
90
+ cukes = Util.calculate_projects(@root_directory, "**", "*.feature")
91
+ cukes.collect do |root_path|
92
+ CucumberStatistics.new(root_path)
93
+ end
94
+ end
95
+
96
+ def calculate_statistics
97
+ out = {}
98
+ @projects.each do |project|
99
+ project.statistics.each do |key, stats|
100
+ out[key] ||= CodeStatisticsCalculator.new(project.test)
101
+ out[key].add(stats)
102
+ end
103
+ end
104
+ out
105
+ end
106
+
107
+ def calculate_totals
108
+ files_total = @statistics.sum do |k,value|
109
+ value.files_total
110
+ end
111
+
112
+ code_total = @statistics.each_with_object(CodeStatisticsCalculator.new) do |pair, code_total|
113
+ code_total.add(pair.last) unless pair.last.test
114
+ end
115
+
116
+ tests_total = @statistics.each_with_object(CodeStatisticsCalculator.new) do |pair, tests_total|
117
+ tests_total.add(pair.last) if pair.last.test
118
+ end
119
+
120
+ grand_total = @statistics.each_with_object(CodeStatisticsCalculator.new) do |pair, total|
121
+ total.add(pair.last)
122
+ end
123
+
124
+ [files_total, code_total, tests_total, grand_total]
125
+ end
126
+
127
+ def calculate_code
128
+ @code_loc = 0
129
+ @statistics.each { |k, v| @code_loc += v.code_lines unless v.test }
130
+ @code_loc
131
+ end
132
+
133
+ def calculate_tests
134
+ @test_loc = 0
135
+ @statistics.each { |k, v| @test_loc += v.code_lines if v.test }
136
+ @test_loc
137
+ end
138
+
139
+ def calculate_create_table_calls
140
+ if @schema_path && File.exist?(@schema_path)
141
+ count_create_table_calls(schema_path, "create_table")
142
+ elsif @structure_path && File.exist?(@structure_path)
143
+ count_create_table_calls(structure_path, "CREATE TABLE")
144
+ else
145
+ 0
146
+ end
147
+ end
148
+
149
+ def count_create_table_calls(file_path, keyword)
150
+ create_table_count = 0
151
+ File.foreach(file_path) do |line|
152
+ create_table_count += 1 if line.strip.start_with?(keyword)
153
+ end
154
+ create_table_count
155
+ end
156
+
157
+ def calculate_polymorphic
158
+ polymorphic_count = 0
159
+ Dir.glob(File.join(@root_directory, "app", "models", "*.rb")).each do |file|
160
+ File.foreach(file) do |line|
161
+ if line =~ /belongs_to\s+:\w+,\s+polymorphic:\s+true/
162
+ polymorphic_count += 1
163
+ end
164
+ end
165
+ end
166
+ polymorphic_count
167
+ end
168
+ end
169
+ end
@@ -0,0 +1,13 @@
1
+ module RailsStats
2
+ class StatsFormatter
3
+ def initialize(calculator, opts = {})
4
+ @calculator = calculator
5
+ @statistics = calculator.statistics
6
+ @code_total = calculator.code_total
7
+ @tests_total = calculator.tests_total
8
+ @grand_total = calculator.grand_total
9
+ end
10
+
11
+ attr_reader :calculator
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ desc "Report code statistics (KLOCs, etc) from the current (or given) application"
2
+ task :stats, [:path, :format] do |t, args|
3
+ Rake::Task["stats"].clear # clear out normal one if there
4
+ require 'rails_stats/all'
5
+
6
+ path = args[:path]
7
+ path = Rails.root.to_s if defined?(Rails)
8
+ fmt = args[:format] || ""
9
+ raise "no path given for stats" unless path
10
+
11
+ root_directory = File.absolute_path(path)
12
+ puts "\nDirectory: #{root_directory}\n\n" if args[:path]
13
+ RailsStats::CodeStatistics.new(root_directory, format: fmt).to_s
14
+ end
@@ -0,0 +1,74 @@
1
+ module RailsStats
2
+ class TestStatistics
3
+ attr_reader :statistics, :total, :test
4
+
5
+ SPEC_FOLDERS = ['controllers',
6
+ 'functional',
7
+ 'helpers',
8
+ 'models',
9
+ 'requests',
10
+ 'unit',
11
+ 'integrations',
12
+ 'integration',
13
+ 'mailers',
14
+ 'lib']
15
+
16
+ def initialize(directory, key_concepts)
17
+ @test = true
18
+ @directory = directory
19
+ @key_concepts = key_concepts
20
+ @statistics = calculate_statistics
21
+ @total = calculate_total
22
+ end
23
+
24
+ private
25
+
26
+ def calculate_total
27
+ out = CodeStatisticsCalculator.new(true)
28
+ @statistics.each do |key, stats|
29
+ out.add(stats)
30
+ end
31
+ out
32
+ end
33
+
34
+ def calculate_statistics
35
+ out = {}
36
+ categorize_files.each do |key, list|
37
+ out[key] = Util.calculate_file_statistics(list)
38
+ end
39
+ out
40
+ end
41
+
42
+ def categorize_files
43
+ out = {}
44
+ Dir[File.join(@directory, "**", "*.rb")].each do |file_path|
45
+ if file_path =~ /.*_test.rb$/
46
+ key = categorize_file(file_path)
47
+ else
48
+ key = "Test Support"
49
+ end
50
+
51
+ out[key] ||= []
52
+ out[key] << file_path
53
+ end
54
+
55
+ out
56
+ end
57
+
58
+ def categorize_file(file_path)
59
+ types = (@key_concepts + SPEC_FOLDERS).uniq
60
+ types.each do |folder|
61
+ if file_path =~ /\/#{folder}\//
62
+ folder = Inflector.humanize(folder)
63
+ folder = Inflector.titleize(folder)
64
+ folder = Inflector.singularize(folder)
65
+ return "#{folder} Tests"
66
+ end
67
+ end
68
+
69
+ # something else
70
+ return "Other Tests"
71
+ end
72
+ end
73
+
74
+ end
@@ -0,0 +1,111 @@
1
+ module RailsStats
2
+ module Util
3
+ extend self
4
+
5
+ def calculate_projects(*args)
6
+ projects = {}
7
+
8
+ children = [args.pop].flatten
9
+ parent = args.flatten
10
+ children.each do |dirname|
11
+ child_folder_pattern = File.join(*(parent.dup + [dirname]))
12
+ Dir[child_folder_pattern].each do |marker_path|
13
+ next if marker_path =~ /\/vendor\//
14
+
15
+ projects[File.absolute_path(File.dirname(marker_path))] = true
16
+ end
17
+ end
18
+
19
+ out = projects.keys
20
+
21
+ # TODO: make sure none are children of other ones in there
22
+ out
23
+ end
24
+
25
+ def calculate_shared_projects(shared, *args)
26
+ projects = {}
27
+ calculate_projects(*args).each do |path|
28
+ if path =~ /(^.*\/#{shared}\/).*/
29
+ projects[$1] = true
30
+ end
31
+ end
32
+
33
+ out = projects.keys
34
+
35
+ # TODO: make sure none are children of other ones in there
36
+ out
37
+ end
38
+
39
+ def calculate_file_statistics(file, type = :code, &block)
40
+ stats = CodeStatisticsCalculator.new
41
+
42
+ files = [file].flatten
43
+
44
+ files.each do |path|
45
+ stats.add_by_file_path(path)
46
+ end
47
+
48
+ stats
49
+ end
50
+
51
+ def calculate_statistics(directories, type = :code, &block)
52
+ out = {}
53
+
54
+ directories = [directories].flatten
55
+ is_test = (type.to_s == "test")
56
+
57
+ directories.each do |dir_path|
58
+ next unless File.directory?(dir_path)
59
+
60
+ key = nil
61
+ if block_given?
62
+ key = yield(dir_path)
63
+ end
64
+
65
+ key = path_to_name(dir_path, is_test) if !key || key.length == 0
66
+
67
+ out[key] ||= CodeStatisticsCalculator.new(is_test)
68
+ out[key].add(calculate_directory_statistics(dir_path))
69
+ end
70
+
71
+ out.keys.each do |key|
72
+ out.delete(key) if out[key].lines == 0
73
+ end
74
+
75
+ out
76
+ end
77
+
78
+ def calculate_directory_statistics(directory, pattern = /.*\.(rb|js|coffee|feature)$/)
79
+ stats = CodeStatisticsCalculator.new
80
+
81
+ Dir.foreach(directory) do |file_name|
82
+ path = "#{directory}/#{file_name}"
83
+
84
+ if File.directory?(path) && (/^\./ !~ file_name)
85
+ stats.add(calculate_directory_statistics(path, pattern))
86
+ end
87
+
88
+ next unless file_name =~ pattern
89
+
90
+ stats.add_by_file_path(path)
91
+ end
92
+
93
+ stats
94
+ end
95
+
96
+ def path_to_name(path, is_test)
97
+ folder = File.basename(path)
98
+ folder = Inflector.humanize(folder)
99
+ folder = Inflector.titleize(folder)
100
+
101
+ if is_test
102
+ folder = Inflector.singularize(folder)
103
+ folder = "#{folder} Tests"
104
+ else
105
+ folder = Inflector.pluralize(folder)
106
+ end
107
+
108
+ folder
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsStats
4
+ VERSION = "2.1.0.pre1"
5
+ end
@@ -0,0 +1,9 @@
1
+ require "rails_stats/version"
2
+
3
+ module RailsStats
4
+
5
+ end
6
+
7
+ require 'rake'
8
+ require 'rails_stats/tasks'
9
+
@@ -0,0 +1,9 @@
1
+ **IMPORTANT**: Please read the README before submitting pull requests for this project. Additionally, if your PR closes any open GitHub issues, make sure you include _Closes #XXXX_ in your comment or use the option on the PR's sidebar to add related issues to auto-close the issue that your PR fixes.
2
+
3
+ - [ ] Add an entry to `CHANGELOG.md` that links to this PR under the "main (unreleased)" heading.
4
+
5
+ **Description:**
6
+
7
+ Please include a summary of the change and which issue is fixed or which feature is introduced. If changes to the behavior are made, clearly describe what changes.
8
+
9
+ I will abide by the [code of conduct](CODE_OF_CONDUCT.md).
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_stats/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_stats_fb"
8
+ spec.version = RailsStats::VERSION
9
+ spec.authors = ["Brian Leonard"]
10
+ spec.email = ["brian@bleonard.com"]
11
+ spec.summary = %q{Analyze a Rails project}
12
+ spec.description = %q{Point it to a directory and see stuff about the app}
13
+ spec.homepage = "https://github.com/fastruby/rails_stats"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rake"
22
+ spec.add_dependency "bundler-stats", ">= 2.1"
23
+ end
@@ -0,0 +1,43 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ ruby '2.6.8'
5
+
6
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
7
+ gem 'rails', '~> 6.0.3', '>= 6.0.3.3'
8
+ # Use Puma as the app server
9
+ gem 'puma', '~> 4.1'
10
+ # Use SCSS for stylesheets
11
+ gem "sass-rails"
12
+ # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
13
+ gem 'webpacker', '~> 4.0'
14
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
15
+ gem 'jbuilder', '~> 2.7'
16
+ # Use Redis adapter to run Action Cable in production
17
+ # gem 'redis', '~> 4.0'
18
+ # Use Active Model has_secure_password
19
+ # gem 'bcrypt', '~> 3.1.7'
20
+
21
+ # Use Active Storage variant
22
+ # gem 'image_processing', '~> 1.2'
23
+ gem 'rails_stats', path: '../../../rails_stats'
24
+
25
+ # Reduces boot times through caching; required in config/boot.rb
26
+ gem 'bootsnap', '>= 1.4.2', require: false
27
+
28
+ group :development, :test do
29
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
30
+ gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
31
+ end
32
+
33
+ group :development do
34
+ # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
35
+ gem 'web-console', '>= 3.3.0'
36
+ gem 'listen', '~> 3.2'
37
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
38
+ gem 'spring'
39
+ gem 'spring-watcher-listen', '~> 2.0.0'
40
+ end
41
+
42
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
43
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,2 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../stylesheets .css
File without changes
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
6
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ class ApplicationController < ActionController::Base
2
+ include Pagy::Backend
3
+
4
+ def hello
5
+ p hello
6
+ end
7
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ module ApplicationHelper
2
+ include Pagy::Frontend
3
+ end
@@ -0,0 +1,6 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+
4
+ import { createConsumer } from "@rails/actioncable"
5
+
6
+ export default createConsumer()
@@ -0,0 +1,5 @@
1
+ // Load all the channels within this directory and all subdirectories.
2
+ // Channel files must be named *_channel.js.
3
+
4
+ const channels = require.context('.', true, /_channel\.js$/)
5
+ channels.keys().forEach(channels)