kelredd-sinatra-helpers 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/sinatra_helpers.rb +1 -2
- data/lib/sinatra_helpers/generator/file_templates/boot.rb.erb +2 -2
- data/lib/sinatra_helpers/less.rb +9 -12
- data/lib/sinatra_helpers/less/config.rb +1 -2
- data/lib/sinatra_helpers/sprockets.rb +0 -3
- data/lib/sinatra_helpers/sprockets/config.rb +2 -3
- data/lib/sinatra_helpers/version.rb +1 -1
- metadata +1 -1
data/lib/sinatra_helpers.rb
CHANGED
@@ -7,7 +7,6 @@ module SinatraHelpers
|
|
7
7
|
:not_found => 404,
|
8
8
|
:ok => 200
|
9
9
|
}
|
10
|
-
DEFAULT_CACHE_CONTROL = 'public, max-age=86400' # cache for 24 hours
|
11
10
|
|
12
11
|
class << self
|
13
12
|
|
@@ -15,7 +14,7 @@ module SinatraHelpers
|
|
15
14
|
if defined?(Rails)
|
16
15
|
Rails.configuration.action_controller.perform_caching
|
17
16
|
elsif app.respond_to?(:environment)
|
18
|
-
app.environment == 'production'
|
17
|
+
app.environment.to_s == 'production'
|
19
18
|
else
|
20
19
|
false
|
21
20
|
end
|
@@ -9,9 +9,9 @@ def public_path(*args)
|
|
9
9
|
root_path('public', *args)
|
10
10
|
end
|
11
11
|
|
12
|
+
require 'config/env'
|
12
13
|
begin
|
13
|
-
require "config/
|
14
|
+
require "config/envs/#{RACK_ENV.downcase}"
|
14
15
|
rescue LoadError => err
|
15
16
|
puts "no environment config set up for '#{RACK_ENV.downcase}', ignoring..."
|
16
17
|
end
|
17
|
-
require 'config/environment'
|
data/lib/sinatra_helpers/less.rb
CHANGED
@@ -39,30 +39,27 @@ module SinatraHelpers::Less
|
|
39
39
|
end
|
40
40
|
|
41
41
|
app.get "#{SinatraHelpers::Less[:hosted_root]}/*.css" do
|
42
|
-
|
42
|
+
file_name = params['splat'].first.to_s
|
43
43
|
less_path = File.join([
|
44
|
-
app.root, SinatraHelpers::Less[:src_root], "#{
|
44
|
+
app.root, SinatraHelpers::Less[:src_root], "#{file_name}.less"
|
45
45
|
])
|
46
46
|
css_path = File.join([
|
47
|
-
app.root, SinatraHelpers::Less[:src_root], "#{
|
47
|
+
app.root, SinatraHelpers::Less[:src_root], "#{file_name}.css"
|
48
48
|
])
|
49
49
|
|
50
50
|
content_type CONTENT_TYPE
|
51
|
-
if SinatraHelpers.page_cache?(SinatraHelpers::Less.app)
|
52
|
-
headers['Cache-Control'] = SinatraHelpers::Less[:cache_control]
|
53
|
-
end
|
54
51
|
|
55
52
|
if File.exists?(less_path)
|
56
|
-
SinatraHelpers::Less.compile(
|
53
|
+
SinatraHelpers::Less.compile(file_name, [less_path])
|
57
54
|
elsif File.exists?(css_path)
|
58
|
-
SinatraHelpers::Less.compile(
|
59
|
-
elsif SinatraHelpers::Less[:concat].include?(
|
60
|
-
less_paths = SinatraHelpers::Less[:concat][
|
61
|
-
File.join(app.root, SinatraHelpers::Less[:src_root], "#{
|
55
|
+
SinatraHelpers::Less.compile(file_name, [css_path])
|
56
|
+
elsif SinatraHelpers::Less[:concat].include?(file_name)
|
57
|
+
less_paths = SinatraHelpers::Less[:concat][file_name].collect do |concat_name|
|
58
|
+
File.join(app.root, SinatraHelpers::Less[:src_root], "#{concat_name}.less")
|
62
59
|
end.select do |less_path|
|
63
60
|
File.exists?(less_path)
|
64
61
|
end
|
65
|
-
SinatraHelpers::Less.compile(
|
62
|
+
SinatraHelpers::Less.compile(file_name, less_paths)
|
66
63
|
else
|
67
64
|
halt SinatraHelpers::HTTP_STATUS[:not_found]
|
68
65
|
end
|
@@ -2,12 +2,11 @@ module SinatraHelpers; end
|
|
2
2
|
module SinatraHelpers::Less
|
3
3
|
|
4
4
|
class Config
|
5
|
-
ATTRIBUTES = [:hosted_root, :src_root, :concat, :
|
5
|
+
ATTRIBUTES = [:hosted_root, :src_root, :concat, :compress]
|
6
6
|
DEFAULTS = {
|
7
7
|
:hosted_root => '/stylesheets',
|
8
8
|
:src_root => 'app/stylesheets',
|
9
9
|
:concat => {},
|
10
|
-
:cache_control => SinatraHelpers::DEFAULT_CACHE_CONTROL,
|
11
10
|
:compress => false
|
12
11
|
}
|
13
12
|
|
@@ -58,9 +58,6 @@ module SinatraHelpers::Sprockets
|
|
58
58
|
src_path = File.join(app.root, src_file_path)
|
59
59
|
|
60
60
|
content_type CONTENT_TYPE
|
61
|
-
if SinatraHelpers.page_cache?(SinatraHelpers::Sprockets.app)
|
62
|
-
headers['Cache-Control'] = SinatraHelpers::Sprockets[:cache_control]
|
63
|
-
end
|
64
61
|
|
65
62
|
if File.exists?(src_path)
|
66
63
|
SinatraHelpers::Sprockets.compile(src_file_path)
|
@@ -2,13 +2,12 @@ module SinatraHelpers; end
|
|
2
2
|
module SinatraHelpers::Sprockets
|
3
3
|
|
4
4
|
class Config
|
5
|
-
ATTRIBUTES = [:hosted_root, :src_root, :load_path, :expand_paths
|
5
|
+
ATTRIBUTES = [:hosted_root, :src_root, :load_path, :expand_paths]
|
6
6
|
DEFAULTS = {
|
7
7
|
:hosted_root => '/javascripts',
|
8
8
|
:src_root => 'app/javascripts',
|
9
9
|
:load_path => ['app/javascripts/**', 'vendor/javascripts', 'vendor/sprockets'],
|
10
|
-
:expand_paths => true
|
11
|
-
:cache_control => SinatraHelpers::DEFAULT_CACHE_CONTROL
|
10
|
+
:expand_paths => true
|
12
11
|
}
|
13
12
|
|
14
13
|
attr_accessor *ATTRIBUTES
|