prick-inflector 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +10 -0
- data/README.md +31 -0
- data/Rakefile +8 -0
- data/lib/prick-inflector/version.rb +7 -0
- data/lib/prick-inflector.rb +58 -0
- data/sig/prick_inflector.rbs +4 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7a76c1380f25d21d7189a53e9e9411eea1bd101051e4da60935f37032ffa461b
|
4
|
+
data.tar.gz: 53045c403e00bae01cb58525a8f2900d8b8c5a87000255d5cb45ed0ddc4c51ff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f67136b4fbcb6570177d4941d850002468486d7eb0ea0606bc6f392dbb02f68c6311d3cfc5a5553c05e42c48ee77a1996841300250a15b2f4919c7733dbf0d5c
|
7
|
+
data.tar.gz: 256faee2e43fed297d413feb2edc677f039f58c69f95fd19c16b3d9966692b6d5696cc8266b70ef612bbebbc9df0e3727326869666ad787e24df45d9df9b742f
|
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-3.1.2
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Prick::Inflector
|
2
|
+
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/prick_inflector`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
14
|
+
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
+
|
17
|
+
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
26
|
+
|
27
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/prick_inflector.
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dry-inflector"
|
4
|
+
|
5
|
+
module Prick; end
|
6
|
+
|
7
|
+
require_relative "prick-inflector/version"
|
8
|
+
|
9
|
+
module Prick::Inflector
|
10
|
+
class Error < StandardError; end
|
11
|
+
|
12
|
+
def self.pluralize(word)
|
13
|
+
return word if plural? word
|
14
|
+
result = @@inflector.pluralize(word)
|
15
|
+
if result == word
|
16
|
+
word =~ /s$/ ? "#{word}es" : "#{word}s"
|
17
|
+
else
|
18
|
+
result
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Note that DryInflector::singularize handles the special PgGraph
|
23
|
+
# pluralization rules by default
|
24
|
+
def self.singularize(word)
|
25
|
+
if word =~ /^(.*s)es$/ && pluralize($1) == word
|
26
|
+
$1
|
27
|
+
else
|
28
|
+
@@inflector.singularize(word)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# #plural? is defined using #singularize because #pluralize would cause
|
33
|
+
# endless recursion
|
34
|
+
def self.plural?(word)
|
35
|
+
singularize(word) != word
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.singular?(word)
|
39
|
+
singularize(word) == word
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
@@inflector = Dry::Inflector.new
|
44
|
+
end
|
45
|
+
|
46
|
+
module String::Prick; end
|
47
|
+
|
48
|
+
module String::Prick::Inflector
|
49
|
+
class Error < StandardError; end
|
50
|
+
|
51
|
+
refine String do
|
52
|
+
def pluralize = Prick::Inflector.pluralize(self)
|
53
|
+
def singularize = Prick::Inflector.singularize(self)
|
54
|
+
def plural? = Prick::Inflector.plural?(self)
|
55
|
+
def singular? = Prick::Inflector.singular?(self)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prick-inflector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Claus Rasmussen
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dry-inflector
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Gem prick-inflector
|
28
|
+
email:
|
29
|
+
- claus.l.rasmussen@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".rspec"
|
35
|
+
- ".ruby-version"
|
36
|
+
- Gemfile
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- lib/prick-inflector.rb
|
40
|
+
- lib/prick-inflector/version.rb
|
41
|
+
- sig/prick_inflector.rbs
|
42
|
+
homepage: http://www.nowhere.com/
|
43
|
+
licenses: []
|
44
|
+
metadata:
|
45
|
+
homepage_uri: http://www.nowhere.com/
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.6.0
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubygems_version: 3.3.7
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: Gem prick-inflector
|
65
|
+
test_files: []
|