Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Hi! I cleaned up your code for you! #1

Merged
merged 1 commit into from

1 participant

@GunioRobot

Hi there!

This is WhitespaceBot. I'm an open-source robot that removes trailing white space in your code, and gives you a gitignore file if you didn't have one!

Why whitespace? Whitespace is an eyesore for developers who use text editors with dark themes. It's not a huge deal, but it's a bit annoying if you use Vim in a terminal. Really, I'm just a proof of concept - GitHub's V3 API allows robots to automatically improve open source projects, and that's really cool. Hopefully, somebody, maybe you!, will fork me and make me even more useful. My owner is funding a bounty to anybody who can add security fixing features to me.

I've only cleaned your most popular project, and I've added you to a list of users not to contact again, so you won't get any more pull requests from me unless you ask. If I'm misbehaving, please email my owner and tell him to turn me off! If this is pull request is of no use to you, please just ignore it.

Thanks!
WhiteSpacebot from Gun.io.

@dacort dacort merged commit 57b8073 into dacort:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 28, 2011
  1. Remove whitespace [Gun.io WhitespaceBot]

    Gun.io Whitespace Robot authored
This page is out of date. Refresh to see the latest.
View
14 lib/mwhich/amazon.rb
@@ -6,20 +6,20 @@ def initialize(options={})
@aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
@aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
end
-
+
def search(title)
results = request(title)
-
+
titles = []
results.css("Item").each do |result|
titles << "#{result.css('ProductGroup').inner_html}: #{result.css('Title').inner_html}"
end
-
+
titles
end
-
+
protected
-
+
def request(title)
params = {
"Operation" => "ItemSearch",
@@ -32,11 +32,11 @@ def request(title)
sorted_params = params.sort_by{|x,y| x}.map{|x,y| "#{x}=#{CGI::escape(y)}"}.join('&')
signature = sign("GET\nwebservices.amazon.com\n/onca/xml\n#{sorted_params}").strip
url = "#{@endpoint_url}?#{sorted_params}&Signature=#{CGI::escape(signature)}"
-
+
response = Net::HTTP.get_response(URI.parse(url))
Nokogiri::XML(response.body)
end
-
+
def sign(string)
hmac = HMAC::SHA256.new(@aws_secret_access_key)
hmac.update(string)
View
10 lib/mwhich/client.rb
@@ -1,6 +1,6 @@
module MWhich
class Client
-
+
VALID_SERVICES = [:amazon,:hulu,:itunes,:netflix]
SERVICE_MAP = {
:amazon => MWhich::Services::Amazon,
@@ -9,16 +9,16 @@ class Client
:netflix => MWhich::Services::Netflix
}
IGNORE_MEDIA = [:clips, :trailers]
-
+
attr_accessor :services, :ignore
-
+
# Arguments (all are optional):
# - :services - One or more of :amazon, :netflix, :hulu, or :itunes. Default is :all
def initialize(options={})
self.services = options[:services] || VALID_SERVICES
self.ignore = options[:ignore] ? IGNORE_MEDIA & options[:ignore] : IGNORE_MEDIA
end
-
+
# Search for a movie/tv show by title
def search(title)
results = {}
@@ -26,7 +26,7 @@ def search(title)
s = SERVICE_MAP[service].new(:ignore => ignore)
results[service] = s.search(title)
end
-
+
results
end
end
View
12 lib/mwhich/hulu.rb
@@ -9,10 +9,10 @@ def initialize(options={})
@ignore_media << 'clip' if options[:ignore].include?:clips
end
end
-
+
def search(title)
results = request(title)
-
+
titles = []
results.xpath("//video").each do |result|
next if @ignore_media.include?result.css('video-type').inner_html
@@ -22,15 +22,15 @@ def search(title)
end
titles << "#{result.css('video-type').inner_html}: #{result.css('title').inner_html}#{append}"
end
-
+
titles
end
-
+
protected
-
+
def request(title)
url = "#{@endpoint_url}/search?dp_identifier=hulu&query=#{URI::escape(title)}&items_per_page=10&page=1"
-
+
response = Net::HTTP.get_response(URI.parse(url))
Nokogiri::XML(response.body)
end
View
14 lib/mwhich/itunes.rb
@@ -4,20 +4,20 @@ class ITunes
def initialize(options={})
@endpoint = "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/wsSearch"
end
-
+
def search(title)
results = request(title)
-
+
titles = []
results.each do |result|
titles << "#{result['kind']}: #{result['trackName']} ($#{result['trackPrice']})"
end
-
+
titles
end
-
+
protected
-
+
def request(title)
# We'll do searches across both TV and movies and merge the results
results = []
@@ -27,10 +27,10 @@ def request(title)
data = Yajl::Parser.parse(response.body)
results |= data['results']
end
-
+
results
end
-
+
end
end
end
View
16 lib/mwhich/netflix.rb
@@ -1,33 +1,33 @@
module MWhich
module Services
class Netflix
-
+
def initialize(options={})
@endpoint = "http://odata.netflix.com/v1/Catalog/"
@format = "json"
end
-
+
def search(title)
results = request(title)
-
+
titles = []
results['d']['results'].each do |result|
titles << "#{result['Type']}: #{result['Name']}#{result['Instant']['Available'] ? ' - Watch now!' : ''}"
end
-
+
titles
end
-
+
protected
-
+
def request(title)
filter = "Name eq '#{title}'"
url = "#{@endpoint}Titles?$filter=#{URI::escape(filter)}&$format=#{@format}"
-
+
response = Net::HTTP.get_response(URI.parse(url))
Yajl::Parser.parse(response.body)
end
-
+
end
end
end
Something went wrong with that request. Please try again.