hstatic 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO +2 -0
- data/hstatic.gemspec +1 -0
- data/lib/hstatic/app.rb +19 -14
- data/lib/hstatic/version.rb +1 -1
- metadata +28 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c55ec459ec18553bde8c6c9e99d91882f700913
|
4
|
+
data.tar.gz: 8e903f7d8f4efb60dd57463485843c40f8afec48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 925aeea96736edda8a6f3025fcbe974a60c687f1cac1c5dffb4fb9b22ea9b469369d0f863a41e60ab29aa93944693976d83f96c316ee272604dc25ae38c6bd8d
|
7
|
+
data.tar.gz: 30fa22b6d0addef3e5b52345bd215ac9254d6023b9736e5fc060b3acab900765e348db14c56ee53b0ddc6ecf714339e13e0674637e27d06a3e237463a92cc6f4
|
data/TODO
CHANGED
data/hstatic.gemspec
CHANGED
data/lib/hstatic/app.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
-
require
|
2
|
+
require "haml"
|
3
|
+
require "slim"
|
3
4
|
|
4
5
|
module Hstatic
|
5
6
|
BASEDIR = File.join(File.dirname(__FILE__), '..', '..')
|
@@ -13,26 +14,30 @@ module Hstatic
|
|
13
14
|
helpers do
|
14
15
|
def dynamic_size(size)
|
15
16
|
case
|
16
|
-
when size >
|
17
|
-
sprintf("%5.2f", size /
|
18
|
-
when (size /
|
19
|
-
sprintf("%5.2f", size /
|
17
|
+
when size > 2**40
|
18
|
+
sprintf("%5.2f", size / 2**40) << ' GB'
|
19
|
+
when (size / 2**20) > 0.1
|
20
|
+
sprintf("%5.2f", size / 2**20).to_s << ' MB'
|
20
21
|
else
|
21
|
-
sprintf("%5.2f", size /
|
22
|
+
sprintf("%5.2f", size / 2**10).to_s << ' kB'
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
#
|
27
|
+
# Finally every Tilt supported template is rendered
|
27
28
|
helpers do
|
28
29
|
def render_file(path)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
begin
|
31
|
+
if template = Tilt[path]
|
32
|
+
ext, _ = Tilt.mappings.find { |k, v| v.include? template }
|
33
|
+
method = self.method(ext)
|
34
|
+
basename = File.basename(path, File.extname(path)).to_sym
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
+
method.call(basename, { :views => File.dirname(path) })
|
37
|
+
else
|
38
|
+
raise Exception.new "No matching template"
|
39
|
+
end
|
40
|
+
rescue
|
36
41
|
send_file path
|
37
42
|
end
|
38
43
|
end
|
@@ -96,7 +101,7 @@ module Hstatic
|
|
96
101
|
# Render view
|
97
102
|
haml :index
|
98
103
|
else
|
99
|
-
|
104
|
+
[404, "File not found"]
|
100
105
|
end
|
101
106
|
end
|
102
107
|
end
|
data/lib/hstatic/version.rb
CHANGED
metadata
CHANGED
@@ -1,69 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hstatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erick Pérez Castellanos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sinatra
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: haml
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: slim
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
description: |-
|
@@ -77,7 +91,7 @@ executables:
|
|
77
91
|
extensions: []
|
78
92
|
extra_rdoc_files: []
|
79
93
|
files:
|
80
|
-
- .gitignore
|
94
|
+
- ".gitignore"
|
81
95
|
- Gemfile
|
82
96
|
- LICENSE.txt
|
83
97
|
- README.md
|
@@ -106,12 +120,12 @@ require_paths:
|
|
106
120
|
- lib
|
107
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
122
|
requirements:
|
109
|
-
- -
|
123
|
+
- - ">="
|
110
124
|
- !ruby/object:Gem::Version
|
111
125
|
version: '0'
|
112
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
127
|
requirements:
|
114
|
-
- -
|
128
|
+
- - ">="
|
115
129
|
- !ruby/object:Gem::Version
|
116
130
|
version: '0'
|
117
131
|
requirements: []
|
@@ -121,3 +135,4 @@ signing_key:
|
|
121
135
|
specification_version: 4
|
122
136
|
summary: An HTTP server for you static files
|
123
137
|
test_files: []
|
138
|
+
has_rdoc:
|