pubba 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,23 +3,35 @@ module Sinatra
3
3
  module HTML
4
4
  module Helpers
5
5
  def page_head_tags
6
- tags = []
7
- @page.head_tags.each do |tag|
8
- t = tag.dup
9
- type = t.delete(:tag)
10
- tags << tag_content(type, '', t)
11
- end
12
- tags.join('')
6
+ process_tags(@page.head_tags)
13
7
  end
14
8
 
15
9
  def page_body_tags
16
- tags = []
17
- @page.body_tags.dup.each do |tag|
10
+ process_tags(@page.body_tags)
11
+ end
12
+
13
+ def digest_url(url)
14
+ url.start_with?('http') ? url : ::Statica.digest_url(url)
15
+ end
16
+
17
+ private
18
+
19
+ def process_tags(tags)
20
+ array = []
21
+ tags.each do |tag|
18
22
  t = tag.dup
19
- type = t.delete(:tag)
20
- tags << tag_content(type, '', t)
23
+ set_url(type = t.delete(:tag), t)
24
+ array << tag_content(type, '', t)
25
+ end
26
+ array.join('')
27
+ end
28
+
29
+ def set_url(type, t)
30
+ if type == 'script'
31
+ t[:src] = digest_url(t[:src])
32
+ else
33
+ t[:href] = digest_url(t[:href])
21
34
  end
22
- tags.join('')
23
35
  end
24
36
 
25
37
  def tag_content(tag, content, attrs={}, self_closing=false)
@@ -12,10 +12,20 @@ module Sinatra
12
12
  def start_monitor
13
13
  @running = Thread.new do
14
14
  puts "Pubba is now monitoring: #{Site.asset_folder}"
15
- FSSM.monitor(Site.asset_folder, '**/*', :directories => true) do
16
- update {|base, relative, type| Site.process}
17
- delete {|base, relative, type| Site.process}
18
- create {|base, relative, type| Site.process}
15
+ FSSM.monitor do
16
+ path Site.script_asset_folder do
17
+ glob '**/*'
18
+ update {|base, relative, type| Site.process}
19
+ delete {|base, relative, type| Site.process}
20
+ create {|base, relative, type| Site.process}
21
+ end
22
+
23
+ path Site.style_asset_folder do
24
+ glob '**/*'
25
+ update {|base, relative, type| Site.process}
26
+ delete {|base, relative, type| Site.process}
27
+ create {|base, relative, type| Site.process}
28
+ end
19
29
  end
20
30
  end
21
31
  end
@@ -1,3 +1,5 @@
1
+ require 'statica'
2
+
1
3
  require_relative 'assets/configuration'
2
4
  require_relative 'assets/sprockets_handler'
3
5
  require_relative 'assets/yui_minifier'
@@ -75,6 +77,7 @@ module Sinatra
75
77
  end
76
78
 
77
79
  def set_folder_defaults(settings)
80
+ Statica.root_dir = settings.public_folder
78
81
  @script_public_folder = File.join(settings.public_folder, 'javascripts')
79
82
  @style_public_folder = File.join(settings.public_folder, 'stylesheets')
80
83
  @asset_folder = settings.asset_folder
@@ -1,5 +1,5 @@
1
1
  module Pubba
2
2
  # Pubba version string
3
3
  # @api public
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
data/pubba.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency('r18n-desktop', ['~> 0.4.13'])
24
24
  s.add_runtime_dependency('yui-compressor', ['>= 0.9.4'])
25
25
  s.add_runtime_dependency('fssm', ['>= 0.2.7'])
26
+ s.add_runtime_dependency('statica', ['>= 0.1.0'])
26
27
 
27
28
  s.add_development_dependency('rake', ['>= 0.9.2'])
28
29
  s.add_development_dependency('sinatra', ['>= 1.3.1'])
@@ -6,15 +6,17 @@ class TestPubbaHTMLHelper < TestPubba
6
6
 
7
7
  def test_home_page_head_tags
8
8
  res = get('/home-page-head-tags').body
