wordgraph 0.1.0 → 0.5.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: 5eec332d565ac8fcf1192d04b99b9d6d313b68a2291dd44ce7532dfeccb42141
4
- data.tar.gz: 2d2f2efa8e4d5747ed81ec6c1fa555df1dcf95e5970102b27c464340ddc50165
3
+ metadata.gz: 8a0039b72e4ecc4059c72c226860382a4c76ce898b170b8db2c0e31c9ae854dc
4
+ data.tar.gz: 05a984e25ff21ddf8620dda415138e8763aeb26f60344eafd9cd9a6d7622a889
5
5
  SHA512:
6
- metadata.gz: d3009ff268b5ca9a58f9b98d82541834b95f885662e8a828c1c4a289109157bd452cbda69edcc3202fc6835607772e6ca0dfaec53cbeb628e567dea01fdc8a64
7
- data.tar.gz: 1e71d6ec4dea81d0cfbd1e1738d25df072810a597408a10ebbc4bfa65fd39121a946229c8fdfe935deeae3d63a8682ae303f624c18d95d65b919cf06ab40113e
6
+ metadata.gz: bb4bba4db23d7bf136e4d2868923a1b7e6ffd3e8e3e80b1e8cccd3cb413b77df3ff671242592774b862b8daa925641a3325fdfddf345b6c66934372b3f8fa6f8
7
+ data.tar.gz: 6f61da0501b80dcd2c799f21da041012533301f1a7f9ac9afd3cf5f96250fba29a153fc72a08b7ffbc393f0a3d93f2b728ad6afe70d9ba55a49689fc358effe9
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/*.rb
2
+ lib/**/*.rb
3
+ -
4
+ CHANGELOG.rdoc
5
+ LICENSE.md
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "wordgraph"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ require "irb"
11
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/wordgraph ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "wordgraph/cli"
5
+
6
+ cli = Wordgraph::CLI.new
7
+ options = cli.parse(ARGV)
data/lib/wordgraph/cli.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "optparse"
4
+ require_relative "core"
4
5
 
5
6
  module Wordgraph
6
7
  class CLI
@@ -10,7 +11,7 @@ module Wordgraph
10
11
 
11
12
  def parse(args)
12
13
  parser = OptionParser.new do |opts|
13
- opts.banner = "Usage: cli.rb [options] ARG..."
14
+ opts.banner = "E.g.: wordgraph [options] ARG..."
14
15
  opts.separator ""
15
16
  opts.separator "Specific options:"
16
17
 
@@ -21,16 +22,19 @@ module Wordgraph
21
22
  opts.on("-h", "--help", "Prints this help") do
22
23
  puts opts
23
24
  puts args
24
- exit
25
25
  end
26
26
  end
27
27
 
28
28
  begin
29
- parser.parse!(args)
29
+ files = parser.parse!(args)
30
+ core = Core.new(files, @options[:verbose])
31
+ core.process
30
32
  rescue OptionParser::InvalidOption => e
31
33
  puts e.message
32
34
  puts parser
33
35
  exit 1
36
+ rescue ArgumentError => e
37
+ puts "Invalid argument: #{e}"
34
38
  end
35
39
 
36
40
  @options
@@ -0,0 +1,32 @@
1
+ module Wordgraph
2
+ class Core
3
+ def initialize(files, verbose=false)
4
+ @files = files
5
+ @verbose = verbose
6
+ end
7
+
8
+ def process
9
+ puts "Processing #{@files}" if @verbose
10
+
11
+ @files.each do |f|
12
+ case f
13
+ when /\.(txt|text)\z/i
14
+ puts "Processing txt file #{f}"
15
+ count = {}
16
+ count.default = 0
17
+ IO.foreach(f) do |line|
18
+ line.split do |word|
19
+ count[word] += 1
20
+ end
21
+ end
22
+ puts count
23
+ puts "Succesfully finished processing"
24
+ when /\.docx\z/i
25
+ raise ArgumentError, "docx not supported yet."
26
+ else
27
+ raise ArgumentError, "File type not supported."
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wordgraph
4
- VERSION = "0.1.0"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/wordgraph.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "wordgraph/version"
4
+ require_relative "wordgraph/cli"
4
5
 
