module Trav3
Trav3
project namespace
Constants
- VERSION
Public Instance Methods
cron_keys(hash)
click to toggle source
# File lib/trav3.rb, line 3713 def cron_keys(hash) inject_property_name('cron', hash) end
delete(url)
click to toggle source
# File lib/trav3.rb, line 3717 def delete(url) Trav3::REST.delete(self, url) end
dig(opt)
click to toggle source
# File lib/trav3/pagination.rb, line 35 def dig(opt) @result.dig(opt) end
env_var_keys(hash)
click to toggle source
# File lib/trav3.rb, line 3721 def env_var_keys(hash) inject_property_name('env_var', hash) end
get(url, raw_reply = false)
click to toggle source
# File lib/trav3.rb, line 3725 def get(url, raw_reply = false) Trav3::REST.get(self, url, raw_reply) end
get_path(url)
click to toggle source
# File lib/trav3.rb, line 3729 def get_path(url) get("#{without_repo}#{url}") end
get_path_with_opts(url, without_limit = true)
click to toggle source
# File lib/trav3.rb, line 3733 def get_path_with_opts(url, without_limit = true) url, opt = url.match(/^(.+)\?(.*)$/)&.captures || url opts.immutable do |o| o.remove(:limit) if without_limit o.send(:update, opt) get_path("#{url}#{opts}") end end
initial_defaults()
click to toggle source
# File lib/trav3.rb, line 3742 def initial_defaults defaults(limit: 25) h('Content-Type': 'application/json') h('Accept': 'application/json') h('Travis-API-Version': 3) end
inject_property_name(name, hash)
click to toggle source
# File lib/trav3.rb, line 3749 def inject_property_name(name, hash) raise TypeError, "Hash expected, #{input.class} given" unless hash.is_a? Hash return hash.map { |k, v| ["#{name}.#{k}", v] }.to_h unless hash.keys.first.match?(/^#{name}\.\w+$/) hash end
key_pair_keys(hash)
click to toggle source
# File lib/trav3.rb, line 3756 def key_pair_keys(hash) inject_property_name('key_pair', hash) end
number?(input)
click to toggle source
# File lib/trav3.rb, line 3760 def number?(input) /^\d+$/.match? input.to_s end
opts()
click to toggle source
# File lib/trav3.rb, line 3764 def opts @options end
parse(other)
click to toggle source
# File lib/trav3/options.rb, line 121 def parse(other) return other.split('&').map(&split).to_h if other.is_a? String other.map(&split).to_h end
patch(url, data)
click to toggle source
# File lib/trav3.rb, line 3768 def patch(url, data) Trav3::REST.patch(self, url, data) end
post(url, body = nil)
click to toggle source
# File lib/trav3.rb, line 3772 def post(url, body = nil) Trav3::REST.post(self, url, body) end
repo_slug_or_id?(input)
click to toggle source
# File lib/trav3.rb, line 3792 def repo_slug_or_id?(input) Regexp.new(/(^\d+$)|(^[A-Za-z0-9_.-]+(?:\/|%2F){1}[A-Za-z0-9_.-]+$)/i).match? input end
repository_name()
click to toggle source
# File lib/trav3.rb, line 3796 def repository_name @repo end
sanitize_repo_name(repo)
click to toggle source
# File lib/trav3.rb, line 3800 def sanitize_repo_name(repo) repo.to_s.gsub(/\//, '%2F') end
update(other)
click to toggle source
# File lib/trav3/options.rb, line 127 def update(other) return self unless other build(parse(other)) end
username()
click to toggle source
# File lib/trav3.rb, line 3804 def username @repo[/.*?(?=(?:\/|%2F)|$)/] end
validate_api_endpoint(input)
click to toggle source
# File lib/trav3.rb, line 3776 def validate_api_endpoint(input) raise InvalidAPIEndpoint unless /^https:\/\/api\.travis-ci\.(?:org|com)$/.match? input end
validate_number(input)
click to toggle source
# File lib/trav3.rb, line 3780 def validate_number(input) raise TypeError, "Integer expected, #{input.class} given" unless number? input end
validate_repo_format(input)
click to toggle source
# File lib/trav3.rb, line 3784 def validate_repo_format(input) raise InvalidRepository unless repo_slug_or_id? input end
validate_string(input)
click to toggle source
# File lib/trav3.rb, line 3788 def validate_string(input) raise TypeError, "String expected, #{input.class} given" unless input.is_a? String end
with_repo()
click to toggle source
# File lib/trav3.rb, line 3808 def with_repo "#{api_endpoint}/repo/#{@repo}" end
without_limit() { || ... }
click to toggle source
# File lib/trav3.rb, line 3816 def without_limit limit = opts.remove(:limit) result = yield opts.build(limit: limit) if limit result end
without_repo()
click to toggle source
# File lib/trav3.rb, line 3812 def without_repo api_endpoint end