binxtils 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6939fd30bf94c85805b8f5cbc55b0a5e4ea0b3938093c84b986e5d94571a9efb
4
- data.tar.gz: 8cf7bcc61f2d001b6b4c67358b99505b528c5bfd40d9ac919c5a8b17a3efa64d
3
+ metadata.gz: 1595e2d8526fd86fa68cd648e318960c951a046c7a5401bb3819a01f91f9d915
4
+ data.tar.gz: a57ad2f943c81ccbc8245302639805b8ffa36529b8737871a5afdd143c162462
5
5
  SHA512:
6
- metadata.gz: bc96e2f7f245112cfa3f70b1a224884c320b5cf27d17ce321d71e959935bf80127a113a9f96dfe762eebbb9122ed543589482cd8bc7e0a5f19c7f143f632d3b1
7
- data.tar.gz: 0a1d915fb2ce58a04353421c0aed7ec6c41a56b0bdf56d07a146edad73ed26ead20548ca24eb6e6ccd01de9fdbd88ec0f63974b9f7bf4f6342e0eb2435ff9bfb
6
+ metadata.gz: a7e95c3ad3df8c0a64ea582344c40033407e49e4844284b964bc21159b1933bfe121f1848b9c8f53913c496140c4a174af847d113527a63f8c1302b9f5040788
7
+ data.tar.gz: 2cdd46b2ea2b0f9c45aa7d2432f7296210d481405d0154edea6ad1d9f3d18604059f27751225b11d73988dc9a0bc57c68a2db48f6e57e9a8a5b962faf5678868
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binxtils
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ load "tasks/char_count.rake"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binxtils
4
+ VERSION = "0.2.0"
5
+ end
data/lib/binxtils.rb CHANGED
@@ -10,3 +10,4 @@ require "rails-html-sanitizer"
10
10
  require_relative "binxtils/input_normalizer"
11
11
  require_relative "binxtils/time_zone_parser"
12
12
  require_relative "binxtils/time_parser"
13
+ require_relative "binxtils/railtie" if defined?(Rails::Railtie)
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "shellwords"
4
+
5
+ namespace :binxtils do
6
+ desc "Count non-whitespace characters (excluding comments). Pass paths as args or defaults to app, bin, config, lib"
7
+ task :char_count do
8
+ file_extensions = %w[.rb .erb .haml .html .js .css .scss .yml .yaml .json .md].freeze
9
+
10
+ paths = ARGV.drop(1).reject { |arg| arg.start_with?("-") }
11
+ paths = %w[app bin config lib] if paths.empty?
12
+
13
+ files = `git ls-files #{paths.shelljoin}`.split("\n")
14
+ .select { |file| file_extensions.include?(File.extname(file)) }
15
+
16
+ total_chars = files.sum do |file|
17
+ next 0 unless File.exist?(file)
18
+
19
+ content = File.read(file)
20
+ content_without_comments = case File.extname(file)
21
+ when ".rb", ".yml", ".yaml"
22
+ content.gsub(/#.*$/, "")
23
+ when ".erb", ".haml", ".html"
24
+ content.gsub(/#.*$/, "").gsub(/<!--.*?-->/m, "")
25
+ when ".js", ".css", ".scss"
26
+ content.gsub(%r{//.*$}, "").gsub(%r{/\*.*?\*/}m, "")
27
+ when ".md"
28
+ content.gsub(/<!--.*?-->/m, "")
29
+ else
30
+ content
31
+ end
32
+ content_without_comments.gsub(/\s/, "").length
33
+ end
34
+
35
+ puts total_chars
36
+
37
+ # Prevent rake from interpreting path args as task names
38
+ paths.each { |path| task(path.to_sym) {} }
39
+ end
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binxtils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bike Index
@@ -89,8 +89,11 @@ files:
89
89
  - README.md
90
90
  - lib/binxtils.rb
91
91
  - lib/binxtils/input_normalizer.rb
92
+ - lib/binxtils/railtie.rb
92
93
  - lib/binxtils/time_parser.rb
93
94
  - lib/binxtils/time_zone_parser.rb
95
+ - lib/binxtils/version.rb
96
+ - lib/tasks/char_count.rake
94
97
  homepage: https://github.com/bikeindex/binxtils
95
98
  licenses:
96
99
  - MIT