This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Controller | |
| before :ensure_authenticated, :exclude => [:index, :show] | |
| def new(project_id) | |
| only_provides :html | |
| @ticket = Ticket.new(:project_id => project_id) | |
| display @ticket | |
| end | |
| # RSPEC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Array | |
| def uniq_by(method) | |
| results = [] | |
| self.map do |e| | |
| result = e.send(method) | |
| results.include?(result) ? nil : (results << result; e) | |
| end.compact | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Exceptions < Merb::Controller | |
| # handle NotFound exceptions (404) | |
| def not_found | |
| render :format => :html | |
| end | |
| # handle NotAcceptable exceptions (406) | |
| def not_acceptable | |
| render :format => :html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def display | |
| result = open(gist_url).read | |
| out = result.scan(/document.write\('(.*|\s*)'\)/)[1] | |
| out.nil? ? "Not Found" : out[0] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def f(ra,n) | |
| ra.inject(0){ |c, x| x.include? n ? c + 1 : c } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def f(ra,n) | |
| ra.inject(0) { |r,x| r += 1 if x.include? n; r } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def f(ra,n) | |
| ra.inject(0) { |r,x| r += 1 if x.include? n; r } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def f(ra,n) | |
| ra.inject(0) { |r,x| r += 1 if x.include? n; r } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def on_time_value | |
| attendances.inject(0){|sum, a| a.late? ? sum : sum + 5} | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # spec helper | |
| Spec::Runner.configure do |config| | |
| # snip | |
| config.include(Rack::Test::Methods) | |
| end |