hobby-pages 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e6db678112c7d9a11a8281c4131e607e9b1d155
4
- data.tar.gz: 6df58f7fa8122d8e7865af55536854282161292e
3
+ metadata.gz: f1f33116e38ee9f4222ababdec0fc189f97d1778
4
+ data.tar.gz: fff828c5b9d5fa9417a8f0ca6b30bd3dd1e386af
5
5
  SHA512:
6
- metadata.gz: c836329640bebae055ba35dfb703333812b6bbbd9f95a06f097e2983066cc7fa017adab173affb548b336b4e7d741aa15c544802068f2de0fbbf991398642720
7
- data.tar.gz: 9ae7499ce9b23776f3dbd712d64fe3b354b34e4ac0b75ea3bdd49595da8af17206ef423db4d839192d58d2a87cf54bad7bd21e4ab08e30051f452ee4e796dd18
6
+ metadata.gz: b967798de505dc054507593fb79b0e3b1eef0d6bf03a755f657ef68cc4e2115ffbfa9eb0653b30b31cb992727686c9c775d339b2e374f24bdfc47e474150fbae
7
+ data.tar.gz: 45f5912f49eb25f39745e25e20c45812d689464e4a7e90b97c9892d5588dc00af7727fc3cd5d6db32c4356e855a398153192afc43a8ce90cba7e751391653d94
data/hobby-pages.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
  Gem::Specification.new do |g|
2
2
  g.name = 'hobby-pages'
3
3
  g.files = `git ls-files`.split($/)
4
- g.version = '0.0.4'
4
+ g.version = '0.0.5'
5
5
  g.summary = 'A Hobby app to return a bunch of HTML pages from a directory.'
6
6
  g.authors = ['Anatoly Chernow']
7
7
 
8
- g.add_dependency 'hobby', '>=0.0.8'
8
+ g.add_dependency 'hobby', '>=0.0.9'
9
9
  g.add_dependency 'tilt'
10
10
  g.add_dependency 'slim'
11
11
  g.add_dependency 'sass'
data/lib/hobby/pages.rb CHANGED
@@ -24,6 +24,11 @@ module Hobby
24
24
  end
25
25
  end
26
26
 
27
+ get '/:name.js' do
28
+ content_type :js
29
+ js_at_name my[:name]
30
+ end
31
+
27
32
  get '/:name' do
28
33
  @name = my[:name]
29
34
 
@@ -54,14 +59,6 @@ module Hobby
54
59
  end
55
60
  end
56
61
 
57
- def js_tag
58
- @js_tag ||= if js
59
- "<script>#{js}</script>"
60
- else
61
- ''
62
- end
63
- end
64
-
65
62
  def css
66
63
  style_file = "#{directory}/css/pages/#{name}.sass"
67
64
  if File.exist? style_file
@@ -71,7 +68,15 @@ module Hobby
71
68
  end
72
69
  end
73
70
 
74
- def js
71
+ def js_tag
72
+ @js_tag ||= if js_at_name(name)
73
+ "<script src='#{env['SCRIPT_NAME']}/#{name}.js'></script>"
74
+ else
75
+ ''
76
+ end
77
+ end
78
+
79
+ def js_at_name name
75
80
  directory.sprockets["pages/#{name}.js"]
76
81
  end
77
82
 
data/spec/main_spec.rb CHANGED
@@ -56,17 +56,21 @@ describe Hobby::Pages do
56
56
  end
57
57
 
58
58
  it 'creages pages with JS' do
59
- response = @conn.get path: '/with-js'
59
+ response = @conn.get path: '/jspage'
60
60
  doc = Nokogiri.HTML response.body
61
61
 
62
- text = doc.at_css('script').text
63
- expect(text).to eq <<~S
62
+ js_src = doc.at_css('script').attr :src
63
+ expect(js_src).to eq '/jspage.js'
64
+
65
+ response = @conn.get path: js_src
66
+ expect(response.body).to eq <<~S
64
67
  (function() {
65
68
  alert('something');
66
69
 
67
70
  }).call(this);
68
71
  S
69
72
  end
73
+
70
74
  it 'maps the index template to the root route' do
71
75
  response = @conn.get(path: '/')
72
76
  doc = Nokogiri.HTML response.body
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
4
+ version: 0.0.5
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-22 00:00:00.000000000 Z
11
+ date: 2017-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hobby
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.8
19
+ version: 0.0.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.8
26
+ version: 0.0.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tilt
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -110,11 +110,11 @@ files:
110
110
  - spec/dirs/main/html/layouts/default.slim
111
111
  - spec/dirs/main/html/pages/exist.slim
112
112
  - spec/dirs/main/html/pages/index.slim
113
+ - spec/dirs/main/html/pages/jspage.slim
113
114
  - spec/dirs/main/html/pages/with-css.slim
114
115
  - spec/dirs/main/html/pages/with-head.slim
115
- - spec/dirs/main/html/pages/with-js.slim
116
116
  - spec/dirs/main/html/ruby/with-head.rb
117
- - spec/dirs/main/js/pages/with-js.coffee
117
+ - spec/dirs/main/js/pages/jspage.coffee
118
118
  - spec/helper.rb
119
119
  - spec/main_spec.rb
120
120
  homepage: