Class: GG
- Defined in:
- lib/gg.rb,
lib/gg/railtie.rb,
lib/gg/version.rb,
lib/gg/rack_plugin.rb
Defined Under Namespace
Classes: DemoApp, Logger, Railtie, Stack, StackLine, State
Constant Summary collapse
- VERSION =
"0.9.13"
- MAX_HISTORY =
10
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#history ⇒ Object
readonly
Returns the value of attribute history.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ GG
constructor
A new instance of GG.
Constructor Details
#initialize(app) ⇒ GG
Returns a new instance of GG.
3 4 5 6 |
# File 'lib/gg/rack_plugin.rb', line 3 def initialize( app ) @app = app @history = [] end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
10 11 12 |
# File 'lib/gg/rack_plugin.rb', line 10 def app @app end |
#history ⇒ Object (readonly)
Returns the value of attribute history.
10 11 12 |
# File 'lib/gg/rack_plugin.rb', line 10 def history @history end |
Class Method Details
.path(subpath) ⇒ Object
22 23 24 |
# File 'lib/gg.rb', line 22 def self.path( subpath ) File.join( root, subpath ) end |
.render(subpath, scope = nil, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gg.rb', line 26 def self.render( subpath, scope=nil, &block ) Tilt.new( GG.path( subpath ) ).render( scope, &block ) # if scope # Tilt.new( GG.path( subpath ) ).render( scope, &block ) # elsif block_given? # Tilt.new( GG.path( subpath ) ).render( &block ) # else # raise ArgumentError, "Must provide one of scope or block" # end end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gg/rack_plugin.rb', line 12 def call( env ) case env[ 'PATH_INFO' ] when '/gg/history' render_history( 0 ) when %r{/gg/history/([0-9])} render_history( $~[1].to_i ) when '/gg/main.css' [ 200, { 'Content-Type' => 'text/css' }, [ File.read(File.join(File.dirname(__FILE__),'public/gg.css'))] ] else render_app( env ) end end |