pubba 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -2
- data/CHANGES +9 -0
- data/README.md +1 -0
- data/Rakefile +24 -0
- data/lib/pubba/assets/handler.rb +61 -3
- data/lib/pubba/assets/sprockets_handler.rb +33 -24
- data/lib/pubba/page.rb +8 -4
- data/lib/pubba/version.rb +1 -1
- data/pubba.gemspec +1 -0
- data/test/helper.rb +5 -28
- data/test/pubba/assets/test_configuration.rb +3 -3
- data/test/pubba/test_page.rb +14 -12
- data/test/pubba/test_site.rb +2 -2
- data/test/resources.rb +61 -0
- data/test/sinatra/app/assets/js/custom/home.js +3 -0
- data/test/sinatra/app/assets/js/custom/search.js +3 -0
- data/test/sinatra/app/assets/js/github/documentcloud/backbone.js +623 -0
- data/test/sinatra/app/assets/js/github/documentcloud/underscore.js +460 -0
- data/test/sinatra/config/pubba.yml +2 -1
- metadata +36 -21
- data/test/sinatra/app/assets/js/third-party/backbone.js +0 -3
data/.gitignore
CHANGED
data/CHANGES
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
master
|
2
2
|
|
3
|
+
0.7.2
|
4
|
+
* Support id attribute on style tag
|
5
|
+
|
6
|
+
0.7.1
|
7
|
+
* Fix asset_host functionality
|
8
|
+
* Don't stop monitoring if compressor encounters error
|
9
|
+
|
10
|
+
0.7.0
|
11
|
+
|
3
12
|
* Conceptual change from Sinatra extension to generic library
|
4
13
|
* Namespace changed from Sinatra::Pubba to Pubba
|
5
14
|
* Change to configuration implementation
|
data/README.md
CHANGED
@@ -253,4 +253,5 @@ Huge thanks to my company, [Primedia](http://primedia.com) for encouraging open
|
|
253
253
|
|
254
254
|
I highly value contributions and will happily list all those who submit accepted pull requests.
|
255
255
|
|
256
|
+
[Blanton Black](https://github.com/blanton-black) : Id atttribute support on style tag
|
256
257
|
[Chas Lemley](https://github.com/chaslemley) : YUI Compressor support
|
data/Rakefile
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
module Prepare
|
2
|
+
def self.do
|
3
|
+
require File.join(File.dirname(__FILE__), 'lib', 'pubba')
|
4
|
+
require File.join(File.dirname(__FILE__), 'test', 'resources')
|
5
|
+
|
6
|
+
$>.print(">> Cleaning resources from public directories\n")
|
7
|
+
Resources.clean
|
8
|
+
|
9
|
+
Pubba.configure do |p|
|
10
|
+
p.config_file = Resources.pubba_config_file
|
11
|
+
p.public_folder = Resources.public_folder
|
12
|
+
p.asset_folder = Resources.asset_folder
|
13
|
+
p.r18n_folder = Resources.r18n_folder
|
14
|
+
end
|
15
|
+
|
16
|
+
$>.print(">> Processing assets")
|
17
|
+
Pubba::Site.process
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
1
22
|
begin
|
2
23
|
require 'bundler'
|
3
24
|
Bundler::GemHelper.install_tasks
|
@@ -7,6 +28,7 @@ end
|
|
7
28
|
require 'rake/testtask'
|
8
29
|
|
9
30
|
Rake::TestTask.new('test') do |t|
|
31
|
+
Prepare.do
|
10
32
|
t.libs << 'lib' << 'test'
|
11
33
|
t.test_files = Dir.glob('test/**/test_*.rb')
|
12
34
|
t.verbose = true
|
@@ -44,3 +66,5 @@ desc "Generate Documentation"
|
|
44
66
|
task :doc => :yard
|
45
67
|
|
46
68
|
task :default => 'test'
|
69
|
+
|
70
|
+
|
data/lib/pubba/assets/handler.rb
CHANGED
@@ -1,9 +1,67 @@
|
|
1
|
+
require 'octopi'
|
2
|
+
|
1
3
|
module Pubba
|
2
4
|
module Assets
|
3
5
|
class Handler
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
class << self
|
7
|
+
include Octopi
|
8
|
+
|
9
|
+
def asset(file)
|
10
|
+
raise NotImplementedError
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return path, ext Path and extension of resource
|
14
|
+
def get_external_resource(url)
|
15
|
+
path = ''
|
16
|
+
ext = ''
|
17
|
+
|
18
|
+
authenticated do
|
19
|
+
parts = url.split(':')
|
20
|
+
user = parts[1]
|
21
|
+
repo = parts[2]
|
22
|
+
tag = parts[3]
|
23
|
+
file = parts[4]
|
24
|
+
|
25
|
+
# file extension: .js
|
26
|
+
ext = File.extname(file)
|
27
|
+
|
28
|
+
# file name without extension
|
29
|
+
basename = File.basename(file, ext)
|
30
|
+
|
31
|
+
# subdir gitub/primedia
|
32
|
+
subdir = File.join(parts[0], user)
|
33
|
+
|
34
|
+
# github/repo/file
|
35
|
+
path = File.join(subdir, basename)
|
36
|
+
|
37
|
+
folder = (ext == '.css' ? Pubba.style_folder : Pubba.script_folder)
|
38
|
+
|
39
|
+
# assets/js/github/repo/file
|
40
|
+
out_path = File.join(Pubba.asset_folder, folder, subdir)
|
41
|
+
FileUtils.mkdir_p(out_path)
|
42
|
+
|
43
|
+
# assets/js/github/repo/file
|
44
|
+
out_file = File.join(out_path, basename + ext)
|
45
|
+
|
46
|
+
r = Repository.find(user: user, repo: repo)
|
47
|
+
r.tags.each do |t|
|
48
|
+
if t.name = tag
|
49
|
+
sha = t.sha
|
50
|
+
begin
|
51
|
+
blob = Blob.find(user: user, repo: repo, sha: sha, path: file)
|
52
|
+
File.open(out_file, "w"){|f| f.write(blob.data) }
|
53
|
+
break
|
54
|
+
rescue Octopi::APIError => e
|
55
|
+
puts "Error attempting to get: user: #{user}, repo: #{repo}, sha: #{sha}, path: #{file}"
|
56
|
+
puts e.message
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
return path, ext.split('.').last
|
63
|
+
end
|
64
|
+
end # class block
|
7
65
|
|
8
66
|
def save_as(file)
|
9
67
|
raise NotImplementedError
|
@@ -5,37 +5,46 @@ require_relative 'handler'
|
|
5
5
|
module Pubba
|
6
6
|
module Assets
|
7
7
|
class SprocketsHandler < Handler
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
class << self
|
9
|
+
def find(file)
|
10
|
+
SprocketsHandler.new(sprockets.find_asset(file))
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def asset_paths(*paths)
|
14
|
+
paths.each do |path|
|
15
|
+
sprockets.append_path path
|
16
|
+
end
|
15
17
|
end
|
16
|
-
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def sprockets
|
20
|
+
@sprockets ||= Sprockets::Environment.new()
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
def process(source, destination)
|
24
|
+
FileUtils.mkdir_p destination
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
Dir.glob("#{source}/*") do |file|
|
27
|
+
asset = find(file)
|
28
|
+
asset.save_as "#{destination}/#{File.basename(file)}"
|
29
|
+
end
|
28
30
|
end
|
29
|
-
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
def build(name, type, ext, urls)
|
33
|
+
content = urls.collect do |url|
|
34
|
+
if url.start_with?("github:")
|
35
|
+
url,ext = get_external_resource(url)
|
36
|
+
end
|
37
|
+
|
38
|
+
"//= require #{url}.#{ext}"
|
39
|
+
end.compact.join("\n")
|
40
|
+
|
41
|
+
out_folder = File.join(Pubba.asset_folder, "out", ext)
|
42
|
+
FileUtils.mkdir_p out_folder
|
43
|
+
fname = File.join(out_folder, "#{name}-#{type}.#{ext}")
|
44
|
+
File.open(fname, 'w') do |f|
|
45
|
+
f.write Site.asset_configuration.disclaimer
|
46
|
+
f.write content
|
47
|
+
end
|
39
48
|
end
|
40
49
|
end
|
41
50
|
|
data/lib/pubba/page.rb
CHANGED
@@ -74,7 +74,7 @@ module Pubba
|
|
74
74
|
style_groups do |group, hash|
|
75
75
|
urls = []
|
76
76
|
style_urls(group) do |url|
|
77
|
-
next if
|
77
|
+
next if external?(url)
|
78
78
|
urls << url
|
79
79
|
end
|
80
80
|
Pubba.asset_handler.build(name, group, "css", urls)
|
@@ -85,7 +85,7 @@ module Pubba
|
|
85
85
|
script_groups do |group|
|
86
86
|
urls = []
|
87
87
|
script_urls(group) do |url|
|
88
|
-
next if
|
88
|
+
next if external?(url)
|
89
89
|
urls << url
|
90
90
|
end
|
91
91
|
Pubba.asset_handler.build(name, group, "js", urls)
|
@@ -111,7 +111,7 @@ module Pubba
|
|
111
111
|
def add_style_tag(group, hash, url)
|
112
112
|
h = { tag: 'link', type: 'text/css', rel: 'stylesheet' }
|
113
113
|
h[:media] = hash['media'] if hash['media']
|
114
|
-
h[:href] =
|
114
|
+
h[:href] = external?(url) ? url : "/#{Pubba.style_folder}/#{name}-#{group}.css"
|
115
115
|
h[:id] = hash['id'] if hash['id']
|
116
116
|
|
117
117
|
maybe_add_tag(@head_tags, h, :href)
|
@@ -119,7 +119,7 @@ module Pubba
|
|
119
119
|
|
120
120
|
def add_script_tag(group, url)
|
121
121
|
h = { tag: 'script', type: "text/javascript" }
|
122
|
-
h[:src] =
|
122
|
+
h[:src] = external?(url) ? url : "/#{Pubba.script_folder}/#{name}-#{group}.js"
|
123
123
|
|
124
124
|
tag_set = (group == "head") ? @head_tags : @body_tags
|
125
125
|
maybe_add_tag(tag_set, h, :src)
|
@@ -130,5 +130,9 @@ module Pubba
|
|
130
130
|
tag_set.each{|tag| found = true if tag[key] == hash[key]}
|
131
131
|
tag_set << hash unless found
|
132
132
|
end
|
133
|
+
|
134
|
+
def external?(url)
|
135
|
+
(url.start_with?("http") and not url.start_with?("github:")) ? true : false
|
136
|
+
end
|
133
137
|
end # Page
|
134
138
|
end # Pubba
|
data/lib/pubba/version.rb
CHANGED
data/pubba.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_runtime_dependency('yui-compressor', ['>= 0.9.4'])
|
25
25
|
s.add_runtime_dependency('fssm', ['>= 0.2.7'])
|
26
26
|
s.add_runtime_dependency('statica', ['>= 0.3.0'])
|
27
|
+
s.add_runtime_dependency('octopi', ['>= 0.4.5'])
|
27
28
|
|
28
29
|
s.add_development_dependency('rake', ['>= 0.9.2'])
|
29
30
|
s.add_development_dependency('sinatra', ['>= 1.3.1'])
|
data/test/helper.rb
CHANGED
@@ -1,32 +1,9 @@
|
|
1
1
|
require 'minitest/unit'
|
2
2
|
require 'sinatra/test_helpers'
|
3
|
+
require_relative 'resources'
|
3
4
|
|
4
5
|
MiniTest::Unit.autorun
|
5
6
|
|
6
|
-
module R
|
7
|
-
extend self
|
8
|
-
|
9
|
-
def app_folder
|
10
|
-
File.join(File.dirname(__FILE__), 'sinatra', 'app')
|
11
|
-
end
|
12
|
-
|
13
|
-
def asset_folder
|
14
|
-
File.join(app_folder, 'assets')
|
15
|
-
end
|
16
|
-
|
17
|
-
def r18n_folder
|
18
|
-
File.join(app_folder, 'i18n')
|
19
|
-
end
|
20
|
-
|
21
|
-
def public_folder
|
22
|
-
File.join(File.dirname(__FILE__), 'sinatra', 'public')
|
23
|
-
end
|
24
|
-
|
25
|
-
def pubba_config_file
|
26
|
-
File.join(File.dirname(__FILE__), 'sinatra', 'config', 'pubba.yml')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
7
|
class TestPubba < MiniTest::Unit::TestCase
|
31
8
|
include Sinatra::TestHelpers
|
32
9
|
|
@@ -34,13 +11,13 @@ class TestPubba < MiniTest::Unit::TestCase
|
|
34
11
|
mock_app do
|
35
12
|
require 'pubba'
|
36
13
|
|
37
|
-
settings.set :public_folder,
|
14
|
+
settings.set :public_folder, Resources.public_folder
|
38
15
|
|
39
16
|
Pubba.configure do |p|
|
40
|
-
p.config_file =
|
17
|
+
p.config_file = Resources.pubba_config_file
|
41
18
|
p.public_folder = settings.public_folder
|
42
|
-
p.asset_folder =
|
43
|
-
p.r18n_folder =
|
19
|
+
p.asset_folder = Resources.asset_folder
|
20
|
+
p.r18n_folder = Resources.r18n_folder
|
44
21
|
end
|
45
22
|
|
46
23
|
Pubba::Site.configure
|
@@ -2,17 +2,17 @@ require 'helper'
|
|
2
2
|
|
3
3
|
class TestPubbaAssetsConfiguration < TestPubba
|
4
4
|
def setup
|
5
|
-
@config = Pubba::Assets::Configuration.new(
|
5
|
+
@config = Pubba::Assets::Configuration.new(Resources.pubba_config_file)
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_yaml_is_initialized
|
9
|
-
hsh = {"global"=>{"styles"=>{"all"=>{"urls"=>["http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css", "custom/global"]}, "phone"=>{"media"=>"only screen and (max-width: 480px)", "urls"=>["custom/small"]}, "desktop"=>{"media"=>"only screen and (min-width: 480px)", "urls"=>["custom/large"]}}, "scripts"=>{"head"=>["https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", "third-party/modernizr"], "body"=>["https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js", "
|
9
|
+
hsh = {"global"=>{"styles"=>{"all"=>{"urls"=>["http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css", "custom/global"]}, "phone"=>{"media"=>"only screen and (max-width: 480px)", "urls"=>["custom/small"]}, "desktop"=>{"media"=>"only screen and (min-width: 480px)", "urls"=>["custom/large"]}}, "scripts"=>{"head"=>["https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", "third-party/modernizr"], "body"=>["https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js", "github:documentcloud:underscore:1.2.4:underscore.js", "github:documentcloud:backbone:0.5.3:backbone.js", "custom/app", "custom/tracker"]}}, "home"=>{"styles"=>{"all"=>{"urls"=>["custom/home"]}}}, "search"=>{"styles"=>{"all"=>{"urls"=>["custom/search", "third-party/widget"]}}, "scripts"=>{"body"=>["custom/lightbox"]}}}
|
10
10
|
|
11
11
|
assert_equal hsh, @config.yaml
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_global_config
|
15
|
-
hsh = {"styles"=>{"all"=>{"urls"=>["http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css", "custom/global"]}, "phone"=>{"media"=>"only screen and (max-width: 480px)", "urls"=>["custom/small"]}, "desktop"=>{"media"=>"only screen and (min-width: 480px)", "urls"=>["custom/large"]}}, "scripts"=>{"head"=>["https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", "third-party/modernizr"], "body"=>["https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js", "
|
15
|
+
hsh = {"styles"=>{"all"=>{"urls"=>["http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css", "custom/global"]}, "phone"=>{"media"=>"only screen and (max-width: 480px)", "urls"=>["custom/small"]}, "desktop"=>{"media"=>"only screen and (min-width: 480px)", "urls"=>["custom/large"]}}, "scripts"=>{"head"=>["https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", "third-party/modernizr"], "body"=>["https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js", "github:documentcloud:underscore:1.2.4:underscore.js", "github:documentcloud:backbone:0.5.3:backbone.js", "custom/app", "custom/tracker"]}}
|
16
16
|
|
17
17
|
assert_equal hsh, @config.global_config!
|
18
18
|
|
data/test/pubba/test_page.rb
CHANGED
@@ -16,7 +16,7 @@ class TestPubbaPage < TestPubba
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_home_all_css_asset
|
19
|
-
css = File.open( File.join(
|
19
|
+
css = File.open( File.join(Resources.asset_folder, 'out', 'css', 'home-all.css')){|f| f.read }
|
20
20
|
contents = <<TEXT
|
21
21
|
// This file is automatically generated from the contents
|
22
22
|
// in #{Pubba::Site.asset_configuration.name}
|
@@ -29,7 +29,7 @@ TEXT
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_home_phone_css_asset
|
32
|
-
css = File.open( File.join(
|
32
|
+
css = File.open( File.join(Resources.asset_folder, 'out', 'css', 'home-phone.css')){|f| f.read }
|
33
33
|
contents = <<TEXT
|
34
34
|
// This file is automatically generated from the contents
|
35
35
|
// in #{Pubba::Site.asset_configuration.name}
|
@@ -41,7 +41,7 @@ TEXT
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_home_desktop_css_asset
|
44
|
-
css = File.open( File.join(
|
44
|
+
css = File.open( File.join(Resources.asset_folder, 'out', 'css', 'home-desktop.css')){|f| f.read }
|
45
45
|
contents = <<TEXT
|
46
46
|
// This file is automatically generated from the contents
|
47
47
|
// in #{Pubba::Site.asset_configuration.name}
|
@@ -53,7 +53,7 @@ TEXT
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_search_all_css_asset
|
56
|
-
css = File.open( File.join(
|
56
|
+
css = File.open( File.join(Resources.asset_folder, 'out', 'css', 'search-all.css')){|f| f.read }
|
57
57
|
contents = <<TEXT
|
58
58
|
// This file is automatically generated from the contents
|
59
59
|
// in #{Pubba::Site.asset_configuration.name}
|
@@ -67,7 +67,7 @@ TEXT
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_search_phone_css_asset
|
70
|
-
css = File.open( File.join(
|
70
|
+
css = File.open( File.join(Resources.asset_folder, 'out', 'css', 'search-phone.css')){|f| f.read }
|
71
71
|
contents = <<TEXT
|
72
72
|
// This file is automatically generated from the contents
|
73
73
|
// in #{Pubba::Site.asset_configuration.name}
|
@@ -79,7 +79,7 @@ TEXT
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def test_search_desktop_css_asset
|
82
|
-
css = File.open( File.join(
|
82
|
+
css = File.open( File.join(Resources.asset_folder, 'out', 'css', 'search-desktop.css')){|f| f.read }
|
83
83
|
contents = <<TEXT
|
84
84
|
// This file is automatically generated from the contents
|
85
85
|
// in #{Pubba::Site.asset_configuration.name}
|
@@ -91,7 +91,7 @@ TEXT
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def test_home_head_js_asset
|
94
|
-
js = File.open( File.join(
|
94
|
+
js = File.open( File.join(Resources.asset_folder, 'out', 'js', 'home-head.js')){|f| f.read }
|
95
95
|
contents = <<TEXT
|
96
96
|
// This file is automatically generated from the contents
|
97
97
|
// in #{Pubba::Site.asset_configuration.name}
|
@@ -103,12 +103,13 @@ TEXT
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def test_home_body_js_asset
|
106
|
-
js = File.open( File.join(
|
106
|
+
js = File.open( File.join(Resources.asset_folder, 'out', 'js', 'home-body.js')){|f| f.read }
|
107
107
|
contents = <<TEXT
|
108
108
|
// This file is automatically generated from the contents
|
109
109
|
// in #{Pubba::Site.asset_configuration.name}
|
110
110
|
//
|
111
|
-
//= require
|
111
|
+
//= require github/documentcloud/underscore.js
|
112
|
+
//= require github/documentcloud/backbone.js
|
112
113
|
//= require custom/app.js
|
113
114
|
//= require custom/tracker.js
|
114
115
|
TEXT
|
@@ -117,7 +118,7 @@ TEXT
|
|
117
118
|
end
|
118
119
|
|
119
120
|
def test_search_head_js_asset
|
120
|
-
js = File.open( File.join(
|
121
|
+
js = File.open( File.join(Resources.asset_folder, 'out', 'js', 'search-head.js')){|f| f.read }
|
121
122
|
contents = <<TEXT
|
122
123
|
// This file is automatically generated from the contents
|
123
124
|
// in #{Pubba::Site.asset_configuration.name}
|
@@ -129,12 +130,13 @@ TEXT
|
|
129
130
|
end
|
130
131
|
|
131
132
|
def test_search_body_js_asset
|
132
|
-
js = File.open( File.join(
|
133
|
+
js = File.open( File.join(Resources.asset_folder, 'out', 'js', 'search-body.js')){|f| f.read }
|
133
134
|
contents = <<TEXT
|
134
135
|
// This file is automatically generated from the contents
|
135
136
|
// in #{Pubba::Site.asset_configuration.name}
|
136
137
|
//
|
137
|
-
//= require
|
138
|
+
//= require github/documentcloud/underscore.js
|
139
|
+
//= require github/documentcloud/backbone.js
|
138
140
|
//= require custom/app.js
|
139
141
|
//= require custom/tracker.js
|
140
142
|
//= require custom/lightbox.js
|
data/test/pubba/test_site.rb
CHANGED
@@ -10,11 +10,11 @@ class TestPubbaSite < TestPubba
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_asset_folder_initialization
|
13
|
-
assert_equal "#{
|
13
|
+
assert_equal "#{Resources.asset_folder}", Pubba.asset_folder
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_public_folder_initialization
|
17
|
-
assert_equal "#{
|
17
|
+
assert_equal "#{Resources.public_folder}", Pubba.public_folder
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_script_folder_initialization
|
data/test/resources.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
module Resources
|
2
|
+
extend self
|
3
|
+
|
4
|
+
def app_folder
|
5
|
+
File.join(File.dirname(__FILE__), 'sinatra', 'app')
|
6
|
+
end
|
7
|
+
|
8
|
+
def asset_folder
|
9
|
+
File.join(app_folder, 'assets')
|
10
|
+
end
|
11
|
+
|
12
|
+
def r18n_folder
|
13
|
+
File.join(app_folder, 'i18n')
|
14
|
+
end
|
15
|
+
|
16
|
+
def public_folder
|
17
|
+
File.join(File.dirname(__FILE__), 'sinatra', 'public')
|
18
|
+
end
|
19
|
+
|
20
|
+
def public_js_folder
|
21
|
+
File.join(File.dirname(__FILE__), 'sinatra', 'public', 'js')
|
22
|
+
end
|
23
|
+
|
24
|
+
def public_css_folder
|
25
|
+
File.join(File.dirname(__FILE__), 'sinatra', 'public', 'css')
|
26
|
+
end
|
27
|
+
|
28
|
+
def pubba_config_file
|
29
|
+
File.join(File.dirname(__FILE__), 'sinatra', 'config', 'pubba.yml')
|
30
|
+
end
|
31
|
+
|
32
|
+
def out_js_folder
|
33
|
+
File.join(asset_folder, 'out', 'js')
|
34
|
+
end
|
35
|
+
|
36
|
+
def out_css_folder
|
37
|
+
File.join(asset_folder, 'out', 'css')
|
38
|
+
end
|
39
|
+
|
40
|
+
def clean
|
41
|
+
Dir.glob(Resources.public_js_folder + "/*.js").each do |entry|
|
42
|
+
$>.print "deleting: #{entry}\n"
|
43
|
+
File.delete(entry)
|
44
|
+
end
|
45
|
+
|
46
|
+
Dir.glob(Resources.public_css_folder + "/*.css").each do |entry|
|
47
|
+
$>.print "deleting: #{entry}\n"
|
48
|
+
File.delete(entry)
|
49
|
+
end
|
50
|
+
|
51
|
+
Dir.glob(Resources.out_js_folder + "/*.js").each do |entry|
|
52
|
+
$>.print "deleting: #{entry}\n"
|
53
|
+
File.delete(entry)
|
54
|
+
end
|
55
|
+
|
56
|
+
Dir.glob(Resources.out_css_folder + "/*.css").each do |entry|
|
57
|
+
$>.print "deleting: #{entry}\n"
|
58
|
+
File.delete(entry)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|