Sha256: 45e53dc4d6e3801940bd76722f58fbfddec6325e8b24fbc1d3a81a4e7ac94db1

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

module Integrity
  module Helpers
    module Urls
      def url(path)
        Addressable::URI.parse(request.url).join(path).to_s
      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 commit_path(commit, *path)
        project_path(commit.project, "commits", commit.identifier, *path)
      end

      def build_path(build, *path)
        warn "#build_path is deprecated, use #commit_path instead"
        commit_path build.commit, *path
      end

      def commit_url(commit)
        url commit_path(commit)
      end

      def build_url(build)
        warn "#build_url is deprecated, use #commit_url instead"
        commit_url build.commit
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 4 rubygems

Version Path
foca-integrity-0.1.9.0 lib/integrity/helpers/urls.rb
foca-integrity-0.1.9.1 lib/integrity/helpers/urls.rb
oliyoung-integrity-0.1.9.0 lib/integrity/helpers/urls.rb
sr-integrity-0.1.8.1 lib/integrity/helpers/urls.rb
sr-integrity-0.1.9.1 lib/integrity/helpers/urls.rb
sr-integrity-0.1.9.2 lib/integrity/helpers/urls.rb
integrity-0.1.9.1 lib/integrity/helpers/urls.rb
integrity-0.1.9.0 lib/integrity/helpers/urls.rb
integrity-0.1.9 lib/integrity/helpers/urls.rb