trifle 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,4 @@
1
1
  language: ruby
2
-
3
- branches:
4
- only:
5
- - master
6
-
7
2
  rvm:
8
- - 1.9.2
3
+ - 1.8.7
9
4
  - 1.9.3
10
-
11
- notifications:
12
- email:
13
- - cristiano@emberads.com
14
-
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source :rubygems
3
3
  # Specify your gem's dependencies in messages.gemspec
4
4
  gemspec
5
5
 
6
- gem "fakeredis", github: "guilleiguaran/fakeredis", require: "fakeredis/rspec"
6
+ gem "fakeredis", :github => "guilleiguaran/fakeredis", :require => "fakeredis/rspec"
data/README.md CHANGED
@@ -66,6 +66,7 @@ trifle.find "192.168.1.1"
66
66
 
67
67
  ## Release notes
68
68
 
69
+ * **0.1.1** Made 1.8.7 compatible
69
70
  * **0.0.8** Fixed a search bug that created conflicts between IPv4 and IPv6 data
70
71
  * **0.0.7** Loading now happens into separate key, making loading possible without downtime
71
72
  * **0.0.6** Added a fix for invalid IPs
data/bin/trifle CHANGED
@@ -8,7 +8,7 @@ if ARGV.count < 2
8
8
  exit(1)
9
9
  end
10
10
 
11
- redis = Redis.new(url: ARGV[0])
11
+ redis = Redis.new(:url => ARGV[0])
12
12
  ARGV.shift
13
13
 
14
14
  filenames = []
@@ -27,5 +27,5 @@ ARGV.each do |arg|
27
27
  end
28
28
 
29
29
  puts "Loading #{filenames.join(", ")}"
30
- Trifle.new(redis, options).load(filenames: filenames)
30
+ Trifle.new(redis, options).load(:filenames => filenames)
31
31
  puts "Trifle loaded"
@@ -18,10 +18,10 @@ class Trifle
18
18
  protected
19
19
 
20
20
  def loader
21
- @loader = Loader.new(redis, key: key)
21
+ @loader = Loader.new(redis, :key => key)
22
22
  end
23
23
 
24
24
  def finder
25
- @finder = Finder.new(redis, key: key)
25
+ @finder = Finder.new(redis, :key => key)
26
26
  end
27
27
  end
@@ -1,4 +1,4 @@
1
- require_relative "initialize_with_redis"
1
+ require "trifle/initialize_with_redis"
2
2
  require 'ipaddr'
3
3
 
4
4
  class Trifle
@@ -1,4 +1,5 @@
1
- require_relative "initialize_with_redis"
1
+ require "trifle/initialize_with_redis"
2
+ require "fastercsv"
2
3
  require "csv"
3
4
 
4
5
  class Trifle
@@ -57,7 +58,8 @@ class Trifle
57
58
 
58
59
  def parse contents
59
60
  contents.gsub!('", "', '","')
60
- CSV.parse(contents)
61
+ csv = RUBY_VERSION =~ /^1\.8/ ? FasterCSV : CSV
62
+ csv.parse(contents)
61
63
  end
62
64
 
63
65
  def valid? data
@@ -1,3 +1,3 @@
1
1
  class Trifle
2
- VERSION = "0.1.0" unless defined? Trifle::VERSION
2
+ VERSION = "0.1.1" unless defined? Trifle::VERSION
3
3
  end
@@ -28,7 +28,7 @@ describe Trifle::Finder do
28
28
  @redis = Redis.new
29
29
  @trifle = Trifle.new(@redis)
30
30
  @finder = Trifle::Finder.new(@redis)
31
- @trifle.load(data: @valid_data)
31
+ @trifle.load(:data => @valid_data)
32
32
  end
33
33
 
34
34
  describe "#handle" do
@@ -45,7 +45,7 @@ describe Trifle::Finder do
45
45
  end
46
46
 
47
47
  it "should not fail if there's only 1 record" do
