hamburglar 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,12 @@
1
- # Hamburglar
2
-
3
- [![Build Status](http://travis-ci.org/site5/hamburglar.png)](http://travis-ci.org/site5/hamburglar)
1
+ # Hamburglar [![Hamburglar Build Status][Build Icon]][Build Status]
4
2
 
5
3
  Hamburglar helps you prevent fraudulent orders.
6
4
 
7
- Confirmed to work with ruby 1.8.7, 1.9.2, Rubinus, and JRuby 1.6.2.
5
+ Hamburglar has been tested on MRI 1.8.7, MRI 1.9.2, MRI 1.9.3 Preview 1,
6
+ Rubinius 2.0.0pre, and JRuby 1.6.2.
7
+
8
+ [Build Icon]: https://secure.travis-ci.org/site5/hamburglar.png?branch=master
9
+ [Build Status]: http://travis-ci.org/site5/hamburglar
8
10
 
9
11
  ## Prerequisites
10
12
 
@@ -49,7 +51,7 @@ By default, reports will use the minFraud API.
49
51
 
50
52
  report = Hamburglar::Report.new(
51
53
  :license_key => 's3cr3tz',
52
- :i => '192.168.1.1',
54
+ :ip => '192.168.1.1',
53
55
  :city => 'Funland',
54
56
  :region => 'US',
55
57
  :postal => '12345',
@@ -64,9 +66,9 @@ By default, reports will use the minFraud API.
64
66
  **Generate a fraud report using Telephone Verification**
65
67
 
66
68
  report = Hamburglar::Report.new(
67
- :gateway => :max_mind_telephone,
68
- :l => 's3cr3tz',
69
- :phone => '+18004445555'
69
+ :gateway => :max_mind_telephone,
70
+ :license_key => 's3cr3tz',
71
+ :phone => '+18004445555'
70
72
  )
71
73
 
72
74
  ## Optional Configuration
@@ -10,6 +10,12 @@ module Hamburglar
10
10
  attr_accessor :config
11
11
  end
12
12
 
13
+ # Set Hamburglar.config
14
+ #
15
+ # Example:
16
+ # Hamburglar.configure do |config|
17
+ # config.fraud_score = 10
18
+ # end
13
19
  def self.configure
14
20
  yield config if block_given?
15
21
  config
@@ -1,10 +1,56 @@
1
1
  module Hamburglar
2
+ # The Hamburglar::Config class stores configuration variables used to generate
3
+ # fraud reports.
2
4
  class Config
5
+ # The gateway used when generating fraud reports via
6
+ # `Hamburglar::Report.new`.
7
+ #
8
+ # Example:
9
+ # # Set gateway
10
+ # config.gateway = :min_fraud
11
+ #
12
+ # # Get gateway
13
+ # config.gateway
3
14
  attr_accessor :gateway
15
+
16
+ # Credentials that should be used when communicating with
17
+ # upstream APIs.
18
+ #
19
+ # This should be a Hash. When a query is sent to a Gateway, this Hash
20
+ # will be merged in **if** it's keys exist in Gateway#optional_params
21
+ #
22
+ # Example:
23
+ # # Set credentials:
24
+ # config.credentials = { :license_key => 's3cretz' }
25
+ #
26
+ # # Get credentials
27
+ # config.credentials
4
28
  attr_accessor :credentials
29
+
30
+ # The score that should be considered fraud. This score will be
31
+ # checked when `Hamburglar::Report#fraud?` is called, unless
32
+ # `config.fraud_proc` is set
33
+ #
34
+ # Example:
35
+ # # Set fraud score
36
+ # config.fraud_score = 5
37
+ #
38
+ # # Get fraud score
39
+ # config.fraud_score
5
40
  attr_accessor :fraud_score
41
+
42
+ # An optional Proc that will be used to evaluate
43
+ # `Hamburglar::Report#fraud?` if set
44
+ #
45
+ # Example:
46
+ # # Set proc
47
+ # config.fraud_proc = lambda { |report| report.distance > 500 }
48
+ #
49
+ # # Get proc
50
+ # config.fraud_proc
6
51
  attr_accessor :fraud_proc
7
52
 
53
+ # Create a new Config instance and set some defaults
8
54
  def initialize
9
55
  @gateway = :min_fraud
10
56
  @credentials = {}
@@ -1,4 +1,6 @@
1
1
  module Hamburglar
2
+ # The Hamburglar::Gateways module contains classes used to generate fraud
3
+ # reports
2
4
  module Gateways
3
5
  autoload :Base, 'hamburglar/gateways/base'
4
6
  autoload :MaxMind, 'hamburglar/gateways/max_mind'
@@ -8,6 +8,8 @@ module Hamburglar
8
8
  # this class
9
9
  class Base
10
10
 
11
+ # A regex for matching URLs with http or https
12
+ # This will be used to verify API urls
11
13
  URL_REGEX = /https?:\/\/[\S]+/
12
14
 
13
15
  # The parameters for the API request
@@ -44,6 +44,11 @@ module Hamburglar
44
44
  :accept_language
45
45
  ].freeze
46
46
  end
47
+
48
+ def initialize(params = {})
49
+ params[:i] = params.delete(:ip) if params[:ip]
50
+ super params
51
+ end
47
52
  end
48
53
 
49
54
  # The TelephoneVerification class handles fraud verification
@@ -61,6 +66,11 @@ module Hamburglar
61
66
  def optional_params
62
67
  [:l, :phone, :verify_code].freeze
63
68
  end
69
+
70
+ def initialize(params = {})
71
+ params[:l] = params.delete(:license_key) if params[:license_key]
72
+ super params
73
+ end
64
74
  end
65
75
 
66
76
  end
@@ -1,3 +1,3 @@
1
1
  module Hamburglar
2
- VERSION = Version = '0.1.0'
2
+ VERSION = Version = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,109 +1,107 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hamburglar
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
4
5
  prerelease:
5
- version: 0.1.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Joshua Priddle
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-06-03 00:00:00 -04:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: rspec
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &21584760 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
18
+ requirements:
22
19
  - - ~>
23
- - !ruby/object:Gem::Version
24
- version: "2.6"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.6'
25
22
  type: :development
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *21584760
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &21584260 !ruby/object:Gem::Requirement
31
28
  none: false
32
- requirements:
29
+ requirements:
33
30
  - - ~>
34
- - !ruby/object:Gem::Version
35
- version: 0.8.7
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.2.2
36
33
  type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: fakeweb
40
34
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *21584260
36
+ - !ruby/object:Gem::Dependency
37
+ name: fakeweb
38
+ requirement: &21583660 !ruby/object:Gem::Requirement
42
39
  none: false
43
- requirements:
40
+ requirements:
44
41
  - - ~>
45
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
46
43
  version: 1.3.0
47
44
  type: :development
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: vcr
51
45
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *21583660
47
+ - !ruby/object:Gem::Dependency
48
+ name: vcr
49
+ requirement: &21583080 !ruby/object:Gem::Requirement
53
50
  none: false
54
- requirements:
51
+ requirements:
55
52
  - - ~>
56
- - !ruby/object:Gem::Version
57
- version: "1.10"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
58
55
  type: :development
59
- version_requirements: *id004
56
+ prerelease: false
57
+ version_requirements: *21583080
60
58
  description: Hamburglar helps you prevent fraudulent orders
61
59
  email: jpriddle@site5.com
62
60
  executables: []
63
-
64
61
  extensions: []
65
-
66
- extra_rdoc_files:
62
+ extra_rdoc_files:
67
63
  - README.markdown
68
- files:
64
+ files:
69
65
  - Rakefile
70
66
  - README.markdown
71
- - lib/cacert.pem
72
67
  - lib/hamburglar/config.rb
73
- - lib/hamburglar/errors.rb
74
- - lib/hamburglar/gateways/base.rb
75
- - lib/hamburglar/gateways/max_mind.rb
76
68
  - lib/hamburglar/gateways.rb
69
+ - lib/hamburglar/errors.rb
77
70
  - lib/hamburglar/report.rb
78
71
  - lib/hamburglar/version.rb
72
+ - lib/hamburglar/gateways/max_mind.rb
73
+ - lib/hamburglar/gateways/base.rb
79
74
  - lib/hamburglar.rb
80
- has_rdoc: true
75
+ - lib/cacert.pem
81
76
  homepage: https://github.com/site5/hamburglar
82
77
  licenses: []
83
-
84
78
  post_install_message:
85
- rdoc_options:
79
+ rdoc_options:
86
80
  - --charset=UTF-8
87
- require_paths:
81
+ require_paths:
88
82
  - lib
89
- required_ruby_version: !ruby/object:Gem::Requirement
83
+ required_ruby_version: !ruby/object:Gem::Requirement
90
84
  none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: "0"
95
- required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ segments:
90
+ - 0
91
+ hash: 2236720283326898591
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
93
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: "0"
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ segments:
99
+ - 0
100
+ hash: 2236720283326898591
101
101
  requirements: []
102
-
103
102
  rubyforge_project:
104
- rubygems_version: 1.6.2
103
+ rubygems_version: 1.8.11
105
104
  signing_key:
106
105
  specification_version: 3
107
106
  summary: Hamburglar helps you prevent fraudulent orders
108
107
  test_files: []
109
-