tagify_string 0.0.1
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.
- data/.gitignore +18 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/tagify_string/lib/core_ext.rb +16 -0
- data/lib/tagify_string/version.rb +3 -0
- data/lib/tagify_string.rb +5 -0
- data/spec/models/string_spec.rb +60 -0
- data/spec/spec_helper.rb +3 -0
- data/tagify_string.gemspec +26 -0
- metadata +128 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3-p0@tagify_string --create --install
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Ray Parker
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# TagifyString
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'tagify_string'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install tagify_string
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "active_support/all"
|
2
|
+
|
3
|
+
# Add tagify methods to string
|
4
|
+
String.class_eval do
|
5
|
+
def tagify(options = {})
|
6
|
+
default_options = {:upcase => true}
|
7
|
+
opts = default_options.merge(options)
|
8
|
+
|
9
|
+
output = self.parameterize
|
10
|
+
opts[:upcase] ? output.upcase : output.downcase
|
11
|
+
end
|
12
|
+
|
13
|
+
def tagify!(options = {})
|
14
|
+
replace self.tagify(options)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This allows using extended characters in the file
|
3
|
+
|
4
|
+
require File.expand_path("spec/spec_helper")
|
5
|
+
|
6
|
+
describe "String" do
|
7
|
+
it "capitalizes a string" do
|
8
|
+
"aB".tagify.should eq "AB"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "removes commas" do
|
12
|
+
",a,B,".tagify.should eq "A-B"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "removes dots" do
|
16
|
+
".a.B.".tagify.should eq "A-B"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "replaces spaces with dashes" do
|
20
|
+
"a b c".tagify.should eq "A-B-C"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "squishes" do
|
24
|
+
" a b c ".tagify.should eq "A-B-C"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "gracefully handles an empty string" do
|
28
|
+
"".tagify.should eq ""
|
29
|
+
end
|
30
|
+
|
31
|
+
it "ASCII-ifies extended characters" do
|
32
|
+
"àáâãäåÇÈÉÊËÌ".tagify.should eq "AAAAAACEEEEI"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "parties like it's 1999" do
|
36
|
+
" +a- .,.,, . &&()@, ##b . . c#-d ".tagify.should eq "A-B-C-D"
|
37
|
+
end
|
38
|
+
|
39
|
+
context "up case and down case" do
|
40
|
+
it "defaults to upcase" do
|
41
|
+
"a".tagify.should eq "A"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "recognizes downcase option" do
|
45
|
+
"A".tagify(:upcase => false).should eq "a"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with a bang" do
|
50
|
+
it "changes the value of the string" do
|
51
|
+
s = "a,b".tagify!
|
52
|
+
s.should eq "A-B"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "changes the value of the string with options" do
|
56
|
+
s = "a,b".tagify!(:upcase => false)
|
57
|
+
s.should eq "a-b"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tagify_string/version'
|
5
|
+
|
6
|
+
#noinspection RubyLiteralArrayInspection
|
7
|
+
|
8
|
+
Gem::Specification.new do |gem|
|
9
|
+
gem.name = "tagify_string"
|
10
|
+
gem.version = TagifyString::VERSION
|
11
|
+
gem.authors = ["Ray Parker"]
|
12
|
+
gem.email = ["rayparkerbassplayer@gmail.com"]
|
13
|
+
gem.description = %q{Adds 'tagify' and 'tagify!' to the Ruby string class. This is pretty much 'parameterize', but upper case by default.}
|
14
|
+
gem.summary = %q{This is reasonably trivial functionality being split off into a gem for the purpose of consistency throughout a number of Shermans applications. This give Shermans the ability to take any string and 'tagify' it so that it is a predictable and typeable (in the keyboard sense) string for writing custom queries and reports on the SailThru web site.}
|
15
|
+
gem.homepage = ""
|
16
|
+
|
17
|
+
gem.add_development_dependency "rspec"
|
18
|
+
gem.add_development_dependency "rake"
|
19
|
+
gem.add_development_dependency "i18n"
|
20
|
+
gem.add_development_dependency "active_support"
|
21
|
+
|
22
|
+
gem.files = `git ls-files`.split($/)
|
23
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
24
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
25
|
+
gem.require_paths = ["lib"]
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tagify_string
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ray Parker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: i18n
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: active_support
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Adds 'tagify' and 'tagify!' to the Ruby string class. This is pretty
|
79
|
+
much 'parameterize', but upper case by default.
|
80
|
+
email:
|
81
|
+
- rayparkerbassplayer@gmail.com
|
82
|
+
executables: []
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- .gitignore
|
87
|
+
- .rvmrc
|
88
|
+
- Gemfile
|
89
|
+
- LICENSE.txt
|
90
|
+
- README.md
|
91
|
+
- Rakefile
|
92
|
+
- lib/tagify_string.rb
|
93
|
+
- lib/tagify_string/lib/core_ext.rb
|
94
|
+
- lib/tagify_string/version.rb
|
95
|
+
- spec/models/string_spec.rb
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
- tagify_string.gemspec
|
98
|
+
homepage: ''
|
99
|
+
licenses: []
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 1.8.24
|
119
|
+
signing_key:
|
120
|
+
specification_version: 3
|
121
|
+
summary: This is reasonably trivial functionality being split off into a gem for the
|
122
|
+
purpose of consistency throughout a number of Shermans applications. This give
|
123
|
+
Shermans the ability to take any string and 'tagify' it so that it is a predictable
|
124
|
+
and typeable (in the keyboard sense) string for writing custom queries and reports
|
125
|
+
on the SailThru web site.
|
126
|
+
test_files:
|
127
|
+
- spec/models/string_spec.rb
|
128
|
+
- spec/spec_helper.rb
|