48
- @trifle.load(data: [["82.132.242.55","82.132.242.55","1384444471","1384444471","GB","United Kingdrom"]])
48
+ @trifle.load(:data => [["82.132.242.55","82.132.242.55","1384444471","1384444471","GB","United Kingdrom"]])
49
49
  @finder.handle("127.0.0.1").should be_nil
50
50
  end
51
51
 
@@ -14,11 +14,11 @@ describe Trifle::InitializeWithRedis do
14
14
  end
15
15
 
16
16
  it "should fail without a redis instance" do
17
- -> { @klass.new(nil) }.should raise_error(ArgumentError)
17
+ lambda { @klass.new(nil) }.should raise_error(ArgumentError)
18
18
  end
19
19
 
20
20
  it "should accept an optional redis key" do
21
- instance = @klass.new(Redis.new, key: "foo")
21
+ instance = @klass.new(Redis.new, :key => "foo")
22
22
  instance.key.should be == "foo"
23
23
  end
24
24
  end
@@ -25,7 +25,7 @@ describe Trifle::Loader do
25
25
  it "should pass it on to load_files" do
26
26
  filename = 'data.csv'
27
27
  @loader.should_receive(:load_files).with([filename])
28
- @loader.handle(filename: filename)
28
+ @loader.handle(:filename => filename)
29
29
  end
30
30
  end
31
31
 
@@ -33,7 +33,7 @@ describe Trifle::Loader do
33
33
  it "should pass it on to load_files" do
34
34
  filenames = ['data1.csv', 'data2.csv']
35
35
  @loader.should_receive(:load_files).with(filenames)
36
- @loader.handle(filenames: filenames)
36
+ @loader.handle(:filenames => filenames)
37
37
  end
38
38
  end
39
39
 
@@ -41,14 +41,14 @@ describe Trifle::Loader do
41
41
  it "should pass it on to load_data" do
42
42
  data = [:foo, :bar]
43
43
  @loader.should_receive(:load_data).with(data)
44
- @loader.handle(data: data)
44
+ @loader.handle(:data => data)
45
45
  end
46
46
  end
47
47
 
48
48
  context "when given anything else" do
49
49
  it "should raise an error" do
50
- -> { @loader.handle(foo: :bar) }.should raise_error(ArgumentError)
51
- -> { @loader.handle }.should raise_error(ArgumentError)
50
+ lambda { @loader.handle(:foo => :bar) }.should raise_error(ArgumentError)
51
+ lambda { @loader.handle }.should raise_error(ArgumentError)
52
52
  end
53
53
  end
54
54
  end
@@ -70,14 +70,14 @@ describe Trifle::Loader do
70
70
 
71
71
  context "when given anything but an array of strings" do
72
72
  it "should raise an error" do
73
- -> { @loader.send(:load_files, "") }.should raise_error(ArgumentError)
74
- -> { @loader.send(:load_files, [:foo]) }.should raise_error(ArgumentError)
73
+ lambda { @loader.send(:load_files, "") }.should raise_error(ArgumentError)
74
+ lambda { @loader.send(:load_files, [:foo]) }.should raise_error(ArgumentError)
75
75
  end
76
76
  end
77
77
 
78
78
  context "when given a filename for a file that's missing" do
79
79
  it "should raise an error" do
80
- -> { @loader.send(:load_files, ["foobar.csv"]) }.should raise_error(/No such file or directory - foobar.csv/)
80
+ lambda { @loader.send(:load_files, ["foobar.csv"]) }.should raise_error(/No such file or directory - foobar.csv/)
81
81
  end
82
82
  end
83
83
  end
@@ -111,13 +111,13 @@ describe Trifle::Loader do
111
111
  context "when given invalid data" do
112
112
  it "should raise an error" do
113
113
  @loader.should_receive(:valid?).and_return(false)
114
- -> { @loader.send(:load_data, @valid_data) }.should raise_error(ArgumentError)
114
+ lambda { @loader.send(:load_data, @valid_data) }.should raise_error(ArgumentError)
115
115
  end
116
116
  end
117
117
 
118
118
  context "when given anything but an array" do
119
119
  it "should raise an error" do
