Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Trim whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mathias committed Nov 21, 2014
1 parent dff69be commit 7747ba8
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions bin/kensa
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ COMMANDS

TEST TYPES

provision [optional params]
provision [optional params]
Simulate a provision call from Heroku.
[optional params]
accepts extra command options and passes them on to the provision request
Expand All @@ -87,6 +87,6 @@ TEST TYPES
Confirm that the manifest is valid. Automatically runs before all tests.

all
runs provision, planchange, and deprovision tests.
runs provision, planchange, and deprovision tests.
defaults to using 'foo' for planchange plan.

10 changes: 5 additions & 5 deletions lib/heroku/kensa/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def call!
end
end

if data["api"].has_key?("config_vars")
if data["api"].has_key?("config_vars")
check "contains config_vars array" do
data["api"]["config_vars"].is_a?(Array)
end
Expand Down Expand Up @@ -189,7 +189,7 @@ def call!
end

check "all keys in the manifest are present" do
difference = data['api']['config_vars'] - response['config'].keys
difference = data['api']['config_vars'] - response['config'].keys
unless difference.empty?
verb = (difference.size == 1) ? "is" : "are"
print "\n\t", yellow( "#{difference.join(', ')} #{verb} missing from the manifest")
Expand Down Expand Up @@ -280,7 +280,7 @@ def call!
payload = {
:heroku_id => heroku_id,
:plan => data[:plan] || 'test',
:callback_url => callback,
:callback_url => callback,
:logplex_token => nil,
:region => "amazon-web-services::us-east-1",
:options => data[:options] || {}
Expand Down Expand Up @@ -456,7 +456,7 @@ def call!

check "validates token" do
@sso.token = 'invalid'
page, respcode = mechanize_get
page, respcode = mechanize_get
error("expected 403, got #{respcode}") unless respcode == 403
true
end
Expand All @@ -470,7 +470,7 @@ def call!

page_logged_in = nil
check "logs in" do
page_logged_in, respcode = mechanize_get
page_logged_in, respcode = mechanize_get
error("expected 200, got #{respcode}") unless respcode == 200
true
end
Expand Down
16 changes: 8 additions & 8 deletions lib/heroku/kensa/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def init
manifest = Manifest.new(@options)
protect_current_manifest!
manifest.write
screen.message "Initialized new addon manifest in #{filename}\n"
screen.message "Initialized new addon manifest in #{filename}\n"
if @options[:foreman]
screen.message "Initialized new .env file for foreman\n"
end
Expand All @@ -42,7 +42,7 @@ def create
@options[:foreman] = true
init
rescue Exception => e
raise CommandInvalid.new("error cloning #{Git.clone_url(template)} into #{app_name}")
raise CommandInvalid.new("error cloning #{Git.clone_url(template)} into #{app_name}")
end
end

Expand Down Expand Up @@ -124,7 +124,7 @@ def protect_current_manifest!
puts
end
end

def filename
@options[:filename]
end
Expand Down Expand Up @@ -273,7 +273,7 @@ def self.defaults
# OptionParser errors out on unnamed options so we have to pull out all the --flags and --flag=somethings
KNOWN_ARGS = %w{file async production without-sso help plan version sso foreman template}
def self.pre_parse(args)
args.partition do |token|
args.partition do |token|
token.match(/^--/) && !token.match(/^--(#{KNOWN_ARGS.join('|')})/)
end.reverse
end
Expand All @@ -287,7 +287,7 @@ def self.parse_provision(flags, args)
value = peek && !peek.match(/^--/) ? peek : 'true'
end
key = key.sub(/^--/,'')
options[key] = value
options[key] = value
end
end
end
Expand Down Expand Up @@ -317,19 +317,19 @@ def self.parse_command_line(args)
end
end
end

def self.parse(args)
if args[0] == 'test' && args[1] == 'provision'
safe_args, extra_params = self.pre_parse(args)
self.defaults.tap do |options|
self.defaults.tap do |options|
options.merge! self.parse_command_line(safe_args)
options.merge! :options => self.parse_provision(extra_params, args)
end
else
self.defaults.merge(self.parse_command_line(args))
end
end
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/heroku/kensa/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def heroku_prefix
def clone_url(name)
if name.include? "://" #its a full url not on github
return name
elsif !name.include? "/" #its one of ours
elsif !name.include? "/" #its one of ours
name = heroku_prefix + name
end

Expand Down
2 changes: 1 addition & 1 deletion lib/heroku/kensa/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def request(meth, credentials, path, payload=nil)
args = [
{ :accept => "application/json" }
]

if payload
args.first[:content_type] = "application/json"
args.unshift OkJson.encode(payload)
Expand Down
6 changes: 3 additions & 3 deletions lib/heroku/kensa/okjson-support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ def stringify_keys
each do |key, value|
case value
when Hash
value = value.stringify_keys
value = value.stringify_keys
when Array
value = value.map { |v| v.stringify_keys if v.is_a? Hash }
value = value.map { |v| v.stringify_keys if v.is_a? Hash }
end

new_hash[key.to_s] = value
Expand All @@ -20,5 +20,5 @@ module OkJson

def encode(x)
encode_without_stringify(x.stringify_keys)
end
end
end
2 changes: 1 addition & 1 deletion lib/heroku/kensa/post_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def service(req, res)
<form action="#{@sso.post_url}" method="POST">
#{ @params.map do |key, value|
%|<input type="hidden" name="#{key}" value="#{value}" />|
end.join("\n")
end.join("\n")
}
</form>
</body>
Expand Down
12 changes: 6 additions & 6 deletions lib/heroku/kensa/sso.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def initialize(data)
@proxy_port = find_available_port
else
@url = data["api"][env].chomp('/')
end
end
@timestamp = Time.now.to_i
@token = make_token(@timestamp)
end

def path
if self.POST?
if self.POST?
URI.parse(url).path
else
"/heroku/resources/#{id}"
Expand Down Expand Up @@ -53,23 +53,23 @@ def post_url
def timestamp=(other)
@timestamp = other
@token = make_token(@timestamp)
end
end

def make_token(t)
Digest::SHA1.hexdigest([@id, @salt, t].join(':'))
end

def querystring
return '' unless @salt
'?' + query_data
'?' + query_data
end

def query_data
query_params.map{|p| p.join('=')}.join('&')
end

def query_params
{ 'token' => @token,
{ 'token' => @token,
'timestamp' => @timestamp.to_s,
'nav-data' => sample_nav_data,
'email' => 'username@example.com',
Expand Down Expand Up @@ -124,7 +124,7 @@ def run_proxy

trap("INT") { server.stop }
pid = fork do
server.start
server.start
end
at_exit { server.stop; Process.waitpid pid }
end
Expand Down
2 changes: 1 addition & 1 deletion test/resources/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def json_must_include(keys)
raise "#{param} not included with request" unless params.keys.include? param
end
end

def login(heroku_user=true)
@header = heroku_user
erb <<-ERB
Expand Down

0 comments on commit 7747ba8

Please sign in to comment.