polygon 0.0.3 → 0.9.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/CHANGELOG.md +0 -12
- data/Gemfile +5 -2
- data/Gemfile.lock +25 -10
- data/lib/polygon/base.rb +10 -8
- data/lib/polygon/core_ext/path.rb +24 -0
- data/lib/polygon/core_ext/rack/nocache.rb +27 -0
- data/lib/polygon/core_ext.rb +2 -0
- data/lib/polygon/database.rb +57 -0
- data/lib/polygon/dialect.rb +13 -0
- data/lib/polygon/entry.rb +101 -0
- data/lib/polygon/helpers.rb +43 -10
- data/lib/polygon/loader.rb +4 -2
- data/lib/polygon/script/gsub.rb +59 -0
- data/lib/polygon/script/launch.rb +75 -0
- data/lib/polygon/script.rb +38 -0
- data/lib/polygon/version.rb +2 -2
- data/lib/polygon.rb +4 -13
- data/polygon.gemspec +5 -3
- data/polygon.noespec +6 -4
- data/spec/core_ext/test_epath.rb +34 -0
- data/spec/database/test_entries.rb +30 -0
- data/spec/database/test_sitemap.rb +31 -0
- data/spec/entry/test_ancestors_or_self.rb +43 -0
- data/spec/entry/test_divide.rb +27 -0
- data/spec/entry/test_equality.rb +26 -0
- data/spec/entry/test_exist.rb +18 -0
- data/spec/entry/test_extensions.rb +29 -0
- data/spec/entry/test_hash.rb +14 -0
- data/spec/entry/test_index.rb +18 -0
- data/spec/entry/test_index_files.rb +29 -0
- data/spec/entry/test_parent.rb +40 -0
- data/spec/entry/test_path.rb +19 -0
- data/spec/entry/test_to_hash.rb +22 -0
- data/{test → spec}/fixtures/data/data.json +0 -0
- data/{test → spec}/fixtures/data/data.md +0 -0
- data/{test → spec}/fixtures/data/data.rb +0 -0
- data/{test → spec}/fixtures/data/data.ruby +0 -0
- data/{test → spec}/fixtures/data/data.yaml +0 -0
- data/{test → spec}/fixtures/data/data.yml +0 -0
- data/spec/fixtures/data/empty.md +3 -0
- data/{test → spec}/fixtures/data/text.md +0 -0
- data/{test → spec}/fixtures/index.yml +0 -0
- data/{test → spec}/fixtures/with_index_md/index.md +0 -0
- data/{test → spec}/fixtures/with_index_yml/index.yml +0 -0
- data/{test → spec}/fixtures/with_index_yml/say-hello.md +0 -0
- data/{test → spec}/fixtures/without_index/hello.md +0 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/test_polygon.rb +10 -0
- data/tasks/yard.rake +51 -0
- metadata +161 -78
- checksums.yaml +0 -7
- data/lib/polygon/content.rb +0 -131
- data/lib/polygon/content_loader.rb +0 -78
- data/test/content/test_entry.rb +0 -99
- data/test/helper.rb +0 -5
- data/test/runall.rb +0 -1
- data/test/test_content.rb +0 -45
- data/test/test_content_loader.rb +0 -39
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
group :runtime do
|
4
|
+
gem "json", ">= 0"
|
4
5
|
gem "sinatra", "~> 1.3"
|
5
|
-
gem "
|
6
|
-
gem "
|
6
|
+
gem "wlang", "~> 2.1.1"
|
7
|
+
gem "alf", "~> 0.12.2"
|
8
|
+
gem "quickl", "~> 0.4.2"
|
9
|
+
gem "path", "~> 1.3.1"
|
7
10
|
end
|
8
11
|
|
9
12
|
group :development do
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
alf (0.12.2)
|
5
|
+
backports (~> 2.6)
|
6
|
+
myrrha (~> 1.2.1)
|
7
|
+
quickl (~> 0.4.2)
|
8
|
+
backports (2.6.1)
|
4
9
|
bluecloth (2.2.0)
|
10
|
+
citrus (2.4.1)
|
5
11
|
diff-lcs (1.1.3)
|
6
|
-
|
7
|
-
|
8
|
-
|
12
|
+
json (1.7.3)
|
13
|
+
myrrha (1.2.2)
|
14
|
+
path (1.3.1)
|
15
|
+
quickl (0.4.3)
|
16
|
+
rack (1.4.4)
|
17
|
+
rack-protection (1.3.2)
|
9
18
|
rack
|
10
19
|
rake (0.9.2.2)
|
11
20
|
rspec (2.10.0)
|
@@ -16,26 +25,32 @@ GEM
|
|
16
25
|
rspec-expectations (2.10.0)
|
17
26
|
diff-lcs (~> 1.1.3)
|
18
27
|
rspec-mocks (2.10.1)
|
19
|
-
sinatra (1.3.
|
28
|
+
sinatra (1.3.3)
|
20
29
|
rack (~> 1.3, >= 1.3.6)
|
21
30
|
rack-protection (~> 1.2)
|
22
31
|
tilt (~> 1.3, >= 1.3.3)
|
32
|
+
temple (0.4.1)
|
23
33
|
tilt (1.3.3)
|
24
|
-
wlang (
|
34
|
+
wlang (2.1.1)
|
35
|
+
backports (~> 2.6)
|
36
|
+
citrus (~> 2.4.1)
|
37
|
+
path (~> 1.3)
|
38
|
+
quickl (~> 0.4.3)
|
39
|
+
temple (~> 0.4.0)
|
25
40
|
yard (0.7.5)
|
26
41
|
|
27
42
|
PLATFORMS
|
28
43
|
ruby
|
29
44
|
|
30
45
|
DEPENDENCIES
|
46
|
+
alf (~> 0.12.2)
|
31
47
|
bluecloth (~> 2.2)
|
32
48
|
bundler (~> 1.0)
|
33
|
-
|
49
|
+
json
|
50
|
+
path (~> 1.3.1)
|
51
|
+
quickl (~> 0.4.2)
|
34
52
|
rake (~> 0.9.2)
|
35
53
|
rspec (~> 2.10)
|
36
54
|
sinatra (~> 1.3)
|
37
|
-
wlang (~>
|
55
|
+
wlang (~> 2.1.1)
|
38
56
|
yard (~> 0.7.2)
|
39
|
-
|
40
|
-
BUNDLED WITH
|
41
|
-
1.16.0
|
data/lib/polygon/base.rb
CHANGED
@@ -2,19 +2,21 @@ module Polygon
|
|
2
2
|
class Base < Sinatra::Base
|
3
3
|
|
4
4
|
configure do
|
5
|
-
set :
|
6
|
-
set :
|
7
|
-
set :
|
8
|
-
set :
|
9
|
-
set :views, Proc.new { root && root/:design/:templates }
|
5
|
+
set :public_folder, Proc.new { 'content/static' }
|
6
|
+
set :views, Proc.new { 'design/views' }
|
7
|
+
set :database, Proc.new { Database.new('content/dynamic') }
|
8
|
+
set :wlang, :layout => :"layouts/html5"
|
10
9
|
enable :logging
|
11
10
|
enable :raise_errors
|
12
11
|
disable :show_exceptions
|
13
12
|
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
not_found do
|
15
|
+
send_file settings.public_folder + '/404.html', :status => 404
|
16
|
+
end
|
17
|
+
|
18
|
+
error do
|
19
|
+
send_file settings.public_folder + '/500.html', :status => 500
|
18
20
|
end
|
19
21
|
|
20
22
|
helpers Polygon::Helpers
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Path
|
2
|
+
|
3
|
+
register_loader '.rb', '.ruby' do |path|
|
4
|
+
::Kernel.eval(path.read, TOPLEVEL_BINDING, path.to_s)
|
5
|
+
end
|
6
|
+
|
7
|
+
register_loader '.md' do |path|
|
8
|
+
require 'yaml'
|
9
|
+
content = path.read
|
10
|
+
if content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
11
|
+
(YAML::load($1) || {}).merge("content" => $')
|
12
|
+
else
|
13
|
+
{"content" => content}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_url
|
18
|
+
path = self.rm_ext
|
19
|
+
path = path.dir if path.basename.to_s == 'index'
|
20
|
+
path = path == Path('.') ? Path("") : path
|
21
|
+
path.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rack
|
2
|
+
class Nocache
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
status, headers, body = @app.call(patch_request_headers(env))
|
9
|
+
[status, patch_response_headers(headers), body]
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
CACHE_BUSTER = {
|
14
|
+
"Cache-Control" => "no-cache, no-store, max-age=0, must-revalidate",
|
15
|
+
"Pragma" => "no-cache",
|
16
|
+
"Expires" => "Fri, 29 Aug 1997 02:14:00 EST"
|
17
|
+
}
|
18
|
+
|
19
|
+
def patch_request_headers(env)
|
20
|
+
env.reject{|k,v| k =~ /^HTTP_IF/i }
|
21
|
+
end
|
22
|
+
|
23
|
+
def patch_response_headers(env)
|
24
|
+
env.reject{|k,v| k =~ /^ETag$/i }.merge(CACHE_BUSTER)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Polygon
|
2
|
+
class Database < Alf::Environment
|
3
|
+
|
4
|
+
attr_reader :root, :options
|
5
|
+
|
6
|
+
def initialize(root, options = {})
|
7
|
+
@root = Path(root)
|
8
|
+
@options = default_options.merge(options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def default_options
|
12
|
+
{ :extensions => ["yml", "md"] }
|
13
|
+
end
|
14
|
+
|
15
|
+
def dataset(name)
|
16
|
+
if self.respond_to?(name)
|
17
|
+
send(name)
|
18
|
+
else
|
19
|
+
raise Alf::NoSuchDatasetError, "No such dataset `#{name}`"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def entries
|
24
|
+
@entries ||= Entries.new(root, options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def sitemap
|
28
|
+
@sitemap ||= begin
|
29
|
+
Alf.lispy(self).compile do
|
30
|
+
(extend :entries,
|
31
|
+
:path => lambda{ entry.relative_path.to_url },
|
32
|
+
:lastmod => lambda{ entry.path.mtime.strftime("%Y-%m-%d") })
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Entries
|
38
|
+
include Alf::Iterator
|
39
|
+
|
40
|
+
def initialize(root, options)
|
41
|
+
@root = root
|
42
|
+
@options = options
|
43
|
+
end
|
44
|
+
|
45
|
+
def each
|
46
|
+
extensions = @options[:extensions]
|
47
|
+
@root.glob("**/*").each do |file|
|
48
|
+
next unless file.file? and extensions.include?(file.ext)
|
49
|
+
entry = Entry.new(@root, file % @root)
|
50
|
+
yield(:entry => entry)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end # class Entries
|
55
|
+
|
56
|
+
end # class Database
|
57
|
+
end # class Polygon
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Polygon
|
2
|
+
class Entry
|
3
|
+
|
4
|
+
attr_reader :root, :relative_path, :options
|
5
|
+
|
6
|
+
def initialize(root, relative_path, options = {})
|
7
|
+
@root = Path(root)
|
8
|
+
@relative_path = Path(relative_path)
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
root / relative_path
|
14
|
+
end
|
15
|
+
|
16
|
+
def exist?
|
17
|
+
path.exist?
|
18
|
+
end
|
19
|
+
|
20
|
+
def index?
|
21
|
+
path.basename.rm_ext.to_s == "index"
|
22
|
+
end
|
23
|
+
|
24
|
+
def /(path)
|
25
|
+
entry = Entry.new(root, self.relative_path / path, options)
|
26
|
+
if entry.path.inside?(root)
|
27
|
+
entry
|
28
|
+
else
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def parent
|
34
|
+
@parent ||= begin
|
35
|
+
return nil unless base = self/".."
|
36
|
+
idx = -1
|
37
|
+
if index?
|
38
|
+
idx = index_files.index(path.basename.to_s) - 1
|
39
|
+
base = base/".." if idx == -1
|
40
|
+
end
|
41
|
+
base ? base/index_files[idx] : nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def ancestors_or_self(filter_unexisting = false)
|
46
|
+
res = _ancestors_or_self
|
47
|
+
filter_unexisting ? res.select{|f| f.path.exist?} : res
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_hash
|
51
|
+
ancestors_or_self(true).inject({}) do |h,entry|
|
52
|
+
merge(h, entry.data)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def ==(other)
|
57
|
+
other.is_a?(Entry) and other.path == path
|
58
|
+
end
|
59
|
+
|
60
|
+
def hash
|
61
|
+
path.hash
|
62
|
+
end
|
63
|
+
|
64
|
+
protected
|
65
|
+
|
66
|
+
def merge(left, right)
|
67
|
+
raise "Unexpected #{left.class} vs. #{right.class}" \
|
68
|
+
unless left.class == right.class
|
69
|
+
case left
|
70
|
+
when Array
|
71
|
+
(right | left).uniq
|
72
|
+
when Hash
|
73
|
+
left.merge(right){|k,l,r| merge(l,r)}
|
74
|
+
else
|
75
|
+
right
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def extensions
|
80
|
+
options[:extensions] || ["yml", "md"]
|
81
|
+
end
|
82
|
+
|
83
|
+
def index_files
|
84
|
+
extensions.map{|ext| "index.#{ext}"}
|
85
|
+
end
|
86
|
+
|
87
|
+
def index_file(i = 0)
|
88
|
+
index_files[i]
|
89
|
+
end
|
90
|
+
|
91
|
+
def data
|
92
|
+
path.load
|
93
|
+
end
|
94
|
+
|
95
|
+
def _ancestors_or_self
|
96
|
+
return [ self ] unless parent
|
97
|
+
parent.ancestors_or_self + [ self ]
|
98
|
+
end
|
99
|
+
|
100
|
+
end # class Entry
|
101
|
+
end # module Polygon
|
data/lib/polygon/helpers.rb
CHANGED
@@ -1,20 +1,53 @@
|
|
1
1
|
module Polygon
|
2
2
|
module Helpers
|
3
3
|
|
4
|
-
def static
|
5
|
-
|
6
|
-
|
4
|
+
def static
|
5
|
+
settings.static
|
6
|
+
end
|
7
|
+
|
8
|
+
def dynamic
|
9
|
+
settings.dynamic
|
10
|
+
end
|
11
|
+
|
12
|
+
def templates
|
13
|
+
settings.templates
|
14
|
+
end
|
15
|
+
|
16
|
+
def database
|
17
|
+
settings.database
|
18
|
+
end
|
19
|
+
|
20
|
+
def lispy(&bl)
|
21
|
+
@lispy ||= Alf.lispy(database)
|
22
|
+
bl ? @lispy.evaluate(&bl) : @lispy
|
23
|
+
end
|
24
|
+
|
25
|
+
def in_production
|
26
|
+
settings.environment == :production
|
27
|
+
end
|
28
|
+
|
29
|
+
def in_test
|
30
|
+
settings.environment == :test
|
31
|
+
end
|
32
|
+
|
33
|
+
def in_development
|
34
|
+
settings.environment == :development
|
35
|
+
end
|
7
36
|
|
8
|
-
def
|
9
|
-
{
|
37
|
+
def sitemap_locals
|
38
|
+
{ :urls => database.sitemap }
|
10
39
|
end
|
11
40
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
41
|
+
def page_locals(path = "")
|
42
|
+
rel = lispy do
|
43
|
+
(unwrap \
|
44
|
+
(extend (restrict :sitemap, :path => path),
|
45
|
+
:data => lambda{ entry.to_hash }),
|
46
|
+
:data)
|
47
|
+
end
|
48
|
+
rel && rel.to_a.first
|
17
49
|
end
|
50
|
+
alias :index_locals :page_locals
|
18
51
|
|
19
52
|
end # module Helpers
|
20
53
|
end # module Polygon
|
data/lib/polygon/loader.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
module Polygon
|
2
|
+
module Script
|
3
|
+
class Gsub < Polygon::Script(__FILE__, __LINE__)
|
4
|
+
|
5
|
+
attr_accessor :dry_run, :regexp, :folder, :pattern
|
6
|
+
|
7
|
+
options do |opt|
|
8
|
+
self.enable_logging = false
|
9
|
+
opt.on('--[no-]log', "Properly log in a file?") do |value|
|
10
|
+
self.enable_logging = value
|
11
|
+
end
|
12
|
+
self.dry_run = false
|
13
|
+
opt.on('-d', '--dry-run', "Dry-run mode, do not touch files") do
|
14
|
+
self.dry_run = true
|
15
|
+
end
|
16
|
+
self.regexp = false
|
17
|
+
opt.on('-r', '--regexp', "Use `from` as a regular expression") do
|
18
|
+
self.regexp = true
|
19
|
+
end
|
20
|
+
self.pattern = "**/*.*"
|
21
|
+
opt.on('-g', '--glob=PATTERN', "File pattern to use for Path.glob") do |pattern|
|
22
|
+
self.pattern = pattern
|
23
|
+
end
|
24
|
+
self.folder = Path.pwd
|
25
|
+
end
|
26
|
+
|
27
|
+
# Stolen from ptools (https://github.com/djberg96/ptools)
|
28
|
+
def binary?(file)
|
29
|
+
s = (File.read(file, File.stat(file).blksize) || "").split(//)
|
30
|
+
((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30
|
31
|
+
end
|
32
|
+
|
33
|
+
def gsub(file, from, to)
|
34
|
+
gsubbed = file.read.gsub!(from){|m|
|
35
|
+
msg = "gsub #{m[0, (50 - to.length)]} -> #{to}"
|
36
|
+
msg += " "*(60 - msg.length) + " (#{file})"
|
37
|
+
info msg
|
38
|
+
to
|
39
|
+
}
|
40
|
+
file.write(gsubbed) if gsubbed && !dry_run
|
41
|
+
rescue ArgumentError => ex
|
42
|
+
error "Skipping #{file}: #{ex.message}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def execute(args)
|
46
|
+
abort options.to_s unless args.size >= 2
|
47
|
+
from = args.shift
|
48
|
+
from = Regexp.compile(regexp ? from : Regexp.escape(from))
|
49
|
+
to = args.shift
|
50
|
+
files = args.empty? ? folder.glob(pattern) : args.map(&Path)
|
51
|
+
files.each do |file|
|
52
|
+
next if file.directory? or binary?(file)
|
53
|
+
gsub(file, from, to)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end # class Gsub
|
58
|
+
end # module Script
|
59
|
+
end # module Polygon
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Polygon
|
2
|
+
module Script
|
3
|
+
class Launch < Polygon::Script(__FILE__, __LINE__)
|
4
|
+
|
5
|
+
attr_accessor :mode, :refresh_repo, :open_browser, :try, :max
|
6
|
+
|
7
|
+
def config_ru
|
8
|
+
root/:config/"#{mode}.ru"
|
9
|
+
end
|
10
|
+
|
11
|
+
# Install the options
|
12
|
+
options do |opt|
|
13
|
+
self.enable_logging = true
|
14
|
+
opt.on('--[no-]log', "Properly log in a file?") do |value|
|
15
|
+
self.enable_logging = value
|
16
|
+
end
|
17
|
+
self.refresh_repo = true
|
18
|
+
opt.on('--[no-]refresh', "Issues a 'git remote update' first?") do |value|
|
19
|
+
self.refresh_repo = value
|
20
|
+
end
|
21
|
+
self.open_browser = true
|
22
|
+
opt.on('--[no-]browser', "Open the browser automatically?") do |value|
|
23
|
+
self.open_browser = value
|
24
|
+
end
|
25
|
+
self.try = 0
|
26
|
+
self.max = 500
|
27
|
+
opt.on('--max=MAX', Integer, "Number of connection attempts") do |value|
|
28
|
+
self.max = Integer(value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Tries to access the website
|
33
|
+
def wait_and_open
|
34
|
+
info "Attempting to connect to the web site..."
|
35
|
+
Http.head "http://127.0.0.1:3000/"
|
36
|
+
rescue Errno::ECONNREFUSED
|
37
|
+
sleep(0.5)
|
38
|
+
retry if (self.try += 1) < max
|
39
|
+
info "Server not found, sorry."
|
40
|
+
raise
|
41
|
+
else
|
42
|
+
Launchy.open("http://127.0.0.1:3000/")
|
43
|
+
end
|
44
|
+
|
45
|
+
def execute(argv)
|
46
|
+
abort options.to_s unless argv.size <= 1
|
47
|
+
self.mode = (argv.first || "development").to_sym
|
48
|
+
abort "Invalid mode #{mode}" unless config_ru.exist?
|
49
|
+
|
50
|
+
info "Refreshing repository info..." do
|
51
|
+
Process.wait spawn("git remote update")
|
52
|
+
end if refresh_repo
|
53
|
+
|
54
|
+
thinpid = nil
|
55
|
+
info "Starting the web server..." do
|
56
|
+
thinpid = spawn("thin -R #{config_ru} start")
|
57
|
+
end
|
58
|
+
|
59
|
+
info "Waiting for the server to start" do
|
60
|
+
require 'launchy'
|
61
|
+
require 'http'
|
62
|
+
wait_and_open
|
63
|
+
end if open_browser
|
64
|
+
|
65
|
+
rescue => ex
|
66
|
+
info "Lauching failed: #{ex.message}"
|
67
|
+
info ex.backtrace.join("\n")
|
68
|
+
Process.kill("SIGHUP", thinpid) if thinpid
|
69
|
+
ensure
|
70
|
+
Process.wait(thinpid) if thinpid
|
71
|
+
end
|
72
|
+
|
73
|
+
end # class Launch
|
74
|
+
end # module Script
|
75
|
+
end # module Polygon
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'polygon'
|
2
|
+
require 'quickl'
|
3
|
+
require 'logger'
|
4
|
+
module Polygon
|
5
|
+
module Script
|
6
|
+
|
7
|
+
attr_accessor :enable_logging
|
8
|
+
|
9
|
+
def root
|
10
|
+
Path($0).backfind('.[config.ru]') || Path.pwd.backfind('.[config.ru]')
|
11
|
+
end
|
12
|
+
|
13
|
+
def logger
|
14
|
+
@logger ||= Logger.new(root/:logs/"#{Quickl.command_name(self)}.log") if enable_logging
|
15
|
+
end
|
16
|
+
|
17
|
+
def log(message, severity)
|
18
|
+
puts message
|
19
|
+
logger.send(severity, message) if enable_logging
|
20
|
+
yield if block_given?
|
21
|
+
end
|
22
|
+
def debug(message, &block); log(message, :debug, &block); end
|
23
|
+
def info(message, &block); log(message, :info, &block); end
|
24
|
+
def warn(message, &block); log(message, :warn, &block); end
|
25
|
+
def error(message, &block); log(message, :error, &block); end
|
26
|
+
def fatal(message, &block); log(message, :fatal, &block); end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.Script(*args)
|
31
|
+
Quickl::Command(*args) do |builder|
|
32
|
+
builder.instance_module Script
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
require 'polygon/script/launch'
|
38
|
+
require 'polygon/script/gsub'
|
data/lib/polygon/version.rb
CHANGED
data/lib/polygon.rb
CHANGED
@@ -1,23 +1,14 @@
|
|
1
1
|
require "polygon/version"
|
2
2
|
require "polygon/loader"
|
3
|
+
require "polygon/core_ext"
|
3
4
|
#
|
4
5
|
# A web framework powered by sinatra for mostly static websites
|
5
6
|
#
|
6
7
|
module Polygon
|
7
8
|
|
8
|
-
def default_loader
|
9
|
-
@default_loader ||= ContentLoader.new.enable_all!
|
10
|
-
end
|
11
|
-
module_function :default_loader
|
12
|
-
|
13
|
-
def default_loader=(loader)
|
14
|
-
@default_loader = loader
|
15
|
-
end
|
16
|
-
module_function :default_loader=
|
17
|
-
|
18
9
|
end # module Polygon
|
19
|
-
require 'polygon/
|
20
|
-
require 'polygon/
|
10
|
+
require 'polygon/entry'
|
11
|
+
require 'polygon/database'
|
21
12
|
require 'polygon/helpers'
|
22
13
|
require 'polygon/base'
|
23
|
-
|
14
|
+
require 'polygon/dialect'
|
data/polygon.gemspec
CHANGED
@@ -128,10 +128,12 @@ Gem::Specification.new do |s|
|
|
128
128
|
s.add_development_dependency("rspec", "~> 2.10")
|
129
129
|
s.add_development_dependency("yard", "~> 0.7.2")
|
130
130
|
s.add_development_dependency("bluecloth", "~> 2.2")
|
131
|
-
s.add_dependency("sinatra", "~> 1.3")
|
132
|
-
s.add_dependency("epath", "~> 0.2.0")
|
133
131
|
s.add_dependency("json", ">= 0")
|
134
|
-
s.add_dependency("
|
132
|
+
s.add_dependency("sinatra", "~> 1.3")
|
133
|
+
s.add_dependency("wlang", "~> 2.1.1")
|
134
|
+
s.add_dependency("alf", "~> 0.12.2")
|
135
|
+
s.add_dependency("quickl", "~> 0.4.2")
|
136
|
+
s.add_dependency("path", "~> 1.3.1")
|
135
137
|
|
136
138
|
# The version of ruby required by this gem
|
137
139
|
#
|
data/polygon.noespec
CHANGED
@@ -7,7 +7,7 @@ variables:
|
|
7
7
|
upper:
|
8
8
|
Polygon
|
9
9
|
version:
|
10
|
-
0.
|
10
|
+
0.9.1
|
11
11
|
summary: |-
|
12
12
|
A web framework powered by sinatra for mostly static websites
|
13
13
|
description: |-
|
@@ -18,10 +18,12 @@ variables:
|
|
18
18
|
links:
|
19
19
|
- http://github.com/blambeau/polygon
|
20
20
|
dependencies:
|
21
|
-
- {name: sinatra, version: "~> 1.3", groups: [runtime]}
|
22
|
-
- {name: epath, version: "~> 0.2.0", groups: [runtime]}
|
23
21
|
- {name: json, version: ">= 0", groups: [runtime]}
|
24
|
-
- {name:
|
22
|
+
- {name: sinatra, version: "~> 1.3", groups: [runtime]}
|
23
|
+
- {name: wlang, version: "~> 2.1.1", groups: [runtime]}
|
24
|
+
- {name: alf, version: "~> 0.12.2", groups: [runtime]}
|
25
|
+
- {name: quickl, version: "~> 0.4.2", groups: [runtime]}
|
26
|
+
- {name: path, version: "~> 1.3.1", groups: [runtime]}
|
25
27
|
- {name: rake, version: "~> 0.9.2", groups: [development]}
|
26
28
|
- {name: bundler, version: "~> 1.0", groups: [development]}
|
27
29
|
- {name: rspec, version: "~> 2.10", groups: [development]}
|