ruby_words 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/CLAUDE.md +63 -0
- data/README.md +1 -1
- data/lib/ruby_words/version.rb +1 -1
- data/lib/ruby_words.rb +19 -3
- metadata +4 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 39b9665049405ab0b4282ca6b3834735d06baac156c0ea0054480cc10023842e
|
|
4
|
+
data.tar.gz: 8bf024f3ac49c260c6e4c7d88b15b9cc9a7a221526ab189022a215b59d984e21
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ac3d4c5548139c0cb8671cd68d76cb3a00e1ce8d6b1dc8b9fef86dfdc7a20ca5801bc91f0c24d1a3a8ed648b55244ed33a88f406b440b8035c291f1ef2b902f
|
|
7
|
+
data.tar.gz: eacea667fa08297976e96692c0d0b29966410745a42d51cf6752f8f8e728be117b1fb2d3b7963eed079a656f61c9076801daca049caf32dc547b91b6ca7b33f6
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This is a Ruby gem that extracts words from the Ruby language by parsing RBS type signatures. It uses the `rbs` gem to load Ruby's standard library type definitions and extracts method names, splitting them by underscores to create a word list suitable for programming dictionaries (e.g., cspell).
|
|
8
|
+
|
|
9
|
+
## Key Commands
|
|
10
|
+
|
|
11
|
+
### Setup
|
|
12
|
+
- `bin/setup` - Install dependencies and prepare the development environment
|
|
13
|
+
|
|
14
|
+
### Testing
|
|
15
|
+
- `rake test` - Run the test suite (using Minitest)
|
|
16
|
+
- `rake` - Run default task (tests + linting)
|
|
17
|
+
|
|
18
|
+
### Linting
|
|
19
|
+
- `rake standard` - Run Standard Ruby linter (auto-formatter based on RuboCop)
|
|
20
|
+
- `bundle exec standardrb --fix` - Auto-fix linting issues
|
|
21
|
+
|
|
22
|
+
### Running the Tool
|
|
23
|
+
- `bundle exec exe/ruby_words` - Run the CLI locally (outputs a sorted list of words to stdout)
|
|
24
|
+
- `bin/console` - Start an interactive console for experimentation
|
|
25
|
+
|
|
26
|
+
### Gem Management
|
|
27
|
+
- `bundle exec rake install` - Install gem locally for testing
|
|
28
|
+
- `bundle exec rake release` - Release a new version (tags, pushes to RubyGems)
|
|
29
|
+
|
|
30
|
+
## Architecture
|
|
31
|
+
|
|
32
|
+
### Core Implementation (`lib/ruby_words.rb`)
|
|
33
|
+
|
|
34
|
+
The main logic is in the `RubyWords::Ruby` class:
|
|
35
|
+
|
|
36
|
+
1. **RBS Loading**: Uses `RBS::EnvironmentLoader` to load all RBS type signatures from Ruby's standard library
|
|
37
|
+
2. **AST Traversal**: Walks through RBS declarations, focusing on class/module declarations
|
|
38
|
+
3. **Method Extraction**: Extracts method names from method definitions
|
|
39
|
+
4. **Word Splitting**: Splits method names by underscores to create individual words (e.g., `to_s` becomes `["to", "s"]`)
|
|
40
|
+
5. **Deduplication**: Returns unique, sorted word list
|
|
41
|
+
|
|
42
|
+
### Executable (`exe/ruby_words`)
|
|
43
|
+
|
|
44
|
+
Simple CLI that instantiates `RubyWords::Ruby`, calls `run` to process all signatures, and outputs the word list.
|
|
45
|
+
|
|
46
|
+
## Code Style
|
|
47
|
+
|
|
48
|
+
- Uses **Standard Ruby** for code formatting and linting (extends RuboCop)
|
|
49
|
+
- Enforces **double quotes** for string literals (see `.rubocop.yml`)
|
|
50
|
+
- Requires Ruby >= 3.0
|
|
51
|
+
- Uses `frozen_string_literal: true` in all Ruby files
|
|
52
|
+
|
|
53
|
+
## Testing
|
|
54
|
+
|
|
55
|
+
- Uses **Minitest** as the testing framework
|
|
56
|
+
- Test files located in `test/`
|
|
57
|
+
- Currently minimal test coverage (only version check)
|
|
58
|
+
|
|
59
|
+
## Type Signatures
|
|
60
|
+
|
|
61
|
+
- RBS type signatures are in `sig/` directory
|
|
62
|
+
- Main signature file: `sig/ruby_words.rbs`
|
|
63
|
+
- The gem itself depends on the `rbs` gem (~> 3.6)
|
data/README.md
CHANGED
data/lib/ruby_words/version.rb
CHANGED
data/lib/ruby_words.rb
CHANGED
|
@@ -22,7 +22,11 @@ module RubyWords
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def all
|
|
25
|
-
@method_names
|
|
25
|
+
@method_names
|
|
26
|
+
.map { |word| word.delete_suffix("?").delete_suffix("!").delete_suffix("=") }
|
|
27
|
+
.select { |word| word.match?(/[a-zA-Z0-9]/) && word.length > 1 }
|
|
28
|
+
.uniq
|
|
29
|
+
.sort
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
private
|
|
@@ -37,12 +41,15 @@ module RubyWords
|
|
|
37
41
|
case declaration
|
|
38
42
|
when RBS::AST::Declarations::Class, RBS::AST::Declarations::Module
|
|
39
43
|
handle_class_or_module_declaration(declaration, pathname)
|
|
40
|
-
else
|
|
41
|
-
# Other kinds not yet handled
|
|
42
44
|
end
|
|
43
45
|
end
|
|
44
46
|
|
|
45
47
|
def handle_class_or_module_declaration(declaration, pathname)
|
|
48
|
+
# Add the class/module name itself, split by :: and CamelCase
|
|
49
|
+
declaration.name.to_s.split("::").each do |part|
|
|
50
|
+
@method_names.append(*split_camel_case(part))
|
|
51
|
+
end
|
|
52
|
+
|
|
46
53
|
declaration.members.each do |member|
|
|
47
54
|
case member
|
|
48
55
|
when RBS::AST::Members::MethodDefinition
|
|
@@ -55,5 +62,14 @@ module RubyWords
|
|
|
55
62
|
name = member.name.name
|
|
56
63
|
@method_names.append(*name.split("_"))
|
|
57
64
|
end
|
|
65
|
+
|
|
66
|
+
def split_camel_case(word)
|
|
67
|
+
# Split CamelCase, handling acronyms like EOF in EOFError
|
|
68
|
+
# Since Ruby class names always start uppercase, we can use a simpler pattern
|
|
69
|
+
# EOFError -> EOF, Error
|
|
70
|
+
# FileTest -> File, Test
|
|
71
|
+
# HTTPSConnection -> HTTPS, Connection
|
|
72
|
+
word.scan(/[A-Z]+(?=[A-Z][a-z]|\b)|[A-Z][a-z]+/)
|
|
73
|
+
end
|
|
58
74
|
end
|
|
59
75
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_words
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Waite
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rbs
|
|
@@ -24,7 +23,6 @@ dependencies:
|
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '3.6'
|
|
27
|
-
description:
|
|
28
26
|
email:
|
|
29
27
|
- 13400+andyw8@users.noreply.github.com
|
|
30
28
|
executables:
|
|
@@ -34,6 +32,7 @@ extra_rdoc_files: []
|
|
|
34
32
|
files:
|
|
35
33
|
- ".rubocop.yml"
|
|
36
34
|
- CHANGELOG.md
|
|
35
|
+
- CLAUDE.md
|
|
37
36
|
- LICENSE.txt
|
|
38
37
|
- README.md
|
|
39
38
|
- Rakefile
|
|
@@ -49,7 +48,6 @@ metadata:
|
|
|
49
48
|
homepage_uri: https://github.com/andyw8/ruby_words
|
|
50
49
|
source_code_uri: https://github.com/andyw8/ruby_words
|
|
51
50
|
changelog_uri: https://github.com/andyw8/ruby-lsp/releases
|
|
52
|
-
post_install_message:
|
|
53
51
|
rdoc_options: []
|
|
54
52
|
require_paths:
|
|
55
53
|
- lib
|
|
@@ -64,8 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
64
62
|
- !ruby/object:Gem::Version
|
|
65
63
|
version: '0'
|
|
66
64
|
requirements: []
|
|
67
|
-
rubygems_version: 3.
|
|
68
|
-
signing_key:
|
|
65
|
+
rubygems_version: 3.6.9
|
|
69
66
|
specification_version: 4
|
|
70
67
|
summary: A list of words from the Ruby programming language
|
|
71
68
|
test_files: []
|