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 +4 -4
- data/lib/binxtils/railtie.rb +9 -0
- data/lib/binxtils/version.rb +5 -0
- data/lib/binxtils.rb +1 -0
- data/lib/tasks/char_count.rake +40 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1595e2d8526fd86fa68cd648e318960c951a046c7a5401bb3819a01f91f9d915
|
|
4
|
+
data.tar.gz: a57ad2f943c81ccbc8245302639805b8ffa36529b8737871a5afdd143c162462
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a7e95c3ad3df8c0a64ea582344c40033407e49e4844284b964bc21159b1933bfe121f1848b9c8f53913c496140c4a174af847d113527a63f8c1302b9f5040788
|
|
7
|
+
data.tar.gz: 2cdd46b2ea2b0f9c45aa7d2432f7296210d481405d0154edea6ad1d9f3d18604059f27751225b11d73988dc9a0bc57c68a2db48f6e57e9a8a5b962faf5678868
|
data/lib/binxtils.rb
CHANGED
|
@@ -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.
|
|
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
|