9
- str = %|<link href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-all.css" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-phone.css" media="only screen and (max-width: 480px)" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-desktop.css" media="only screen and (min-width: 480px)" rel="stylesheet" type="text/css"></link><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script><script src="/javascripts/home-head.js" type="text/javascript"></script>|
9
+ puts res
10
+ reg = Regexp.new '<link href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-all.css/\w+" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-phone.css/\w+" media="only screen and \(max-width: 480px\)" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-desktop.css/\w+" media="only screen and \(min-width: 480px\)" rel="stylesheet" type="text/css"></link><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script><script src="/javascripts/home-head.js/\w+" type="text/javascript"></script>'
10
11
 
11
- assert_equal str, res
12
+
13
+ assert_match reg, res
12
14
  end
13
15
 
14
16
  def test_home_page_body_tags
15
17
  res = get('/home-page-body-tags').body
16
- str = %|<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script><script src="/javascripts/home-body.js" type="text/javascript"></script>|
18
+ reg = Regexp.new '<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script><script src="/javascripts/home-body.js/\w+" type="text/javascript"></script>'
17
19
 
18
- assert_equal str, res
20
+ assert_match reg, res
19
21
  end
20
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-14 00:00:00.000000000 Z
12
+ date: 2011-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
16
- requirement: &2151925720 !ruby/object:Gem::Requirement
16
+ requirement: &2151810540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.1.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2151925720
24
+ version_requirements: *2151810540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: r18n-desktop
27
- requirement: &2151913100 !ruby/object:Gem::Requirement
27
+ requirement: &2151809780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.4.13
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2151913100
35
+ version_requirements: *2151809780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yui-compressor
38
- requirement: &2151918540 !ruby/object:Gem::Requirement
38
+ requirement: &2151809040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.9.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2151918540
46
+ version_requirements: *2151809040
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: fssm
49
- requirement: &2151911280 !ruby/object:Gem::Requirement
49
+ requirement: &2151808220 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,21 @@ dependencies:
54
54
  version: 0.2.7
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2151911280
57
+ version_requirements: *2151808220
58
+ - !ruby/object:Gem::Dependency
59
+ name: statica
60
+ requirement: &2151807540 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: 0.1.0
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *2151807540
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: rake
60
- requirement: &2151799920 !ruby/object:Gem::Requirement
71
+ requirement: &2151806960 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ! '>='
@@ -65,10 +76,10 @@ dependencies:
65
76
  version: 0.9.2
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *2151799920
79
+ version_requirements: *2151806960
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: sinatra
71
- requirement: &2151804560 !ruby/object:Gem::Requirement
82
+ requirement: &2151806280 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ! '>='
@@ -76,10 +87,10 @@ dependencies:
76
87
  version: 1.3.1
77
88
  type: :development
78
89
  prerelease: false
79
- version_requirements: *2151804560
90
+ version_requirements: *2151806280
80
91
  - !ruby/object:Gem::Dependency
81
92
  name: sinatra-contrib
82
- requirement: &2151803660 !ruby/object:Gem::Requirement
93
+ requirement: &2151805680 !ruby/object:Gem::Requirement
83
94
  none: false
84
95
  requirements:
85
96
  - - ! '>='
@@ -87,10 +98,10 @@ dependencies:
87
98
  version: 1.3.1
88
99
  type: :development
89
100
  prerelease: false
90
- version_requirements: *2151803660
101
+ version_requirements: *2151805680
91
102
  - !ruby/object:Gem::Dependency
92
103
  name: yard
93
- requirement: &2151802660 !ruby/object:Gem::Requirement
104
+ requirement: &2151821320 !ruby/object:Gem::Requirement
94
105
  none: false
95
106
  requirements:
96
107
  - - ! '>='
@@ -98,7 +109,7 @@ dependencies:
98
109
  version: '0'
99
110
  type: :development
100
111
  prerelease: false
101
- version_requirements: *2151802660
112
+ version_requirements: *2151821320
102
113
  description:
103
114
  email:
104
115
  - andy@stonean.com