Sha256: 06636311d3a8b9613a4a216f2d0cee8ef3bcf67146aa7912c88fff73b49ca95b
Contents?: true
Size: 1.26 KB
Versions: 5
Compression:
Stored size: 1.26 KB
Contents
require 'netrc' module Devcenter::Helpers def devcenter_base_url ENV['DEVCENTER_BASE_URL'] || 'https://devcenter.heroku.com' end def broken_link_checks_path '/api/v1/private/broken-link-checks.json' end def article_path(slug) "/articles/#{slug}" end def article_api_path(slug) "#{article_path(slug)}.json" end def search_api_path "/articles.json" end def validate_article_path(id) "/api/v1/private/articles/#{id}/validate.json" end def update_article_path(id) "/api/v1/private/articles/#{id}.json" end def article_url?(url) escaped_base_url = devcenter_base_url.gsub('/','\\/') url.match(/\A#{escaped_base_url}\/articles\/.+/) true end def slug_from_article_url(url) return nil unless url url.split('/articles/').last.split('?').first.split('#').first end def md_file_path(slug) File.expand_path("#{slug}.md") end def html_file_path(slug) File.expand_path("#{slug}.html") end def write_file(filename, content) File.open(filename, 'w'){ |f| f.write(content) } end def get_oauth_token netrc = Netrc.read user, token = netrc['api.heroku.com'] abort 'Heroku credentials not found. Execute "heroku login" to create them.' unless token token end end
Version data entries
5 entries across 5 versions & 1 rubygems