string-cases 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +42 -4
- data/README.md +59 -0
- data/VERSION +1 -1
- data/lib/string-cases.rb +26 -2
- data/shippable.yml +9 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/string-cases_spec.rb +25 -5
- data/string-cases.gemspec +62 -0
- metadata +35 -46
- data/README.rdoc +0 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b3da4f52fcaeffa940953245d9ed5bec1cdce878
|
4
|
+
data.tar.gz: f12d4fddecb75fed22442c1c00a5715d47dfe374
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50678e9a694411a48ce914f665f7fca0d1be985c81fd69fcdb243e5bf565cef8fb397adb44445fdadb0db3b14eb321324d0db638bf7e89c6e51c1354af9f933b
|
7
|
+
data.tar.gz: 4b23c24b81354e949d87cc591780471de877b8fe4d5c24205c70b1a93661af60ccd9a9b8edfc5e5f314798ea486aae039b3ac446242e13a19efafa65905103ea
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,47 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
addressable (2.3.7)
|
5
|
+
builder (3.2.2)
|
6
|
+
codeclimate-test-reporter (0.4.6)
|
7
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
4
8
|
diff-lcs (1.1.3)
|
5
|
-
|
6
|
-
|
9
|
+
docile (1.1.5)
|
10
|
+
faraday (0.8.9)
|
11
|
+
multipart-post (~> 1.2.0)
|
12
|
+
git (1.2.9.1)
|
13
|
+
github_api (0.10.1)
|
14
|
+
addressable
|
15
|
+
faraday (~> 0.8.1)
|
16
|
+
hashie (>= 1.2)
|
17
|
+
multi_json (~> 1.4)
|
18
|
+
nokogiri (~> 1.5.2)
|
19
|
+
oauth2
|
20
|
+
hashie (3.4.0)
|
21
|
+
highline (1.7.1)
|
22
|
+
jeweler (1.8.8)
|
23
|
+
builder
|
7
24
|
bundler (~> 1.0)
|
8
25
|
git (>= 1.2.5)
|
26
|
+
github_api (= 0.10.1)
|
27
|
+
highline (>= 1.6.15)
|
28
|
+
nokogiri (= 1.5.10)
|
9
29
|
rake
|
10
30
|
rdoc
|
11
31
|
json (1.8.0)
|
12
|
-
|
32
|
+
jwt (1.3.0)
|
33
|
+
multi_json (1.11.0)
|
34
|
+
multi_xml (0.5.5)
|
35
|
+
multipart-post (1.2.0)
|
36
|
+
nokogiri (1.5.10)
|
37
|
+
oauth2 (1.0.0)
|
38
|
+
faraday (>= 0.8, < 0.10)
|
39
|
+
jwt (~> 1.0)
|
40
|
+
multi_json (~> 1.3)
|
41
|
+
multi_xml (~> 0.5)
|
42
|
+
rack (~> 1.2)
|
43
|
+
rack (1.6.0)
|
44
|
+
rake (10.4.2)
|
13
45
|
rdoc (3.12.2)
|
14
46
|
json (~> 1.4)
|
15
47
|
rspec (2.8.0)
|
@@ -20,12 +52,18 @@ GEM
|
|
20
52
|
rspec-expectations (2.8.0)
|
21
53
|
diff-lcs (~> 1.1.2)
|
22
54
|
rspec-mocks (2.8.0)
|
55
|
+
simplecov (0.9.2)
|
56
|
+
docile (~> 1.1.0)
|
57
|
+
multi_json (~> 1.0)
|
58
|
+
simplecov-html (~> 0.9.0)
|
59
|
+
simplecov-html (0.9.0)
|
23
60
|
|
24
61
|
PLATFORMS
|
25
62
|
ruby
|
26
63
|
|
27
64
|
DEPENDENCIES
|
28
65
|
bundler (>= 1.0.0)
|
29
|
-
|
66
|
+
codeclimate-test-reporter
|
67
|
+
jeweler (~> 1.8.8)
|
30
68
|
rdoc (~> 3.12)
|
31
69
|
rspec (~> 2.8.0)
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
[![Build Status](https://api.shippable.com/projects/540e7b9e3479c5ea8f9ec25a/badge?branchName=master)](https://app.shippable.com/projects/540e7b9e3479c5ea8f9ec25a/builds/latest)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/kaspernj/string-cases/badges/gpa.svg)](https://codeclimate.com/github/kaspernj/string-cases)
|
3
|
+
[![Test Coverage](https://codeclimate.com/github/kaspernj/string-cases/badges/coverage.svg)](https://codeclimate.com/github/kaspernj/string-cases)
|
4
|
+
|
5
|
+
# StringCases
|
6
|
+
|
7
|
+
Various kind of string-handeling for Ruby.
|
8
|
+
|
9
|
+
## Install
|
10
|
+
|
11
|
+
Add to your Gemfile and bundle:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem "string-cases"
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### Camel to snake case
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
StringCases.camel_to_snake("UserPictures") #=> "user_pictures"
|
23
|
+
```
|
24
|
+
|
25
|
+
### Snake to camel case
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
StringCases.snake_to_camel("user_pictures") #=> "UserPictures"
|
29
|
+
```
|
30
|
+
|
31
|
+
### Pluralize
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
StringCases.pluralize("user") #=> "users"
|
35
|
+
StringCases.pluralize("category") #=> "categories"
|
36
|
+
```
|
37
|
+
|
38
|
+
### Singularize
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
StringCases.singularize("users") #=> "user"
|
42
|
+
StringCases.singularize("categories") #=> "category"
|
43
|
+
```
|
44
|
+
|
45
|
+
## Contributing to string-cases
|
46
|
+
|
47
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
48
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
49
|
+
* Fork the project.
|
50
|
+
* Start a feature/bugfix branch.
|
51
|
+
* Commit and push until you are happy with your contribution.
|
52
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
53
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
54
|
+
|
55
|
+
## Copyright
|
56
|
+
|
57
|
+
Copyright (c) 2013 kaspernj. See LICENSE.txt for
|
58
|
+
further details.
|
59
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
data/lib/string-cases.rb
CHANGED
@@ -2,8 +2,32 @@ class StringCases
|
|
2
2
|
def self.snake_to_camel(str)
|
3
3
|
return str.to_s.split("_").map{|w| w.capitalize }.join("")
|
4
4
|
end
|
5
|
-
|
5
|
+
|
6
6
|
def self.camel_to_snake(str)
|
7
7
|
return str.to_s.gsub(/(.)([A-Z])/,'\1_\2').downcase
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
|
+
def self.pluralize(str)
|
11
|
+
str = "#{str}"
|
12
|
+
|
13
|
+
if str.end_with?("y")
|
14
|
+
str = str.gsub(/y\Z/, "ies")
|
15
|
+
else
|
16
|
+
str << "s"
|
17
|
+
end
|
18
|
+
|
19
|
+
return str
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.singularize(str)
|
23
|
+
str = "#{str}"
|
24
|
+
|
25
|
+
if str.end_with?("ies")
|
26
|
+
str = str.gsub(/ies\Z/, "y")
|
27
|
+
else
|
28
|
+
str = str.gsub(/s\Z/, "")
|
29
|
+
end
|
30
|
+
|
31
|
+
return str
|
32
|
+
end
|
33
|
+
end
|
data/shippable.yml
ADDED
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
|
1
4
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
6
|
require 'rspec'
|
@@ -8,5 +11,4 @@ require 'string-cases'
|
|
8
11
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
12
|
|
10
13
|
RSpec.configure do |config|
|
11
|
-
|
12
14
|
end
|
data/spec/string-cases_spec.rb
CHANGED
@@ -1,11 +1,31 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "StringCases" do
|
4
|
-
it "
|
5
|
-
StringCases.camel_to_snake("TestSomethingWee").should
|
4
|
+
it "#camel_to_snake" do
|
5
|
+
StringCases.camel_to_snake("TestSomethingWee").should eq "test_something_wee"
|
6
6
|
end
|
7
|
-
|
8
|
-
it "
|
9
|
-
StringCases.snake_to_camel("test_something_wee").should
|
7
|
+
|
8
|
+
it "#snake_to_camel" do
|
9
|
+
StringCases.snake_to_camel("test_something_wee").should eq "TestSomethingWee"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#pluralize" do
|
13
|
+
it "pluralizes normal words" do
|
14
|
+
StringCases.pluralize("user").should eq "users"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "pluralizes words ending with 'y'" do
|
18
|
+
StringCases.pluralize("category").should eq "categories"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#singularize" do
|
23
|
+
it "singularizes normal words" do
|
24
|
+
StringCases.singularize("users").should eq "user"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "singularizes words ending with 'ies'" do
|
28
|
+
StringCases.singularize("categories").should eq "category"
|
29
|
+
end
|
10
30
|
end
|
11
31
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: string-cases 0.0.1 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "string-cases"
|
9
|
+
s.version = "0.0.1"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["kaspernj"]
|
14
|
+
s.date = "2015-03-18"
|
15
|
+
s.description = "Small gem for converting various string-cases to other cases."
|
16
|
+
s.email = "k@spernj.org"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.md",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"lib/string-cases.rb",
|
31
|
+
"shippable.yml",
|
32
|
+
"spec/spec_helper.rb",
|
33
|
+
"spec/string-cases_spec.rb",
|
34
|
+
"string-cases.gemspec"
|
35
|
+
]
|
36
|
+
s.homepage = "http://github.com/kaspernj/string-cases"
|
37
|
+
s.licenses = ["MIT"]
|
38
|
+
s.rubygems_version = "2.4.0"
|
39
|
+
s.summary = "Small gem for converting various string-cases to other cases."
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 4
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
46
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
47
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
48
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.8"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
51
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
53
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.8"])
|
54
|
+
end
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
57
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
58
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
59
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.8"])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
metadata
CHANGED
@@ -1,125 +1,114 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string-cases
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.0.0
|
4
|
+
version: 0.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- kaspernj
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
16
|
-
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
17
16
|
requirements:
|
18
|
-
- - ~>
|
17
|
+
- - "~>"
|
19
18
|
- !ruby/object:Gem::Version
|
20
19
|
version: 2.8.0
|
21
|
-
name: rspec
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
|
25
|
-
none: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 2.8.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
|
32
|
-
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
33
30
|
requirements:
|
34
|
-
- - ~>
|
31
|
+
- - "~>"
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: '3.12'
|
37
|
-
name: rdoc
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
|
-
|
41
|
-
none: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '3.12'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
48
|
-
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
49
44
|
requirements:
|
50
|
-
- -
|
45
|
+
- - ">="
|
51
46
|
- !ruby/object:Gem::Version
|
52
47
|
version: 1.0.0
|
53
|
-
name: bundler
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
|
-
|
57
|
-
none: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 1.0.0
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
|
-
|
64
|
-
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
65
58
|
requirements:
|
66
|
-
- - ~>
|
59
|
+
- - "~>"
|
67
60
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.8.
|
69
|
-
name: jeweler
|
61
|
+
version: 1.8.8
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
|
-
|
73
|
-
none: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: 1.8.
|
68
|
+
version: 1.8.8
|
78
69
|
description: Small gem for converting various string-cases to other cases.
|
79
70
|
email: k@spernj.org
|
80
71
|
executables: []
|
81
72
|
extensions: []
|
82
73
|
extra_rdoc_files:
|
83
74
|
- LICENSE.txt
|
84
|
-
- README.
|
75
|
+
- README.md
|
85
76
|
files:
|
86
|
-
- .document
|
87
|
-
- .rspec
|
77
|
+
- ".document"
|
78
|
+
- ".rspec"
|
88
79
|
- Gemfile
|
89
80
|
- Gemfile.lock
|
90
81
|
- LICENSE.txt
|
91
|
-
- README.
|
82
|
+
- README.md
|
92
83
|
- Rakefile
|
93
84
|
- VERSION
|
94
85
|
- lib/string-cases.rb
|
86
|
+
- shippable.yml
|
95
87
|
- spec/spec_helper.rb
|
96
88
|
- spec/string-cases_spec.rb
|
89
|
+
- string-cases.gemspec
|
97
90
|
homepage: http://github.com/kaspernj/string-cases
|
98
91
|
licenses:
|
99
92
|
- MIT
|
93
|
+
metadata: {}
|
100
94
|
post_install_message:
|
101
95
|
rdoc_options: []
|
102
96
|
require_paths:
|
103
97
|
- lib
|
104
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
99
|
requirements:
|
107
|
-
- -
|
100
|
+
- - ">="
|
108
101
|
- !ruby/object:Gem::Version
|
109
|
-
segments:
|
110
|
-
- 0
|
111
|
-
hash: -2120914035568412939
|
112
102
|
version: '0'
|
113
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
104
|
requirements:
|
116
|
-
- -
|
105
|
+
- - ">="
|
117
106
|
- !ruby/object:Gem::Version
|
118
107
|
version: '0'
|
119
108
|
requirements: []
|
120
109
|
rubyforge_project:
|
121
|
-
rubygems_version:
|
110
|
+
rubygems_version: 2.4.0
|
122
111
|
signing_key:
|
123
|
-
specification_version:
|
112
|
+
specification_version: 4
|
124
113
|
summary: Small gem for converting various string-cases to other cases.
|
125
114
|
test_files: []
|
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= string-cases
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Contributing to string-cases
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
-
* Fork the project.
|
10
|
-
* Start a feature/bugfix branch.
|
11
|
-
* Commit and push until you are happy with your contribution.
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2013 kaspernj. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|