Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions github-challenge/githubChallengeBenHall.rb
Original file line number Diff line number Diff line change
@@ -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
#<pre><h1>Some Person</h1><ul><li>Commit: xxxxxxyyyyzzz<br/>Commit Message</li></ul></pre>

html_output = "<html><head><title>Ben Hall - Integrum Job Application</title></head><body><pre>"

author.each do |k, v|
html_output << "<h1>#{k['name']}</h1><ul>"
v.each do |v|
html_output << "<li>Commit: #{v['message']} </li>"
end
html_output << "</ul>"
end

html_output << "</pre></body></html>"

output_file = File.new("output.html", "w+")
output_file.puts html_output
44 changes: 44 additions & 0 deletions github-challenge/output.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<html><head><title>Ben Hall - Integrum Job Application</title></head><body><pre><h1>Aaron Patterson</h1><ul><li>Commit: only compute path.to_s once </li><li>Commit: remove to_s implementation so that inspect is helpful </li><li>Commit: * LocalCache strategy is now a real middleware class, not an anonymous class
posing for pictures. </li><li>Commit: require deprecation so that we can deprecate methods! </li><li>Commit: anonymous classes have blank names on ruby 1.8 </li><li>Commit: make sure string keys are always looked up from the class cache </li><li>Commit: Ruby 1.8: Y U NO FUN? </li><li>Commit: use newer class cache api </li><li>Commit: adding deprecation noticies to deprecated class cache methods </li><li>Commit: adding backwards compat for class cache references. <3<3 </li><li>Commit: yo dawg, directly use the class cache rather than the cache of the cache </li><li>Commit: refactor Reference to a ClassCache object, fix lazy lookup in Middleware so that anonymous classes are supported </li><li>Commit: initialize ivars </li><li>Commit: Enumerable gives us include?, so remove include? </li><li>Commit: prefer composition over inheritance with AD::MS </li><li>Commit: fixing test case test on 1.9.3dev </li><li>Commit: Revert "compute ext in initialize, and use an attr_reader"

This reverts commit 2dbb73bdda3b81947fd112486ac4285fb1a6e3a9.

Conflicts:

actionpack/lib/action_dispatch/middleware/static.rb </li><li>Commit: no need to pass a regex to Regexp.compile </li><li>Commit: compute ext in initialize, and use an attr_reader </li><li>Commit: Merge branch 'fuuu'

* fuuu:
Move JoinDependency and friends from ActiveRecord::Associations::ClassMethods to just ActiveRecord::Associations
Rewrote AssociationPreload. </li><li>Commit: use a subclass of AS::TZ for testing html output </li><li>Commit: reduce two method calls per request, 1 to method_missing and one to send </li></ul><h1>Alexander Uvarov</h1><ul><li>Commit: Add an option to FormBuilder to omit hidden field with id

[#4551 state:committed]

Signed-off-by: Santiago Pastorino <[email protected]> </li><li>Commit: Move ActiveModel::AttributeMethods#attribute_methods_generated? to ActiveRecord, so it's flexible now

[#6428 state:resolved]

Signed-off-by: José Valim <[email protected]> </li></ul><h1>Sam Elliott</h1><ul><li>Commit: Remove warnings about redefined test methods

[#6490 state:committed]

Signed-off-by: Santiago Pastorino <[email protected]> </li></ul><h1>Cheah Chu Yeow</h1><ul><li>Commit: Fix Action caching bug where an action that has a non-cacheable response always renders a nil response body. It now correctly renders the response body.

Note that only GET and HTTP 200 responses can be cached.

[#6480 state:committed]

Signed-off-by: Santiago Pastorino <[email protected]> </li></ul><h1>José Valim</h1><ul><li>Commit: log and readme should respect --quiet </li></ul><h1>Jon Leighton</h1><ul><li>Commit: Move JoinDependency and friends from ActiveRecord::Associations::ClassMethods to just ActiveRecord::Associations </li><li>Commit: Rewrote AssociationPreload. </li></ul><h1>Josh Kalderimis</h1><ul><li>Commit: Updated the AS guides with some information on the difference between Date.today and Date.current. </li><li>Commit: updated Time, Date and DateTime current methods in AS to use Time.zone and not Time.zone_default.

[#6410 state:committed] </li></ul><h1>Dalibor Nasevic</h1><ul><li>Commit: No need of instance variable

[#6502 state:committed]

Signed-off-by: Santiago Pastorino <[email protected]> </li><li>Commit: Fixed typos in asset_host_test

[#6501 state:committed]

Signed-off-by: Santiago Pastorino <[email protected]> </li></ul><h1>Diego Carrion</h1><ul><li>Commit: reverted tests deleted by 080345baca1076a9788d, refactored implementations should not invalidate the validations

Signed-off-by: Santiago Pastorino <[email protected]> </li><li>Commit: refactored Time#<=> and DateTime#<=> by removing unnecessary calls without losing performance

Signed-off-by: Santiago Pastorino <[email protected]> </li></ul></pre></body></html>
44 changes: 17 additions & 27 deletions refactor-this/helper.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 22 additions & 3 deletions refactor-this/helper_spec.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require 'rubygems'
require 'factory_girl'
require 'factories'
require 'spec'
require 'spec/autorun'
require 'redgreen'
require 'user_profile'
require 'helper'
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand Down
Binary file added resume/Ben_Hall_Resume.pdf
Binary file not shown.