Sha256: 64924ffe52a93bc60001df6baf4c16aa2e3b0aba51e46081c5d657280240d1f4

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'oauth'
require 'json'
require 'haml/util'
require 'haml/engine'
require 'curb'
require 'logger'

require 'dm-core'
require 'dm-validations'
require 'dm-timestamps'
require 'sinatra/base'

module <%= name.camelize %>
  module Log
    def self.logger
      if @logger.nil?
        @logger        = Logger.new("<%= name %>.log")
        @logger.level  = Logger::INFO
      end
      @logger
    end
  end

  module OAuth
    def self.consumer
      ::OAuth::Consumer.new(ENV['<%= name.upcase %>_READKEY'],
                            ENV['<%= name.upcase %>_READSECRET'],
                            {:site => 'http://twitter.com'})
    end
  end

  def self.retryable(options = {}, &block)
    opts = { :tries => 1, :on => StandardError }.merge(options)
    retry_exception, retries = opts[:on], opts[:tries]

    begin
      return yield
    rescue retry_exception
      retry if (retries -= 1) > 0
    end
    yield
  end

  def self.app
    @app ||= Rack::Builder.new do
      # use Rack::Hoptoad 'mysecretkey'
      use Rack::Session::Cookie, :key => 'rack.session', :path => '/',
        :expire_after => 2592000, :secret => '<%= ::Digest::SHA1.hexdigest(Time.now.to_s) %>'
      run <%= name.camelize %>::App
    end
  end
end

require File.dirname(__FILE__)+'/<%= name %>/app'
require File.dirname(__FILE__)+'/<%= name %>/models/user'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
singem-0.2.0 lib/generators/twitter/templates/lib/templates.rb.erb
singem-0.1.2 lib/generators/twitter/templates/lib/templates.rb.erb