"showoff static" fails with error #117

Closed
badboy opened this Issue Aug 23, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@badboy
Contributor

badboy commented Aug 23, 2011

When executing showoff static I get:

error: undefined method `verbose' for ShowOff:Class

This is due to line 46 in lib/showoff.rb.

A quick fixed that works for me is adding "options" as an OpenStruct:

diff --git i/lib/showoff.rb w/lib/showoff.rb
index 103f182..2f0b881 100644
--- i/lib/showoff.rb
+++ w/lib/showoff.rb
@@ -356,6 +356,13 @@ class ShowOff < Sinatra::Application
    def self.do_static(what)
       what = "index" if !what

+      self.class_eval do
+        require 'ostruct'
+        def options
+          @options ||= OpenStruct.new
+        end
+      end
+
       # Nasty hack to get the actual ShowOff module
       showoff = ShowOff.new
       while !showoff.is_a?(ShowOff)

but this seems like a nasty hack. Any ideas how to handle this in a proper way?

@davetron5000

This comment has been minimized.

Show comment Hide comment
@davetron5000

davetron5000 Aug 23, 2011

Contributor

I'm having a hard time seeing how this ever worked; when I remove the verbose stuff, it just bombs on the next thing.

It seems like a big flaw in the design; the static stuff creates an instance of ShowOff just to get at the options hash, which is managed by Sinatra somehow. Your fix is probably the thing least likely to break something, but since there's no tests, I'd be afraid to do something more drastic.

Contributor

davetron5000 commented Aug 23, 2011

I'm having a hard time seeing how this ever worked; when I remove the verbose stuff, it just bombs on the next thing.

It seems like a big flaw in the design; the static stuff creates an instance of ShowOff just to get at the options hash, which is managed by Sinatra somehow. Your fix is probably the thing least likely to break something, but since there's no tests, I'd be afraid to do something more drastic.

@badboy

This comment has been minimized.

Show comment Hide comment
@badboy

badboy Aug 23, 2011

Contributor

Yep, this is really flawed. I will definitely look into it tonight or tomorrow (exporting static versions is the thing I really need, so this bugs me).
Maybe I will have to rewrite the whole damn thing, let's se...

Contributor

badboy commented Aug 23, 2011

Yep, this is really flawed. I will definitely look into it tonight or tomorrow (exporting static versions is the thing I really need, so this bugs me).
Maybe I will have to rewrite the whole damn thing, let's se...

@badboy badboy closed this Jan 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment