html_tagger 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/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +6 -0
- data/html_tagger.gemspec +21 -0
- data/lib/html_tagger.rb +57 -0
- data/lib/html_tagger/version.rb +3 -0
- data/spec/html_tagger/html_tagger_spec.rb +68 -0
- data/spec/spec_helper.rb +14 -0
- metadata +91 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Craig A. Cook
|
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
|
+
# HtmlTagger
|
2
|
+
|
3
|
+
Several convience methods monkey patched on String to wrap in HTML formatting.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'html_tagger'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install html_tagger
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
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 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/html_tagger.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/html_tagger/version', __FILE__)
|
3
|
+
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ["Craig A. Cook"]
|
7
|
+
gem.email = ["craig.a.cook@gmail.com"]
|
8
|
+
gem.description = %q{OO simple html tagging of text, similar to JS calls}
|
9
|
+
gem.summary = %q{generates HTML tags similar to how it is done in JavaScript}
|
10
|
+
gem.homepage = ""
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = "html_tagger"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = HtmlTagger::VERSION
|
18
|
+
gem.add_development_dependency "rspec-expectations", "2.9.0"
|
19
|
+
gem.add_development_dependency "rspec", "2.9.0"
|
20
|
+
gem.add_development_dependency "rubygems-test"
|
21
|
+
end
|
data/lib/html_tagger.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require "html_tagger/version"
|
2
|
+
|
3
|
+
class String
|
4
|
+
|
5
|
+
def link(linked_to_url)
|
6
|
+
'<a href="'+linked_to_url+'">'+self+"</a>"
|
7
|
+
end
|
8
|
+
|
9
|
+
def bold
|
10
|
+
add_style('font-weight:bold')
|
11
|
+
end
|
12
|
+
|
13
|
+
def color(text_color)
|
14
|
+
"<span color=\""+ text_color + "\">" + self + "</span>"
|
15
|
+
end
|
16
|
+
|
17
|
+
def italics
|
18
|
+
add_style('font-style:italic')
|
19
|
+
end
|
20
|
+
|
21
|
+
def oblique
|
22
|
+
add_style('font-style:oblique')
|
23
|
+
end
|
24
|
+
|
25
|
+
def underscore
|
26
|
+
add_style('text-decoration:underline')
|
27
|
+
end
|
28
|
+
|
29
|
+
def underline
|
30
|
+
underscore
|
31
|
+
end
|
32
|
+
|
33
|
+
def strikeout
|
34
|
+
add_style('text-decoration:line-through')
|
35
|
+
end
|
36
|
+
|
37
|
+
def subscript
|
38
|
+
add_style('font-size:xx-small; vertical-align:bottom')
|
39
|
+
end
|
40
|
+
|
41
|
+
def superscript
|
42
|
+
add_style('font-size:xx-small; vertical-align:top')
|
43
|
+
end
|
44
|
+
|
45
|
+
def add_class(added_class)
|
46
|
+
'<span class="'+ added_class + '">' + self + "</span>"
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def add_style(style)
|
51
|
+
'<span style="' + style + '">' + self + "</span>"
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '../../spec_helper')
|
2
|
+
|
3
|
+
require 'html_tagger'
|
4
|
+
|
5
|
+
describe "HtmlTagger" do
|
6
|
+
|
7
|
+
let(:text) do
|
8
|
+
"Text to Markup"
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
end
|
13
|
+
|
14
|
+
context "HTML String" do
|
15
|
+
|
16
|
+
context "instance methods" do
|
17
|
+
|
18
|
+
it "linkifes self" do
|
19
|
+
text.link('http://localhost:3000/link').should == "<a href=\"http://localhost:3000/link\">#{text}</a>"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "makes self bold" do
|
23
|
+
text.bold.should == "<span style=\"font-weight:bold\">#{text}</span>"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "italicizes self" do
|
27
|
+
text.italics.should == "<span style=\"font-style:italic\">#{text}</span>"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "obliquizes self" do
|
31
|
+
text.oblique.should == "<span style=\"font-style:oblique\">#{text}</span>"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "underlines self" do
|
35
|
+
text.underline.should == "<span style=\"text-decoration:underline\">#{text}</span>"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "colorizes it red" do
|
39
|
+
text.color('red').should == "<span color=\"red\">#{text}</span>"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "adds the class 'foo'" do
|
43
|
+
text.add_class('foo').should == "<span class=\"foo\">#{text}</span>"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "adds a style to bold and italicize" do
|
47
|
+
text.add_style("font-weight:bold; font-style:italic").should == "<span style=\"font-weight:bold; font-style:italic\">#{text}</span>"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "strikes out text" do
|
51
|
+
text.strikeout.should == "<span style=\"text-decoration:line-through\">#{text}</span>"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "makes self subscript" do
|
55
|
+
text.subscript.should == "<span style=\"font-size:xx-small; vertical-align:bottom\">#{text}</span>"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "makes self superscript" do
|
59
|
+
text.superscript.should == "<span style=\"font-size:xx-small; vertical-align:top\">#{text}</span>"
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'rspec'
|
8
|
+
require 'rspec/autorun'
|
9
|
+
require 'html_tagger'
|
10
|
+
|
11
|
+
#RSpec.configure do |config|
|
12
|
+
#
|
13
|
+
#end
|
14
|
+
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: html_tagger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Craig A. Cook
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec-expectations
|
16
|
+
requirement: &73277010 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.9.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *73277010
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &73274010 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.9.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *73274010
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rubygems-test
|
38
|
+
requirement: &73273320 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *73273320
|
47
|
+
description: OO simple html tagging of text, similar to JS calls
|
48
|
+
email:
|
49
|
+
- craig.a.cook@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- html_tagger.gemspec
|
60
|
+
- lib/html_tagger.rb
|
61
|
+
- lib/html_tagger/version.rb
|
62
|
+
- spec/html_tagger/html_tagger_spec.rb
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
homepage: ''
|
65
|
+
licenses: []
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.8.12
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: generates HTML tags similar to how it is done in JavaScript
|
88
|
+
test_files:
|
89
|
+
- spec/html_tagger/html_tagger_spec.rb
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
has_rdoc:
|