Sha256: 907a5d1c1954649f3fb398f0fe4e03e88f7f2bb6cc8f15ce536a8b944c3cff05
Contents?: true
Size: 819 Bytes
Versions: 13
Compression:
Stored size: 819 Bytes
Contents
module Devcenter::Helpers def devcenter_base_url ENV['DEVCENTER_BASE_URL'] || 'https://devcenter.heroku.com' 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 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 end
Version data entries
13 entries across 13 versions & 1 rubygems