hamburglar 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1,105 @@
1
+ # Hamburglar
2
+
3
+ [![Build Status](http://travis-ci.org/site5/hamburglar.png)](http://travis-ci.org/site5/hamburglar)
4
+
5
+ Hamburglar helps you prevent fraudulent orders.
6
+
7
+ Confirmed to work with ruby 1.8.7, 1.9.2, Rubinus, and JRuby 1.6.2.
8
+
9
+ ## Prerequisites
10
+
11
+ You must have an active account with one of the APIs Hamburglar
12
+ supports. See **Supported APIs** below.
13
+
14
+ ## Installation
15
+
16
+ gem install hamburglar
17
+
18
+ ## Usage
19
+
20
+ To get a fraud report, create a new instance of the `Hamburglar::Report`
21
+ class:
22
+
23
+ report = Hamburglar::Report.new(params)
24
+
25
+ Check for fraud by comparing the fraud score to
26
+ `Hamburglar.config.fraud_score`:
27
+
28
+ report.fraud?
29
+
30
+ By default, Hamburglar only considers the numeric fraud score when
31
+ trying to determine if an order is fraudulent. If you need more control,
32
+ you can configure `Hamburglar.config.fraud_proc`. It should be a block
33
+ that returns true when the order should be considered fraudulent.
34
+
35
+ Hamburglar.configure do |c|
36
+ c.fraud_proc = lambda do |report|
37
+ report.score > 5 && report.distance > 100
38
+ end
39
+ end
40
+
41
+ report.fraud?
42
+
43
+ ### MaxMind
44
+
45
+ Hamburglar supports MaxMind's minFraud and Telephone Verification APIs.
46
+ By default, reports will use the minFraud API.
47
+
48
+ **Generate a fraud report using minFraud**
49
+
50
+ report = Hamburglar::Report.new(
51
+ :license_key => 's3cr3tz',
52
+ :i => '192.168.1.1',
53
+ :city => 'Funland',
54
+ :region => 'US',
55
+ :postal => '12345',
56
+ :country => 'US',
57
+ :bin => '12345',
58
+ :domain => 'example.com',
59
+ :binName => 'Happy Meal Bank',
60
+ :cust_phone => '+18004445555',
61
+ :email_address => 'test@example.com'
62
+ )
63
+
64
+ **Generate a fraud report using Telephone Verification**
65
+
66
+ report = Hamburglar::Report.new(
67
+ :gateway => :max_mind_telephone,
68
+ :l => 's3cr3tz',
69
+ :phone => '+18004445555'
70
+ )
71
+
72
+ ## Optional Configuration
73
+
74
+ You may optionally configure the default gateway and credentials
75
+ Hamburglar will use. For example, in a Rails app where you always
76
+ used minFraud, you can add the following to
77
+ `config/initializers/hamburglar.rb`:
78
+
79
+ Hamburglar.configure do |config|
80
+ config.fraud_score = 2.5
81
+ config.gateway = :max_mind_min_fraud
82
+ config.credentials = { :license_key => 's3cr3tz' }
83
+ end
84
+
85
+ Note that Hamburglar uses a default fraud score of 2.5 and the default
86
+ gateway is minFraud.
87
+
88
+ ## Supported APIs
89
+
90
+ * [MaxMind MinFraud](http://www.maxmind.com/app/ccv/)
91
+ * [MaxMind Telephone Verification](http://www.maxmind.com/app/telephone_api)
92
+
93
+ ## Note on Patches/Pull Requests
94
+
95
+ * Fork the project.
96
+ * Make your feature addition or bug fix.
97
+ * Add tests for it. This is important so I don't break it in a future version
98
+ unintentionally.
99
+ * Commit, do not bump version. (If you want to have your own version, that is
100
+ fine but bump version in a commit by itself I can ignore when I pull.)
101
+ * Send me a pull request. Bonus points for topic branches.
102
+
103
+ ## Copyright
104
+
105
+ Copyright (c) 2011 Site5 LLC. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ $:.unshift 'lib'
2
+
3
+ begin
4
+ require 'bundler'
5
+ Bundler::GemHelper.install_tasks
6
+ rescue LoadError
7
+ puts "Please install bundler (gem install bundler)"
8
+ exit
9
+ end
10
+
11
+ begin
12
+ require 'rspec/core/rake_task'
13
+ RSpec::Core::RakeTask.new :spec
14
+ rescue LoadError
15
+ puts "Please install rspec (bundle install)"
16
+ exit
17
+ end
18
+
19
+ begin
20
+ require 'metric_fu'
21
+ MetricFu::Configuration.run do |config|
22
+ config.rcov[:rcov_opts] << "-Ispec"
23
+ end
24
+ rescue LoadError
25
+ # puts "Can't find metric_fu"
26
+ end
27
+
28
+ begin
29
+ require 'rcov'
30
+ desc "Run all specs with rcov"
31
+ RSpec::Core::RakeTask.new(:rcov) do |t|
32
+ t.rcov = true
33
+ t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/,features\/}
34
+ end
35
+ rescue LoadError
36
+ # puts "Can't find rcov"
37
+ end
38
+
39
+ desc "Open an irb session preloaded with this library"
40
+ task :console do
41
+ sh "irb -rubygems -r ./lib/hamburglar.rb -I ./lib"
42
+ end
43
+
44
+ desc "Run 'rake spec' with multiple rubies"
45
+ task :all_specs do
46
+ rubies = %w[1.8.7 1.9.2 jruby rbx-1.2.3].map { |r| "#{r}@hamburglar" }.join(',')
47
+ sh "rvm #{rubies} rake spec"
48
+ sh "find . -type f -name '*.rbc'| xargs rm"
49
+ end
50
+
51
+ task :default => :spec