cwc 1.0.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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/cwc +8 -0
  3. data/lib/cwc.rb +79 -0
  4. metadata +60 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4d721f665f4679032729e440f71f17360d13e5d46eb23a2428964a3bfb134316
4
+ data.tar.gz: f4e3bdd1e465807750e0c9e6e8a6c819a0d47894afa5de837a7cf24406e0b840
5
+ SHA512:
6
+ metadata.gz: 6b608b23230791cf9222f0df7b18a556d10e9746572e4bf15871143d8fb45773212c0bbf547cb40a39fa5b80bb2e7e9367505c29125942fad48eb9dd8d1ede15
7
+ data.tar.gz: ab922b340202d6b93f2f56f95d97990c5ae33ef64f564a36ca6489520e0890f0081b8e732f82a818835a3c3d05d8db2c51083d8a62819be3e0e706d8d5e9c5dd
data/bin/cwc ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # SPDX-FileCopyrightText: 2026 ceriseris@ceriseris.nl
4
+ #
5
+ # SPDX-License-Identifier: AGPL-3.0-or-later
6
+
7
+ require "cwc"
8
+ puts Cwc.main()
data/lib/cwc.rb ADDED
@@ -0,0 +1,79 @@
1
+ # SPDX-FileCopyrightText: 2026 ceriseris@ceriseris.nl
2
+ #
3
+ # SPDX-License-Identifier: AGPL-3.0-or-later
4
+
5
+ # lib/cwc.rb
6
+
7
+ module Cwc
8
+ VERSION= "1.0.0"
9
+ class << self
10
+ require "optparse"
11
+ $options = {}
12
+ parser = OptionParser.new do |p|
13
+ p.banner = "Usage: cwc [options] [file]"
14
+ p.on("-c", "--count-bytes", "Count the ammount of bytes in a file") do |b|
15
+ $options[:bytes] = b
16
+ end
17
+ p.on("-w", "--count-words", "Count the ammount of words in a file") do |w|
18
+ $options[:words] = w
19
+ end
20
+ p.on("-l", "--count-lines", "Count the ammount of lines in a file") do |l|
21
+ $options[:lines] = l
22
+ end
23
+ p.on("-m", "--count-chars", "Count the ammount of characters in a files") do |c|
24
+ $options[:chars] = c
25
+ end
26
+ p.on("-h", "--help") do
27
+ puts parser
28
+ exit
29
+ end
30
+ end
31
+ parser.parse!(into:$options)
32
+
33
+ def countBytes(file)
34
+ return File.size(file)
35
+ end
36
+ def countLines(file)
37
+ return File.readlines(file).size
38
+ end
39
+ def countWords(file)
40
+ return File.read(file).split.size
41
+ end
42
+ def countChars(file)
43
+ return File.read(file).size
44
+ end
45
+
46
+ def main
47
+ o = ""
48
+ file = ARGV[0]
49
+ # if file.length < 1
50
+ # return parser
51
+ # end
52
+
53
+ bytes = countBytes(file)
54
+ words= countWords(file)
55
+ lines= countLines(file)
56
+
57
+ if $options.key?(:bytes)
58
+ number = bytes
59
+ end
60
+ if $options.key?(:words)
61
+ number = words
62
+ end
63
+ if $options.key?(:lines)
64
+ number = lines
65
+ end
66
+ if $options.key?(:chars)
67
+ number = countChars(file)
68
+ end
69
+
70
+ if $options.length < 1
71
+ o = "\t%d\t%d\t%d\t%s" % [lines, words, bytes, file]
72
+ else
73
+ o = "\t%d\t%s" % [number, file]
74
+ end
75
+
76
+ return o
77
+ end
78
+ end
79
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cwc
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ceriseris
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: optparse
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.6'
27
+ description: A simple wordcount alternative written in ruby
28
+ email:
29
+ - Ceriseris@ceriseris.nl
30
+ executables:
31
+ - cwc
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - bin/cwc
36
+ - lib/cwc.rb
37
+ homepage: https://codeberg.org/Ceriseris/Cwc
38
+ licenses:
39
+ - AGPL-3.0-or-later
40
+ metadata: {}
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubygems_version: 3.4.20
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: A Ruby wordcounter
60
+ test_files: []