Sha256: 27246ac7e5ea288f7e6a9b90991f7b7974ec663a502f186a79123edf343e0d3d

Contents?: true

Size: 1.44 KB

Versions: 6

Compression:

Stored size: 1.44 KB

Contents

#
# Copyright 2011 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

module StompBox
  class Application < Sinatra::Base 
    
    helpers do 
  
      def config(key)
        ENV[key]
      end
  
      def home_path
        request.script_name
      end

      def push_path
        port = request.port == 80 ? "" : ":#{request.port}"
        request.scheme + "://" + request.host + port + to( "push/#{config('API_KEY')}" )
      end
  
      def to(location)
        location.gsub!(/^\//, '')
        "#{home_path}/#{location}"
      end
  
      def repositories
        @repositories ||= Repository.ordered
      end
  
      def classes_for(push)
        track = push.tracked? ? 'tracked' : 'ignored'
        [push.status, track, classify(push.repo_name), classify(push.branch)]
      end
  
      def selector_for(push)
        classes_for(push).join('.')
      end
  
      def classify(str)
        str.gsub('.', '-')
      end
  
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
torquebox-stompbox-0.3.3 app/helpers.rb
torquebox-stompbox-0.3.2 app/helpers.rb
torquebox-stompbox-0.3.1 app/helpers.rb
torquebox-stompbox-0.3.0 app/helpers.rb
torquebox-stompbox-0.2.0 app/helpers.rb
torquebox-stompbox-0.1.0 app/helpers.rb