Class: Shack::ShackRails

Inherits:
Object
  • Object
show all
Defined in:
lib/shack/railtie.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ShackRails

Returns a new instance of ShackRails.



9
10
11
# File 'lib/shack/railtie.rb', line 9

def initialize(app)
  @app = app
end

Instance Method Details

#fetch_sha_from_file?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/shack/railtie.rb', line 29

def fetch_sha_from_file?
  Shack::Middleware.sha.blank? && File.exist?(revision_file)
end

#inject!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/shack/railtie.rb', line 13

def inject!
  if Rails.env.production?
    # Don't show the stamp in production, but do add it to the headers
    Shack::Middleware.configure do |shack|
      shack.hide_stamp = true
    end
  end

  if fetch_sha_from_file?
    Shack::Middleware.configure do |shack|
      shack.sha = File.open(revision_file).read.strip
    end
  end
  @app.middleware.use(Shack::Middleware)
end

#revision_fileObject



33
34
35
# File 'lib/shack/railtie.rb', line 33

def revision_file
  File.join(Rails.root, "REVISION")
end