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
Layout/SpaceAroundEqualsInParameterDefault: | |
EnforcedStyle: no_space | |
Metrics/BlockLength: | |
ExcludedMethods: | |
- describe | |
- context | |
- it | |
Metrics/ClassLength: |
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 DbGateway | |
def add_ipn(email, params) | |
DB[:ipns].insert(email_address: email, data: Sequel.pg_json(params) | |
end | |
def generate_redemption_token(email) | |
SecureRandom.hex.tap do |t| | |
DB[:tokens].insert(email_address: email, value: t) | |
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
var Core = (function($) { | |
return { | |
modules: {}, | |
addModule: function(module_name, fn) { | |
// create new sandbox for module | |
var sandbox = new Sandbox(module_name); | |
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
(ns example.errors) | |
(defn clean-address [params] | |
"Ensure (params :address) is present" | |
(if (empty? (params :address)) | |
[nil "Please enter your address"] | |
[params nil])) | |
(defn clean-email [params] | |
"Ensure (params :email) matches *@*.*" |
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 WidgetController < ApplicationController | |
def new | |
# ... | |
end | |
def create | |
AddWidgetToInventory.call(widget_params) do |on| | |
on.success do |widget| | |
redirect widget_path(widget), flash: "Successfully created widget" | |
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 EmployeeTest < Test::Unit::TestCase | |
let(:employee) { Employee.new('[email protected]') } | |
def test_employee_has_an_email | |
assert_equal('[email protected]', employee.email) | |
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 EmployeeTest < Test::Unit::TestCase | |
def test_employee_has_an_email | |
assert_equal('[email protected]', employee.email) | |
end | |
private | |
def employee | |
@employee ||= Employee.new('[email protected]') | |
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 Test::Unit::TestCase | |
def self.let(name, &block) | |
ivar = "@#{name}" | |
self.class_eval do | |
define_method(name) do | |
if instance_variable_defined?(ivar) | |
instance_variable_get(ivar) | |
else | |
value = self.instance_eval(&block) | |
instance_variable_set(ivar, value) |
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
//= require _jquery-1.9.1.min | |
window.crossDomainPost = function crossDomainPost(success) { | |
var uniqueString = "CHANGE_THIS_TO_SOME_UNIQUE_STRING", | |
$iframe = $('<iframe name=' + uniqueString + '>'), | |
$form = $('<form>'), | |
fields = [ | |
'email', | |
'first_name', | |
'last_name', |
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
unless 'production' == ENV['RACK_ENV'] | |
require "flay_task" | |
FlayTask.new do |t| | |
t.dirs = %w[lib] | |
end | |
require "flog" | |
desc 'Analyze code using ABC metric' | |
task :flog do | |
flog = Flog.new |
NewerOlder