hiroeorz-html-extended-classes 0.1.2
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/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +20 -0
- data/Rakefile +48 -0
- data/VERSION.yml +4 -0
- data/html-extended-classes.gemspec +50 -0
- data/lib/html-extended-classes.rb +3 -0
- data/lib/html-extended-classes/ext-nil.rb +15 -0
- data/lib/html-extended-classes/ext-object.rb +5 -0
- data/lib/html-extended-classes/ext-string.rb +26 -0
- data/spec/html-extended-classes_spec.rb +34 -0
- data/spec/spec_helper.rb +9 -0
- metadata +67 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 hiroeorz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
= html-extended-classes
|
2
|
+
|
3
|
+
* http://github.com/hiroeorz/rspec-w3c-matchers/tree/master
|
4
|
+
* mailto:hiroeorz@gmail.com
|
5
|
+
|
6
|
+
|
7
|
+
== DESCRIPTION:
|
8
|
+
html-extended-classes is extended base classes for developping web application.
|
9
|
+
|
10
|
+
== SYNOPSIS:
|
11
|
+
require "html-extended-classes"
|
12
|
+
|
13
|
+
"abcedfg".to_short_name(3) #=> "abc..."
|
14
|
+
"helloWorld".to_under_score#=> "hello_world"
|
15
|
+
|
16
|
+
etc...
|
17
|
+
|
18
|
+
== Copyright
|
19
|
+
|
20
|
+
Copyright (c) 2009 hiroeorz. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "html-extended-classes"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "hiroe.orz@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/hiroeorz/html-extended-classes"
|
11
|
+
gem.authors = ["hiroeorz"]
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
end
|
14
|
+
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'spec/rake/spectask'
|
20
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
21
|
+
spec.libs << 'lib' << 'spec'
|
22
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
23
|
+
end
|
24
|
+
|
25
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
26
|
+
spec.libs << 'lib' << 'spec'
|
27
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
28
|
+
spec.rcov = true
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
task :default => :spec
|
33
|
+
|
34
|
+
require 'rake/rdoctask'
|
35
|
+
Rake::RDocTask.new do |rdoc|
|
36
|
+
if File.exist?('VERSION.yml')
|
37
|
+
config = YAML.load(File.read('VERSION.yml'))
|
38
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
39
|
+
else
|
40
|
+
version = ""
|
41
|
+
end
|
42
|
+
|
43
|
+
rdoc.rdoc_dir = 'rdoc'
|
44
|
+
rdoc.title = "html-extended-classes #{version}"
|
45
|
+
rdoc.rdoc_files.include('README*')
|
46
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
+
end
|
48
|
+
|
data/VERSION.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{html-extended-classes}
|
5
|
+
s.version = "0.1.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["hiroeorz"]
|
9
|
+
s.date = %q{2009-06-06}
|
10
|
+
s.email = %q{hiroe.orz@gmail.com}
|
11
|
+
s.extra_rdoc_files = [
|
12
|
+
"LICENSE",
|
13
|
+
"README.rdoc"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".document",
|
17
|
+
".gitignore",
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION.yml",
|
22
|
+
"html-extended-classes.gemspec",
|
23
|
+
"lib/html-extended-classes.rb",
|
24
|
+
"lib/html-extended-classes/ext-nil.rb",
|
25
|
+
"lib/html-extended-classes/ext-object.rb",
|
26
|
+
"lib/html-extended-classes/ext-string.rb",
|
27
|
+
"spec/html-extended-classes_spec.rb",
|
28
|
+
"spec/spec_helper.rb"
|
29
|
+
]
|
30
|
+
s.has_rdoc = true
|
31
|
+
s.homepage = %q{http://github.com/hiroeorz/html-extended-classes}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.1}
|
35
|
+
s.summary = %q{TODO}
|
36
|
+
s.test_files = [
|
37
|
+
"spec/html-extended-classes_spec.rb",
|
38
|
+
"spec/spec_helper.rb"
|
39
|
+
]
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
+
s.specification_version = 2
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
46
|
+
else
|
47
|
+
end
|
48
|
+
else
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "jcode"
|
2
|
+
|
3
|
+
class String
|
4
|
+
def to_short_name(name_length = 20, continue_string = "...")
|
5
|
+
if self.jlength <= name_length
|
6
|
+
return self.dup
|
7
|
+
end
|
8
|
+
|
9
|
+
new_string = ""
|
10
|
+
|
11
|
+
self.each_char do |c|
|
12
|
+
new_string << c
|
13
|
+
|
14
|
+
break if new_string.jlength >= name_length
|
15
|
+
end
|
16
|
+
|
17
|
+
return new_string << continue_string
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_under_score
|
21
|
+
self.
|
22
|
+
gsub(/^[A-Z]+/) {|e| e.downcase}.
|
23
|
+
gsub(/[a-z][A-Z]+/) {|e| e[0, 1] + "_" + e[1..-1].downcase}
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
4
|
+
|
5
|
+
describe "HtmlExtendedClasses" do
|
6
|
+
|
7
|
+
it "Sting should return under score string" do
|
8
|
+
"hello_world".to_under_score.should == "hello_world"
|
9
|
+
"Helloworld".to_under_score.should == "helloworld"
|
10
|
+
|
11
|
+
"HelloWorld".to_under_score.should == "hello_world"
|
12
|
+
"HELLoWORLD".to_under_score.should == "hello_world"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "String should return short name" do
|
16
|
+
"abcdefghijklmn".to_short_name(3).should == "abc..."
|
17
|
+
"あいうえお".to_short_name(3).should == "あいう..."
|
18
|
+
"あaいbうcえdおe".to_short_name(6).should == "あaいbうc..."
|
19
|
+
"あaいbうcえdおe".to_short_name(3).should == "あaい..."
|
20
|
+
end
|
21
|
+
|
22
|
+
it "NILClass should return id == -1" do
|
23
|
+
nil.id.should == -1
|
24
|
+
end
|
25
|
+
|
26
|
+
it "NILClass should return empty string called to_short_name" do
|
27
|
+
nil.to_short_name(5).should == ""
|
28
|
+
end
|
29
|
+
|
30
|
+
it "NILClass should return empty string called strftime" do
|
31
|
+
nil.strftime("%Y%m%d").should == ""
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hiroeorz-html-extended-classes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hiroeorz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-06 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: hiroe.orz@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .document
|
27
|
+
- .gitignore
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- VERSION.yml
|
32
|
+
- html-extended-classes.gemspec
|
33
|
+
- lib/html-extended-classes.rb
|
34
|
+
- lib/html-extended-classes/ext-nil.rb
|
35
|
+
- lib/html-extended-classes/ext-object.rb
|
36
|
+
- lib/html-extended-classes/ext-string.rb
|
37
|
+
- spec/html-extended-classes_spec.rb
|
38
|
+
- spec/spec_helper.rb
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://github.com/hiroeorz/html-extended-classes
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --charset=UTF-8
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.2.0
|
62
|
+
signing_key:
|
63
|
+
specification_version: 2
|
64
|
+
summary: TODO
|
65
|
+
test_files:
|
66
|
+
- spec/html-extended-classes_spec.rb
|
67
|
+
- spec/spec_helper.rb
|