trenni-formatters 2.8.1 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trenni/formatters.rb +2 -0
- data/lib/trenni/formatters/formatter.rb +2 -0
- data/lib/trenni/formatters/html/definition_list_form.rb +41 -33
- data/lib/trenni/formatters/html/form_formatter.rb +68 -51
- data/lib/trenni/formatters/html/label_form.rb +148 -0
- data/lib/trenni/formatters/html/option_select.rb +24 -22
- data/lib/trenni/formatters/html/radio_select.rb +18 -16
- data/lib/trenni/formatters/markdown.rb +7 -7
- data/lib/trenni/formatters/relative_time.rb +2 -0
- data/lib/trenni/formatters/truncated_text.rb +2 -0
- data/lib/trenni/formatters/version.rb +3 -1
- metadata +66 -47
- data/.gitignore +0 -17
- data/.rspec +0 -4
- data/.simplecov +0 -9
- data/.travis.yml +0 -8
- data/Gemfile +0 -12
- data/README.md +0 -77
- data/Rakefile +0 -8
- data/spec/trenni/formatters/formatters_spec.rb +0 -57
- data/spec/trenni/formatters/html/form_formatter_spec.rb +0 -186
- data/spec/trenni/formatters/html/option_select_spec.rb +0 -129
- data/spec/trenni/formatters/html/radio_select_spec.rb +0 -49
- data/spec/trenni/formatters/markdown_spec.rb +0 -34
- data/spec/trenni/formatters/relative_time_spec.rb +0 -38
- data/spec/trenni/formatters/truncated_text_spec.rb +0 -32
- data/trenni-formatters.gemspec +0 -33
@@ -1,49 +0,0 @@
|
|
1
|
-
# Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'trenni/formatters'
|
22
|
-
require 'trenni/formatters/html/radio_select'
|
23
|
-
|
24
|
-
module Trenni::Formatters::HTML::RadioSelectSpec
|
25
|
-
class FormFormatter < Trenni::Formatters::Formatter
|
26
|
-
include Trenni::Formatters::HTML::DefinitionListForm
|
27
|
-
|
28
|
-
def select(options = {}, &block)
|
29
|
-
element(Trenni::Formatters::HTML::RadioSelect, options, &block)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe Trenni::Formatters::HTML::RadioSelect do
|
34
|
-
let(:formatter) {FormFormatter.new(:object => double(:bar => 10))}
|
35
|
-
|
36
|
-
it "should list items" do
|
37
|
-
_out = ""
|
38
|
-
|
39
|
-
captured = Trenni::Template.capture do
|
40
|
-
formatter.select :field => :bar do |select|
|
41
|
-
_out << select.item(:title => "A", :value => 0)
|
42
|
-
_out << select.item(:title => "B", :value => 10)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
expect(captured).to be == %Q{<dt>Bar</dt>\n<dd>\n\t<table>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td class="handle"><input type="radio" name="bar" value="0"/></td>\n\t\t\t\t<td class="item">A</td>\n\t\t\t</tr><tr>\n\t\t\t\t<td class="handle"><input type="radio" name="bar" value="10" checked/></td>\n\t\t\t\t<td class="item">B</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</dd>}
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'trenni/formatters/formatter'
|
22
|
-
require 'trenni/formatters/markdown'
|
23
|
-
|
24
|
-
describe Trenni::Formatters::Markdown do
|
25
|
-
subject {Class.new(Trenni::Formatters::Formatter).include(Trenni::Formatters::Markdown).new}
|
26
|
-
|
27
|
-
let(:sample_text) {"# Heading\n\nParagraph\n"}
|
28
|
-
|
29
|
-
it "should format markdown" do
|
30
|
-
result = subject.markdown(sample_text)
|
31
|
-
|
32
|
-
expect(result).to include('<h1>', '<p>')
|
33
|
-
end
|
34
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'trenni/formatters/formatter'
|
22
|
-
require 'trenni/formatters/relative_time'
|
23
|
-
|
24
|
-
describe Trenni::Formatters::RelativeTime do
|
25
|
-
subject {Class.new(Trenni::Formatters::Formatter).include(Trenni::Formatters::RelativeTime).new}
|
26
|
-
|
27
|
-
let(:now) {Time.now}
|
28
|
-
let(:time_this_year) {Time.mktime(now.year, 1, 1)}
|
29
|
-
let(:time_last_year) {Time.mktime(now.year - 1, 1, 1)}
|
30
|
-
|
31
|
-
it "should format without year" do
|
32
|
-
expect(subject.format(time_this_year, current_time: now)).to be == "January 1, 12:00am"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should format with year" do
|
36
|
-
expect(subject.format(time_last_year, current_time: now)).to be == "January 1, 12:00am, #{time_last_year.year}"
|
37
|
-
end
|
38
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'trenni/formatters/formatter'
|
22
|
-
require 'trenni/formatters/truncated_text'
|
23
|
-
|
24
|
-
describe Trenni::Formatters::TruncatedText do
|
25
|
-
subject {Class.new(Trenni::Formatters::Formatter).include(Trenni::Formatters::TruncatedText).new}
|
26
|
-
|
27
|
-
let(:sample_text) {"The quick brown fox jumped over the lazy dog!"}
|
28
|
-
|
29
|
-
it "should truncate text" do
|
30
|
-
expect(subject.truncated_text(sample_text)).to be == "The quick brown fox jumped ..."
|
31
|
-
end
|
32
|
-
end
|
data/trenni-formatters.gemspec
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'trenni/formatters/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "trenni-formatters"
|
8
|
-
spec.version = Trenni::Formatters::VERSION
|
9
|
-
spec.authors = ["Samuel Williams"]
|
10
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
11
|
-
spec.description = <<-EOF
|
12
|
-
Trenni is a templating system, and these formatters assist with the development
|
13
|
-
of typical view and form based web interface. A formatter is a high-level
|
14
|
-
adapter that turns model data into presentation text.
|
15
|
-
|
16
|
-
Formatters are designed to be customised, typically per-project, for specific
|
17
|
-
formatting needs.
|
18
|
-
EOF
|
19
|
-
spec.summary = %q{Formatters for Trenni, to assist with typical views and form based interfaces.}
|
20
|
-
spec.homepage = "https://github.com/ioquatix/trenni-formatters"
|
21
|
-
|
22
|
-
spec.files = `git ls-files`.split($/)
|
23
|
-
spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
24
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
25
|
-
spec.require_paths = ["lib"]
|
26
|
-
|
27
|
-
spec.add_dependency "trenni", "~> 3.4"
|
28
|
-
spec.add_dependency "mapping", "~> 1.1"
|
29
|
-
|
30
|
-
spec.add_development_dependency "bundler"
|
31
|
-
spec.add_development_dependency "rspec", "~> 3.4"
|
32
|
-
spec.add_development_dependency "rake"
|
33
|
-
end
|