hobby-pages 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hobby-pages.gemspec +1 -1
- data/lib/hobby/pages.rb +30 -13
- data/spec/dirs/main/config.ru +3 -0
- data/spec/dirs/main/html/layouts/default.slim +2 -0
- data/spec/main_spec.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e6db678112c7d9a11a8281c4131e607e9b1d155
|
4
|
+
data.tar.gz: 6df58f7fa8122d8e7865af55536854282161292e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c836329640bebae055ba35dfb703333812b6bbbd9f95a06f097e2983066cc7fa017adab173affb548b336b4e7d741aa15c544802068f2de0fbbf991398642720
|
7
|
+
data.tar.gz: 9ae7499ce9b23776f3dbd712d64fe3b354b34e4ac0b75ea3bdd49595da8af17206ef423db4d839192d58d2a87cf54bad7bd21e4ab08e30051f452ee4e796dd18
|
data/hobby-pages.gemspec
CHANGED
data/lib/hobby/pages.rb
CHANGED
@@ -46,6 +46,35 @@ module Hobby
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
def css_tag
|
50
|
+
@css_tag ||= if css
|
51
|
+
"<style>#{css}</style>"
|
52
|
+
else
|
53
|
+
''
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def js_tag
|
58
|
+
@js_tag ||= if js
|
59
|
+
"<script>#{js}</script>"
|
60
|
+
else
|
61
|
+
''
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def css
|
66
|
+
style_file = "#{directory}/css/pages/#{name}.sass"
|
67
|
+
if File.exist? style_file
|
68
|
+
sass_string = IO.read style_file
|
69
|
+
load_path = "#{directory}/css/pages/#{name}"
|
70
|
+
Sass::Engine.new(sass_string, load_paths: [load_path]).render
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def js
|
75
|
+
directory.sprockets["pages/#{name}.js"]
|
76
|
+
end
|
77
|
+
|
49
78
|
class Directory
|
50
79
|
def initialize root
|
51
80
|
@root = root
|
@@ -97,25 +126,13 @@ module Hobby
|
|
97
126
|
|
98
127
|
script_file = "#{directory.to_s}/html/ruby/#{name}.rb"
|
99
128
|
@script = IO.read script_file if File.exist? script_file
|
100
|
-
|
101
|
-
style_file = "#{directory.to_s}/css/pages/#{name}.sass"
|
102
|
-
if File.exist? style_file
|
103
|
-
sass_string = IO.read style_file
|
104
|
-
load_path = "#{directory.to_s}/css/pages/#{name}"
|
105
|
-
css = Sass::Engine.new(sass_string, load_paths: [load_path]).render
|
106
|
-
@css_tag = "<style id='for_page_#{name}'>#{css}</style>"
|
107
|
-
end
|
108
|
-
|
109
|
-
if js = directory.sprockets["pages/#{name}.js"]
|
110
|
-
@js_tag = "<script id='js_for_page_#{name}'>#{js}</script>"
|
111
|
-
end
|
112
129
|
end
|
113
130
|
|
114
131
|
def render app
|
115
132
|
app.instance_eval @script if @script
|
116
133
|
|
117
134
|
@layout.render app do
|
118
|
-
|
135
|
+
@template.render app
|
119
136
|
end
|
120
137
|
end
|
121
138
|
end
|
data/spec/main_spec.rb
CHANGED
@@ -51,7 +51,7 @@ describe Hobby::Pages do
|
|
51
51
|
response = @conn.get path: '/with-css'
|
52
52
|
doc = Nokogiri.HTML response.body
|
53
53
|
|
54
|
-
text = doc.at_css('style
|
54
|
+
text = doc.at_css('style').text
|
55
55
|
expect(text).to eq "input {\n width: 100%; }\n"
|
56
56
|
end
|
57
57
|
|
@@ -59,7 +59,7 @@ describe Hobby::Pages do
|
|
59
59
|
response = @conn.get path: '/with-js'
|
60
60
|
doc = Nokogiri.HTML response.body
|
61
61
|
|
62
|
-
text = doc.at_css('script
|
62
|
+
text = doc.at_css('script').text
|
63
63
|
expect(text).to eq <<~S
|
64
64
|
(function() {
|
65
65
|
alert('something');
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobby-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoly Chernow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hobby
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- Gemfile
|
105
105
|
- hobby-pages.gemspec
|
106
106
|
- lib/hobby/pages.rb
|
107
|
+
- spec/dirs/main/config.ru
|
107
108
|
- spec/dirs/main/css/pages/with-css.sass
|
108
109
|
- spec/dirs/main/css/pages/with-css/width.sass
|
109
110
|
- spec/dirs/main/html/layouts/default.slim
|