polygon 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ {"kind":"json"}
@@ -0,0 +1,4 @@
1
+ ---
2
+ kind: md
3
+ ---
4
+ This is the text
@@ -0,0 +1 @@
1
+ {"kind" => "rb"}
@@ -0,0 +1 @@
1
+ {"kind" => "ruby"}
@@ -0,0 +1,2 @@
1
+ ---
2
+ kind: yaml
@@ -0,0 +1,2 @@
1
+ ---
2
+ kind: yml
@@ -0,0 +1 @@
1
+ This is the text
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Root index.yml
3
+ keywords: [root]
File without changes
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Dir with an index.yml
3
+ keywords: [with_index_yml/index.yml]
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: Say Hello
3
+ keywords: [say-hello]
4
+ ---
5
+ # How to Say Hello to World?
6
+
7
+ This way!
@@ -0,0 +1,4 @@
1
+ ---
2
+ title: Welcome!
3
+ ---
4
+ Welcome to this page!
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'test/unit'
3
+ require 'polygon'
4
+ module Helper
5
+ end
@@ -0,0 +1 @@
1
+ Dir[File.expand_path("../**/test_*.rb", __FILE__)].each{|f| load(f)}
@@ -0,0 +1,45 @@
1
+ require 'helper'
2
+ module Polygon
3
+ class ContentTest < Test::Unit::TestCase
4
+ include Helper
5
+
6
+ def setup
7
+ @root = Path.dir/"../fixtures"
8
+ @loader = ContentLoader.new
9
+ @loader.enable_yaml!(".yml")
10
+ @loader.enable_yaml_front_matter!(".md")
11
+ @content = Content.new(@root, @loader)
12
+ end
13
+
14
+ def assert_entry(entry)
15
+ assert_instance_of Content::Entry, entry
16
+ end
17
+
18
+ def test_initialize
19
+ assert_instance_of Content, Content.new(@root)
20
+ end
21
+
22
+ def test_entry_should_be_a_factory
23
+ entry = @content.entry(@root/"index.yml")
24
+ assert_entry entry
25
+ assert_equal @content, entry.content
26
+ assert_equal @root/"index.yml", entry.path
27
+ end
28
+
29
+ def test_entry_should_serve_relative_paths
30
+ relative = (@root/"index.yml").relative_to(@root)
31
+ assert_entry @content.entry(relative)
32
+ end
33
+
34
+ def test_entry_should_serve_valid_absolute_paths
35
+ assert_entry @content.entry(@root/"index.yml")
36
+ assert_entry @content.entry(@root/:data/"data.yml")
37
+ end
38
+
39
+ def test_entry_should_not_serve_outside_root
40
+ assert_nil @content.entry(Path.home)
41
+ assert_nil @content.entry(@root.parent)
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,39 @@
1
+ require 'helper'
2
+ module Polygon
3
+ class ContentLoaderTest < Test::Unit::TestCase
4
+ include Helper
5
+
6
+ def setup
7
+ @loader = ContentLoader.new
8
+ @loader.enable_all!
9
+ end
10
+
11
+ def test_load
12
+ fixtures = Path.dir/:fixtures/:data
13
+
14
+ assert_equal({"kind" => "yml"}, @loader.load(fixtures/"data.yml"))
15
+ assert_equal({"kind" => "yaml"}, @loader.load(fixtures/"data.yaml"))
16
+ assert_equal({"kind" => "json"}, @loader.load(fixtures/"data.json"))
17
+ assert_equal({"kind" => "rb"}, @loader.load(fixtures/"data.rb"))
18
+ assert_equal({"kind" => "ruby"}, @loader.load(fixtures/"data.ruby"))
19
+
20
+ assert_equal({"kind" => "md", "content" => "This is the text"},
21
+ @loader.load(fixtures/"data.md"))
22
+ assert_equal({"content" => "This is the text"},
23
+ @loader.load(fixtures/"text.md"))
24
+
25
+ assert_raise(Errno::ENOENT){
26
+ @loader.load(fixtures/"no-such-one.yml")
27
+ }
28
+ assert_raise(RuntimeError, /Unable to load.*unrecognized extension/){
29
+ @loader.load(fixtures/"data.notarecognized")
30
+ }
31
+ end
32
+
33
+ def test_extensions
34
+ assert_equal [".yml", ".yaml", ".json", ".rb", ".ruby", ".md"],
35
+ @loader.extensions
36
+ end
37
+
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,208 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: polygon
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bernard Lambeau
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-11 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &70159370960020 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.2
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70159370960020
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &70159370959520 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70159370959520
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70159370959060 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.10'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70159370959060
47
+ - !ruby/object:Gem::Dependency
48
+ name: yard
49
+ requirement: &70159370958600 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.7.2
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70159370958600
58
+ - !ruby/object:Gem::Dependency
59
+ name: bluecloth
60
+ requirement: &70159370984760 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '2.2'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70159370984760
69
+ - !ruby/object:Gem::Dependency
70
+ name: sinatra
71
+ requirement: &70159370984300 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '1.3'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *70159370984300
80
+ - !ruby/object:Gem::Dependency
81
+ name: epath
82
+ requirement: &70159370983840 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 0.2.0
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *70159370983840
91
+ - !ruby/object:Gem::Dependency
92
+ name: json
93
+ requirement: &70159370983380 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :runtime
100
+ prerelease: false
101
+ version_requirements: *70159370983380
102
+ - !ruby/object:Gem::Dependency
103
+ name: wlang
104
+ requirement: &70159370982920 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.10.2
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: *70159370982920
113
+ description: ! "Polygon provides a framework with strong separation of concerns between
114
+ \nclients, developers and web designers"
115
+ email:
116
+ - blambeau@gmail.com
117
+ executables: []
118
+ extensions: []
119
+ extra_rdoc_files:
120
+ - README.md
121
+ - CHANGELOG.md
122
+ - LICENCE.md
123
+ files:
124
+ - polygon.gemspec
125
+ - polygon.noespec
126
+ - CHANGELOG.md
127
+ - Gemfile
128
+ - Gemfile.lock
129
+ - lib/polygon/base.rb
130
+ - lib/polygon/content.rb
131
+ - lib/polygon/content_loader.rb
132
+ - lib/polygon/helpers.rb
133
+ - lib/polygon/loader.rb
134
+ - lib/polygon/version.rb
135
+ - lib/polygon.rb
136
+ - LICENCE.md
137
+ - Manifest.txt
138
+ - Rakefile
139
+ - README.md
140
+ - spec/spec_helper.rb
141
+ - spec/test_polygon.rb
142
+ - tasks/debug_mail.rake
143
+ - tasks/debug_mail.txt
144
+ - tasks/gem.rake
145
+ - tasks/spec_test.rake
146
+ - tasks/unit_test.rake
147
+ - tasks/yard.rake
148
+ - test/content/test_entry.rb
149
+ - test/fixtures/data/data.json
150
+ - test/fixtures/data/data.md
151
+ - test/fixtures/data/data.rb
152
+ - test/fixtures/data/data.ruby
153
+ - test/fixtures/data/data.yaml
154
+ - test/fixtures/data/data.yml
155
+ - test/fixtures/data/text.md
156
+ - test/fixtures/index.yml
157
+ - test/fixtures/with_index_md/index.md
158
+ - test/fixtures/with_index_yml/index.yml
159
+ - test/fixtures/with_index_yml/say-hello.md
160
+ - test/fixtures/without_index/hello.md
161
+ - test/helper.rb
162
+ - test/runall.rb
163
+ - test/test_content.rb
164
+ - test/test_content_loader.rb
165
+ homepage: http://github.com/blambeau/polygon
166
+ licenses: []
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ none: false
173
+ requirements:
174
+ - - ! '>='
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ none: false
179
+ requirements:
180
+ - - ! '>='
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 1.8.10
186
+ signing_key:
187
+ specification_version: 3
188
+ summary: A web framework powered by sinatra for mostly static websites
189
+ test_files:
190
+ - test/content/test_entry.rb
191
+ - test/fixtures/data/data.json
192
+ - test/fixtures/data/data.md
193
+ - test/fixtures/data/data.rb
194
+ - test/fixtures/data/data.ruby
195
+ - test/fixtures/data/data.yaml
196
+ - test/fixtures/data/data.yml
197
+ - test/fixtures/data/text.md
198
+ - test/fixtures/index.yml
199
+ - test/fixtures/with_index_md/index.md
200
+ - test/fixtures/with_index_yml/index.yml
201
+ - test/fixtures/with_index_yml/say-hello.md
202
+ - test/fixtures/without_index/hello.md
203
+ - test/helper.rb
204
+ - test/runall.rb
205
+ - test/test_content.rb
206
+ - test/test_content_loader.rb
207
+ - spec/spec_helper.rb
208
+ - spec/test_polygon.rb