5
6
  module Wordgraph
6
7
  class Error < StandardError; end
data/wordgraph.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ # coding: utf-8
3
+
4
+ lib = File.expand_path("../lib/", __FILE__)
5
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
6
+ require "wordgraph/version"
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "wordgraph"
10
+ spec.version = Wordgraph::VERSION
11
+ spec.licenses = %w(MIT)
12
+ spec.authors = ["marm00"]
13
+ spec.email = [""]
14
+ spec.description = "Wordgraph"
15
+ spec.summary = spec.description
16
+ spec.homepage = "https://github.com/marm00/wordgraph"
17
+
18
+ spec.metadata = {
19
+ "bug_tracker_uri" => "https://github.com/marm00/wordgraph/issues",
20
+ "changelog_uri" => spec.homepage,
21
+ "documentation_uri" => spec.homepage,
22
+ "source_code_uri" => "https://github.com/marm00/wordgraph/tree/main",
23
+ "wiki_uri" => spec.homepage,
24
+ }
25
+
26
+ spec.required_ruby_version = ">= 3.1.0"
27
+
28
+ spec.files = %w(.document wordgraph.gemspec) + Dir["*.md", "bin/*", "lib/**/*.rb", "fixtures/**/*"]
29
+ spec.executables = %w(wordgraph)
30
+ spec.require_paths = %w(lib)
31
+
32
+ spec.add_dependency "optparse", "~> 0.6.0"
33
+ end
metadata CHANGED
@@ -1,32 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordgraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - marm00
8
- bindir: exe
8
+ bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-14 00:00:00.000000000 Z
11
- dependencies: []
12
- executables: []
10
+ date: 2025-01-19 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: optparse
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 0.6.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.6.0
26
+ description: Wordgraph
27
+ email:
28
+ - ''
29
+ executables:
30
+ - wordgraph
13
31
  extensions: []
14
32
  extra_rdoc_files: []
15
33
  files:
16
- - ".rspec"
17
- - ".ruby-version"
18
- - LICENSE
34
+ - ".document"
19
35
  - README.md
20
- - Rakefile
36
+ - bin/console
37
+ - bin/setup
38
+ - bin/wordgraph
21
39
  - lib/wordgraph.rb
22
40
  - lib/wordgraph/cli.rb
41
+ - lib/wordgraph/core.rb
23
42
  - lib/wordgraph/version.rb
24
- - sig/wordgraph.rbs
43
+ - wordgraph.gemspec
25
44
  homepage: https://github.com/marm00/wordgraph
26
- licenses: []
45
+ licenses:
46
+ - MIT
27
47
  metadata:
28
- homepage_uri: https://github.com/marm00/wordgraph
29
- source_code_uri: https://github.com/marm00/wordgraph
48
+ bug_tracker_uri: https://github.com/marm00/wordgraph/issues
49
+ changelog_uri: https://github.com/marm00/wordgraph
50
+ documentation_uri: https://github.com/marm00/wordgraph
51
+ source_code_uri: https://github.com/marm00/wordgraph/tree/main
52
+ wiki_uri: https://github.com/marm00/wordgraph
30
53
  rdoc_options: []
31
54
  require_paths:
32
55
  - lib
@@ -43,5 +66,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
66
  requirements: []
44
67
  rubygems_version: 3.6.2
45
68
  specification_version: 4
46
- summary: Graphs from words.
69
+ summary: Wordgraph
47
70
  test_files: []
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.4.1
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 marm00
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: :spec
data/sig/wordgraph.rbs DELETED
@@ -1,4 +0,0 @@
1
- module Wordgraph
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end