Sha256: 3cda231ba8e5462a66f14887c76699fcfc06e1fd477ffc5fc794a8d366732f41

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

module Integrity
  module Helpers
    module Urls
      def url(path)
        url = "#{request.scheme}://#{request.host}"

        if request.scheme == "https" && request.port != 443 ||
            request.scheme == "http" && request.port != 80
          url << ":#{request.port}"
        end

        url << "/" unless path.index("/").zero?
        url << path
      end

      def root_url
        url("/")
      end

      def project_path(project, *path)
        "/" << [project.permalink, *path].join("/")
      end

      def project_url(project, *path)
        url project_path(project, *path)
      end

      def push_url_for(project)
        Addressable::URI.parse(project_url(project, "push")).tap do |url|
          if Integrity.config[:use_basic_auth]
            url.user     = Integrity.config[:admin_username]
            url.password = Integrity.config[:hash_admin_password] ?
              "<password>" : Integrity.config[:admin_password]
          end
        end.to_s
      end

      def build_path(build)
        "/#{build.project.permalink}/builds/#{build.commit_identifier}"
      end

      def build_url(build)
        url build_path(build)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
brycethornton-integrity-0.1.7.1 lib/integrity/helpers/urls.rb
foca-integrity-0.1.6 lib/integrity/helpers/urls.rb
foca-integrity-0.1.7 lib/integrity/helpers/urls.rb
foca-integrity-0.1.8 lib/integrity/helpers/urls.rb
myronmarston-integrity-0.1.7.1 lib/integrity/helpers/urls.rb
integrity-0.1.8 lib/integrity/helpers/urls.rb