Module: Copybar

Defined in:
lib/copybar.rb,
lib/copybar/version.rb

Constant Summary collapse

COPYBAR_HOST =
"copybar.io"
VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.build_uri(username, element_path, options = {}) ⇒ Object



7
8
9
10
11
# File 'lib/copybar.rb', line 7

def self.build_uri(username, element_path, options = {})
  query_string = "?edit=true" if options[:edit]

  "http://#{COPYBAR_HOST}/#{username}/#{element_path}#{query_string}"
end

.read(username, element_path, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/copybar.rb', line 13

def self.read(username, element_path, options = {})
  html = open(build_uri(username, element_path, options)).read

  # return html safe string
  if html.respond_to?(:html_safe)
    html.html_safe
  else
    html
  end
end