Sha256: 9578503fbfca932440c2aa9cb2953f74485ae16d0254c6f3203f0b0096e538f7

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 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::HoptoadNotifier '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

5 entries across 5 versions & 1 rubygems

Version Path
singem-0.1.1 lib/generators/twitter/templates/lib/templates.rb.erb
singem-0.1.0 lib/generators/twitter/templates/lib/templates.rb.erb
singem-0.0.7 lib/generators/twitter/templates/lib/templates.rb.erb
singem-0.0.6 lib/generators/twitter/templates/lib/templates.rb.erb
singem-0.0.5 lib/generators/twitter/templates/lib/templates.rb.erb