diff --git a/github-challenge/githubChallengeBenHall.rb b/github-challenge/githubChallengeBenHall.rb new file mode 100644 index 0000000..326203b --- /dev/null +++ b/github-challenge/githubChallengeBenHall.rb @@ -0,0 +1,25 @@ +require "rubygems" +require "json" +require "open-uri" + +github_api_url = open("http://github.com/api/v2/json/commits/list/rails/rails/master") + +author = JSON.parse(github_api_url.read)['commits'].group_by { |commit| commit['author'] } + +#puts author +#

Some Person

+ +html_output = "Ben Hall - Integrum Job Application
"
+
+author.each do |k, v|
+  html_output << "

#{k['name']}

" +end + +html_output << "
" + +output_file = File.new("output.html", "w+") +output_file.puts html_output diff --git a/github-challenge/output.html b/github-challenge/output.html new file mode 100644 index 0000000..170fd41 --- /dev/null +++ b/github-challenge/output.html @@ -0,0 +1,44 @@ +Ben Hall - Integrum Job Application

Aaron Patterson

Alexander Uvarov

Sam Elliott

Cheah Chu Yeow

José Valim

Jon Leighton

Josh Kalderimis

Dalibor Nasevic

Diego Carrion

diff --git a/refactor-this/helper.rb b/refactor-this/helper.rb old mode 100644 new mode 100755 index 6ef273b..de804d8 --- a/refactor-this/helper.rb +++ b/refactor-this/helper.rb @@ -26,42 +26,32 @@ def display_large_photo(profile, html = {}, options = {}, link = true) def display_huge_photo(profile, html = {}, options = {}, link = true) display_photo(profile, image_size(profile, "200x200"), html, options, link) end + + def has_user_profile_and_photo?(profile) + return true if profile.user && profile.user.photo + end + + def is_rep_user?(profile) + return true if profile.user && profile.user.rep? + end def display_photo(profile, size, html = {}, options = {}, link = true) - return image_tag("wrench.png") unless profile # this should not happen + return image_tag("wrench.png") if !profile show_default_image = !(options[:show_default] == false) - html.reverse_merge!(:class => 'thumbnail', :size => size, :title => "Link to #{profile.name}") - - if profile && profile.user - if profile.user && profile.user.photo && File.exists?(profile.user.photo) - @user = profile.user - if link - return link_to(image_tag(url_for_file_column("user", "photo", size), html), profile_path(profile) ) - else - return image_tag(url_for_file_column("user", "photo", size), html) - end - else - show_default_image ? default_photo(profile, size, {}, link) : '' - end + + if has_user_profile_and_photo?(profile) + return link_to(image_tag(url_for_file_column("user", "photo", size), html), profile_path(profile) ) if link + return image_tag(url_for_file_column("user", "photo", size), html) end - - show_default_image ? default_photo(profile, size, {}, link) : '' + + return show_default_image ? default_photo(profile, size, {}, link) : 'NO DEFAULT' end def default_photo(profile, size, html={}, link = true) if link - if profile.user.rep? - link_to(image_tag("user190x119.jpg", html), profile_path(profile) ) - else - link_to(image_tag("user#{size}.jpg", html), profile_path(profile) ) - end - else - if profile.user.rep? - image_tag("user190x119.jpg", html) - else - image_tag("user#{size}.jpg", html) - end + return link_to(image_tag("user100x100.jpg", html), profile_path(profile) ) if !is_rep_user?(profile) + return link_to(image_tag("user190x119.jpg", html), profile_path(profile) ) end end end \ No newline at end of file diff --git a/refactor-this/helper_spec.rb b/refactor-this/helper_spec.rb old mode 100644 new mode 100755 index b82e40e..d034945 --- a/refactor-this/helper_spec.rb +++ b/refactor-this/helper_spec.rb @@ -1,8 +1,6 @@ require 'rubygems' require 'factory_girl' require 'factories' -require 'spec' -require 'spec/autorun' require 'redgreen' require 'user_profile' require 'helper' @@ -12,8 +10,14 @@ describe "Helper" do before(:each) do @helper = Helper.new + @helper.stub!(:profile_path).and_return("profile_path") + @helper.stub!(:url_for_file_column).and_return("file_column_url") + @helper.stub!(:set_image_default_html).and_return({}) end describe "display_photo" do + before do + @helper.stub!(:image_tag).and_return("wrench.png") + end it "should return the wrench if there is no profile" do @helper.display_photo(nil, "100x100", {}, {}, true).should == "wrench.png" end @@ -27,6 +31,8 @@ @photo = Photo.new @user.photo = @photo @profile.stub!(:has_valid_photo?).and_return(true) + @helper.stub!(:image_tag).and_return("") + @helper.stub_chain(:link_to).and_return("this link") end it "should return a link" do @helper.display_photo(@profile, "100x100", {}, {}, true).should == "this link" @@ -42,6 +48,7 @@ @photo = Photo.new @user.photo = @photo @profile.stub!(:has_valid_photo?).and_return(true) + @helper.stub!(:image_tag).and_return("just image") end it "should just an image" do @helper.display_photo(@profile, "100x100", {}, {}, false).should == "just image" @@ -52,12 +59,17 @@ before(:each) do @profile = UserProfile.new @profile.name = "Clayton" + @profile.stub!(:has_valid_photo?).and_return(false) + @helper.stub!(:image_tag).and_return("") + @helper.stub_chain(:link_to).and_return("default link 100x100") end it "return a default" do @helper.display_photo(@profile, "100x100", {}, {}, true).should == "default link 100x100" end end + + describe "When the user doesn't have a photo" do before(:each) do @profile = UserProfile.new @@ -69,6 +81,8 @@ describe "With a rep user" do before(:each) do @user.stub!(:rep?).and_return(true) + @helper.stub!(:image_tag).and_return("") + @helper.stub_chain(:link_to).and_return("default link 190x119") end it "return a default link" do @helper.display_photo(@profile, "100x100", {}, {}, true).should == "default link 190x119" @@ -79,13 +93,16 @@ describe "With a regular user" do before(:each) do @user.stub!(:rep?).and_return(false) + @helper.stub!(:image_tag).and_return("") + @helper.stub_chain(:link_to).and_return("default link 100x100") end it "return a default link" do @helper.display_photo(@profile, "100x100", {}, {}, true).should == "default link 100x100" end end end - + + describe "When the user doesn't have a photo and we don't want to display the default" do before(:each) do @profile = UserProfile.new @@ -107,6 +124,8 @@ describe "With a regular user" do before(:each) do @user.stub!(:rep?).and_return(false) + @helper.stub!(:image_tag).and_return("") + @helper.stub_chain(:link_to).and_return("default link 100x100") end it "return a default link" do @helper.display_photo(@profile, "100x100", {}, {}, true).should == "default link 100x100" diff --git a/resume/Ben_Hall_Resume.pdf b/resume/Ben_Hall_Resume.pdf new file mode 100755 index 0000000..ca9a77e Binary files /dev/null and b/resume/Ben_Hall_Resume.pdf differ