schacon / showoff

moved to puppetlabs/showoff!
2.41k stars 13 forks source link

"showoff static" fails with error #117

Closed badboy closed 8 years ago

badboy commented 13 years ago

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 commented 13 years ago

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 commented 13 years ago

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...