120
- -> { @loader.send(:load_data, :rubbish) }.should raise_error(ArgumentError)
120
+ lambda { @loader.send(:load_data, :rubbish) }.should raise_error(ArgumentError)
121
121
  end
122
122
  end
123
123
  end
@@ -128,7 +128,8 @@ describe Trifle::Loader do
128
128
  end
129
129
 
130
130
  it "should raise an error for invalid csv data" do
131
- -> { @loader.send(:parse, '"foo",","#') }.should raise_error(CSV::MalformedCSVError)
131
+ csv = RUBY_VERSION =~ /^1\.8/ ? FasterCSV : CSV
132
+ lambda { @loader.send(:parse, '"foo",","#') }.should raise_error(csv::MalformedCSVError)
132
133
  end
133
134
 
134
135
  it "should handle ipv6 data" do
@@ -136,7 +137,7 @@ describe Trifle::Loader do
136
137
  "2c0f:ffe8::", "2c0f:ffe8:ffff:ffff:ffff:ffff:ffff:ffff", "58569106662796955307479896348547874816", "58569106742025117821744233942091825151", "NG", "Nigeria"
137
138
  "2c0f:fff0::", "2c0f:fff0:ffff:ffff:ffff:ffff:ffff:ffff", "58569107296622255421594597096899477504", "58569107375850417935858934690443427839", "NG", "Nigeria"
138
139
  CSV
139
- -> { @loader.send(:parse, @ipv6csv) }.should_not raise_error
140
+ lambda { @loader.send(:parse, @ipv6csv) }.should_not raise_error
140
141
  end
141
142
  end
142
143
 
@@ -10,12 +10,12 @@ describe Trifle do
10
10
  before do
11
11
  @redis = Redis.new
12
12
  @trifle = Trifle.new(@redis)
13
- @options = { filenames: "foobar.csv" }
13
+ @options = { :filenames => "foobar.csv" }
14
14
  end
15
15
 
16
16
  it "should pass this to the loader" do
17
17
  loader = mock Trifle::Loader
18
- Trifle::Loader.should_receive(:new).with(@redis, key: @trifle.key).and_return(loader)
18
+ Trifle::Loader.should_receive(:new).with(@redis, :key => @trifle.key).and_return(loader)
19
19
  loader.should_receive(:handle).with(@options)
20
20
  @trifle.load @options
21
21
  end
@@ -30,7 +30,7 @@ describe Trifle do
30
30
 
31
31
  it "should pass this to the finder" do
32
32
  finder = mock Trifle::Finder
33
- Trifle::Finder.should_receive(:new).with(@redis, key: @trifle.key).and_return(finder)
33
+ Trifle::Finder.should_receive(:new).with(@redis, :key => @trifle.key).and_return(finder)
34
34
  finder.should_receive(:handle).with(@ip)
35
35
  @trifle.find @ip
36
36
  end
@@ -24,4 +24,5 @@ Gem::Specification.new do |s|
24
24
  s.add_development_dependency "fakeredis", ">= 0.4.0"
25
25
 
26
26
  s.add_dependency "redis", ">= 3.0.0"
27
+ s.add_dependency "fastercsv", ">= 1.5.5"
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trifle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-16 00:00:00.000000000 Z
12
+ date: 2013-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: 3.0.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: fastercsv
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: 1.5.5
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.5.5
94
110
  description: Stores the GeoIP databases in Redis and gives it a simple way to lookup
95
111
  IPs and map them to countries
96
112
  email:
@@ -133,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
149
  version: '0'
134
150
  segments:
135
151
  - 0
136
- hash: 3747848338070537568
152
+ hash: -1333851127389149991
137
153
  required_rubygems_version: !ruby/object:Gem::Requirement
138
154
  none: false
139
155
  requirements:
@@ -142,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
158
  version: '0'
143
159
  segments:
144
160
  - 0
145
- hash: 3747848338070537568
161
+ hash: -1333851127389149991
146
162
  requirements: []
147
163
  rubyforge_project: trifle
148
164
  rubygems_version: 1.8.24