inflexion 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/.gitignore +3 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/README.md +42 -0
- data/Rakefile +6 -0
- data/inflexion.gemspec +20 -0
- data/lib/inflexion.rb +6 -0
- data/lib/inflexion/methods.rb +24 -0
- data/lib/inflexion/patch.rb +28 -0
- data/lib/inflexion/patches.yml +2 -0
- data/lib/inflexion/version.rb +3 -0
- data/spec/inflexion_spec.rb +24 -0
- data/spec/spec_helper.rb +3 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 28967be1474a8ecd82fd7ec0ea36670bc7c5614e
|
4
|
+
data.tar.gz: 80ced13ea8fa1353b0c9857a1cacd92c2904fc4d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aec22cdd5a8068beca382cb8c996e4004452a77f0594e29f39942fbc0c9655a4bbfbdbcac803ace80c1760c7381194bf44f34b9f3945c34d77d354548c6b1bf3
|
7
|
+
data.tar.gz: d4e0a891e988be4c568746173d906028e7b7dc10302e38be5080502abbf0359bc278ec65b6dba630edd9c62020861f22ad8b7f49b4ed5a0b30f20761a7266839
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Inflexion
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/kami-zh/inflexion.svg)](https://travis-ci.org/kami-zh/inflexion)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/inflexion.svg)](http://badge.fury.io/rb/inflexion)
|
5
|
+
|
6
|
+
Inflexion define new methods on the String class to transform names for different purposes.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'inflexion'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install inflexion
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Once you include `inflextion`, you can use `#pastize`, `#peopleize` and `#progressize` methods.
|
27
|
+
|
28
|
+
Examples:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
'follow'.pastize #=> "followed"
|
32
|
+
'follow'.peopleize #=> "followers"
|
33
|
+
'follow'.progressize #=> "following"
|
34
|
+
|
35
|
+
'like'.pastize #=> "liked"
|
36
|
+
'like'.peopleize #=> "likers"
|
37
|
+
'like'.progressize #=> "liking"
|
38
|
+
```
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kami-zh/inflexion.
|
data/Rakefile
ADDED
data/inflexion.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'inflexion/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'inflexion'
|
8
|
+
s.version = Inflexion::VERSION
|
9
|
+
s.authors = 'kami'
|
10
|
+
s.email = 'hiroki.zenigami@gmail.com'
|
11
|
+
s.summary = 'Inflexion define new methods on the String class to transform names for different purposes.'
|
12
|
+
s.description = 'Inflexion define new methods on the String class to transform names for different purposes.'
|
13
|
+
s.homepage = 'https://github.com/kami-zh/inflexion'
|
14
|
+
s.files = `git ls-files -z`.split("\x0")
|
15
|
+
|
16
|
+
s.add_dependency 'verbs'
|
17
|
+
s.add_development_dependency 'bundler', '~> 1.12'
|
18
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
19
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
20
|
+
end
|
data/lib/inflexion.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'verbs'
|
2
|
+
|
3
|
+
module Inflexion
|
4
|
+
module Methods
|
5
|
+
def pastize
|
6
|
+
self.verb.conjugate(tense: :past).split(' ').last
|
7
|
+
end
|
8
|
+
|
9
|
+
def peopleize
|
10
|
+
str = (self.last == 'e') ? self.chop : self
|
11
|
+
str + 'ers'
|
12
|
+
end
|
13
|
+
|
14
|
+
def progressize
|
15
|
+
patch = Inflexion::Patch.new(:progressize, self)
|
16
|
+
|
17
|
+
if patch.exists?
|
18
|
+
patch.to_s
|
19
|
+
else
|
20
|
+
self.verb.conjugate(aspect: :progressive).split(' ').last
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Inflexion
|
4
|
+
class Patch
|
5
|
+
def initialize(key, str)
|
6
|
+
@key = key
|
7
|
+
@str = str
|
8
|
+
end
|
9
|
+
|
10
|
+
def exists?
|
11
|
+
patches[@key].key?(@str)
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
patches[@key][@str]
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def patches
|
21
|
+
@patches ||= YAML.load_file(patches_path)
|
22
|
+
end
|
23
|
+
|
24
|
+
def patches_path
|
25
|
+
File.expand_path('../patches.yml', __FILE__)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Inflexion do
|
4
|
+
describe '#pastize' do
|
5
|
+
it 'transforms to past' do
|
6
|
+
expect('follow'.pastize).to eq('followed')
|
7
|
+
expect('like'.pastize).to eq('liked')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#peopleize' do
|
12
|
+
it 'transforms to people' do
|
13
|
+
expect('follow'.peopleize).to eq('followers')
|
14
|
+
expect('like'.peopleize).to eq('likers')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#progressize' do
|
19
|
+
it 'transforms to progress' do
|
20
|
+
expect('follow'.progressize).to eq('following')
|
21
|
+
expect('like'.progressize).to eq('liking')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: inflexion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kami
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: verbs
|
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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Inflexion define new methods on the String class to transform names for
|
70
|
+
different purposes.
|
71
|
+
email: hiroki.zenigami@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- inflexion.gemspec
|
83
|
+
- lib/inflexion.rb
|
84
|
+
- lib/inflexion/methods.rb
|
85
|
+
- lib/inflexion/patch.rb
|
86
|
+
- lib/inflexion/patches.yml
|
87
|
+
- lib/inflexion/version.rb
|
88
|
+
- spec/inflexion_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
homepage: https://github.com/kami-zh/inflexion
|
91
|
+
licenses: []
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.5.1
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Inflexion define new methods on the String class to transform names for different
|
113
|
+
purposes.
|
114
|
+
test_files: []
|