kelredd-sinatra-helpers 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -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/environments/#{RACK_ENV.downcase}"
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'
@@ -39,30 +39,27 @@ module SinatraHelpers::Less
39
39
  end
40
40
 
41
41
  app.get "#{SinatraHelpers::Less[:hosted_root]}/*.css" do
42
- css_name = params['splat'].first.to_s
42
+ file_name = params['splat'].first.to_s
43
43
  less_path = File.join([
44
- app.root, SinatraHelpers::Less[:src_root], "#{css_name}.less"
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], "#{css_name}.css"
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(css_name, [less_path])
53
+ SinatraHelpers::Less.compile(file_name, [less_path])
57
54
  elsif File.exists?(css_path)
58
- SinatraHelpers::Less.compile(css_name, [css_path])
59
- elsif SinatraHelpers::Less[:concat].include?(css_name)
60
- less_paths = SinatraHelpers::Less[:concat][css_name].collect do |css_name|
61
- File.join(app.root, SinatraHelpers::Less[:src_root], "#{css_name}.less")
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(css_name, less_paths)
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, :cache_control, :compress]
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, :cache_control]
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
@@ -3,7 +3,7 @@ module SinatraHelpers
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- TINY = 5
6
+ TINY = 6
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kelredd-sinatra-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding