class Pendulum::Command::Apply::ResultURL
Attributes
client[RW]
from[RW]
to[RW]
Public Class Methods
new(client, from, to)
click to toggle source
# File lib/pendulum/command/apply/result_url.rb, line 5 def initialize(client, from, to) self.client = client self.from = from self.to = to end
Public Instance Methods
changed?()
click to toggle source
# File lib/pendulum/command/apply/result_url.rb, line 11 def changed? if from.start_with?('{') json_changed? else url_changed? end end
Private Instance Methods
json_changed?()
click to toggle source
# File lib/pendulum/command/apply/result_url.rb, line 21 def json_changed? to_json = JSON.parse(to) name = to_json['type'] result = result_by(name) to_json = JSON.parse(result.url) if result to_json.delete('apikey') JSON.parse(from) != to_json end
mask(uri)
click to toggle source
# File lib/pendulum/command/apply/result_url.rb, line 41 def mask(uri) uri.password = '***' if uri.user uri end
query_hash(uri)
click to toggle source
# File lib/pendulum/command/apply/result_url.rb, line 50 def query_hash(uri) Hash[URI::decode_www_form(uri.query || '')] end
result_by(name)
click to toggle source
# File lib/pendulum/command/apply/result_url.rb, line 78 def result_by(name) results.find{|r| name == r.name} end
results()
click to toggle source
# File lib/pendulum/command/apply/result_url.rb, line 74 def results @results ||= client.results end
to_uri(url)
click to toggle source
# File lib/pendulum/command/apply/result_url.rb, line 54 def to_uri(url) return URI.parse(url) if ( url.empty? || url.include?('://') ) # use result name, table = url.split(':', 2) table, query = table.split('?', 2) result = result_by(name) return URI.parse(url) unless result uri = URI.parse(result.url) uri.path += "/#{table}" if uri.query uri.query += "&#{query}" else uri.query = query end uri end
uri_without_query(uri)
click to toggle source
# File lib/pendulum/command/apply/result_url.rb, line 46 def uri_without_query(uri) uri.to_s.split('?').first end
url_changed?()
click to toggle source
# File lib/pendulum/command/apply/result_url.rb, line 33 def url_changed? from_uri = to_uri(from) to_uri = mask(to_uri(to)) uri_without_query(from_uri) != uri_without_query(to_uri) || query_hash(from_uri) != query_hash(to_uri) end