trenni-formatters 2.5.0 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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", "~> 2.1"
28
- spec.add_dependency "mapping", "~> 1.1"
29
-
30
- spec.add_development_dependency "bundler", "~> 1.3"
31
- spec.add_development_dependency "rspec", "~> 3.4"
32
- spec.add_development_dependency "rake"
33
- end