aportnov (owner)

Revisions

gist: 141220 Download_button fork
public
Public Clone URL: git://gist.github.com/141220.git
Embed All Files: show embed
sinatra-componets.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Components
  
  components_path = File.expand_path(File.dirname(__FILE__) + '/components')
 
  files = Dir.new(components_path).select{|f| f =~ /.*\.rb/ } || []
  files.each do |f|
    body = File.new(File.join([components_path, f])).read
    name = File.basename(f, '.rb').capitalize + "Helper"
    module_eval <<-"end;"
      module #{name}
        #{body}
      end
    end;
    Sinatra.helpers(const_get(name))
  end
 
end