consistent-hashing 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ == 0.2.1 / 2013-04-27
2
+
3
+ * fixed build, removed bones gem dependency
4
+
5
+ == 0.2.0 / 2012-04-15
6
+
7
+ * added AVLTree dependency
8
+
1
9
  == 0.1.0 / 2012-04-15
2
10
 
3
11
  * introduced the VirtualPoint class
data/README.md CHANGED
@@ -1,17 +1,16 @@
1
- consistent-hashing
2
- ==================
1
+ # consistent-hashing
3
2
 
4
3
  A generic implementation of the Consistent Hashing algorithm using an AVL tree.
5
4
 
6
- Features
7
- --------
5
+ [![Build Status](https://travis-ci.org/domnikl/consistent-hashing.png?branch=develop)](https://travis-ci.org/domnikl/consistent-hashing) [![Code Climate](https://codeclimate.com/github/domnikl/consistent-hashing.png)](https://codeclimate.com/github/domnikl/consistent-hashing)
6
+
7
+ ## Features
8
8
 
9
9
  * set number of replicas to create multiple virtual points in the ring for each node
10
10
  * nodes can be arbitrary data (e.g. a Memcache client instance)
11
11
  * fast performance through using an AVL tree internally
12
12
 
13
- Examples
14
- --------
13
+ ## Examples
15
14
 
16
15
  ```ruby
17
16
  require 'consistent_hashing'
@@ -30,22 +29,19 @@ ring.nodes # => ["192.168.1.101", "192.168.1.102"]
30
29
  ring.points # => [#<ConsistentHashing::VirtualPoint>, #<ConsistentHashing::VirtualPoint>, ...]
31
30
  ```
32
31
 
33
- Install
34
- -------
32
+ ## Installation
35
33
 
36
34
  * `[sudo] gem install consistent-hashing`
37
35
 
38
- Author
39
- ------
36
+ ## Author
40
37
 
41
38
  Original author: Dominik Liebler <liebler.dominik@googlemail.com>
42
39
 
43
- License
44
- -------
40
+ ## License
45
41
 
46
42
  (The MIT License)
47
43
 
48
- Copyright (c) 2012 Dominik Liebler
44
+ Copyright (c) 2013 Dominik Liebler
49
45
 
50
46
  Permission is hereby granted, free of charge, to any person obtaining
51
47
  a copy of this software and associated documentation files (the
@@ -64,4 +60,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
64
60
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
65
61
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
66
62
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
67
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
63
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,19 +1,38 @@
1
1
  require 'rubygems'
2
+ require 'rake/testtask'
2
3
 
3
- begin
4
- require 'bones'
5
- rescue LoadError
6
- abort '### Please install the "bones" gem ###'
7
- end
4
+ task :default => 'test'
5
+
6
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
7
+ require "consistent_hashing"
8
+
9
+ gem_name = "consistent-hashing-#{ConsistentHashing::VERSION}.gem"
10
+
11
+ namespace :gem do
12
+ desc "clean previously generated gems"
13
+ task :clean do
14
+ system "rm -f *.gem"
15
+ end
16
+
17
+ desc "build gem"
18
+ task :build => [:clean, :test] do
19
+ system "gem build consistent-hashing.gemspec"
20
+ end
8
21
 
9
- task :default => 'test:run'
10
- task 'gem:release' => 'test:run'
22
+ desc "install gem"
23
+ task :install => :build do
24
+ system "gem install #{gem_name}"
25
+ end
11
26
 
12
- Bones {
13
- name 'consistent-hashing'
14
- authors 'Dominik Liebler'
15
- email 'liebler.dominik@googlemail.com'
16
- url 'https://github.com/domnikl/consistent-hashing'
17
- ignore_file '.gitignore'
18
- depend_on 'avl_tree'
19
- }
27
+ desc "release to rubygems.org"
28
+ task :release => :build do
29
+ system "gem push #{gem_name}"
30
+ end
31
+ end
32
+
33
+ Rake::TestTask.new do |t|
34
+ t.libs = ["lib"]
35
+ t.warning = true
36
+ t.verbose = true
37
+ t.test_files = FileList['test/**/test_*.rb']
38
+ end
@@ -1,3 +1,5 @@
1
+ require 'rubygems' if RUBY_VERSION !~ /^1\.9/
2
+
1
3
  # Main module
2
4
  #
3
5
  module ConsistentHashing
@@ -51,4 +51,20 @@ class TestRing < ConsistentHashing::TestCase
51
51
  def test_point_for
52
52
  assert_equal "C", @ring.node_for(@examples["C"])
53
53
  end
54
+
55
+ def test_nodes
56
+ nodes = @ring.nodes
57
+
58
+ assert_equal 3, nodes.length
59
+ assert_not_equal nil, nodes.index("A")
60
+ assert_not_equal nil, nodes.index("B")
61
+ assert_not_equal nil, nodes.index("C")
62
+ end
63
+
64
+ def test_points
65
+ ring = ConsistentHashing::Ring.new %w{A B C}, 3
66
+
67
+ points = ring.points
68
+ assert_equal 9, points.length
69
+ end
54
70
  end
@@ -1,7 +1,11 @@
1
1
  $:.unshift(File.join(File.dirname(__FILE__), %w{.. lib}))
2
2
 
3
- require 'simplecov'
4
- SimpleCov.start
3
+ begin
4
+ require 'simplecov'
5
+ SimpleCov.start
6
+ rescue LoadError => e
7
+ # ignore
8
+ end
5
9
 
6
10
  require 'consistent_hashing'
7
11
  require 'test/unit'
@@ -12,4 +16,4 @@ module ConsistentHashing
12
16
  assert_not_nil ConsistentHashing::VERSION
13
17
  end
14
18
  end
15
- end
19
+ end
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consistent-hashing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-22 00:00:00.000000000 Z
12
+ date: 2013-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: avl_tree
16
- requirement: &70236637210800 !ruby/object:Gem::Requirement
16
+ requirement: &70246971619540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,39 +21,26 @@ dependencies:
21
21
  version: 1.1.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70236637210800
25
- - !ruby/object:Gem::Dependency
26
- name: bones
27
- requirement: &70236637209960 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: 3.8.0
33
- type: :development
34
- prerelease: false
35
- version_requirements: *70236637209960
36
- description: A generic implementation of the Consistent Hashing algorithm using an
37
- AVL tree.
24
+ version_requirements: *70246971619540
25
+ description: a Consistent Hashing implementation in pure Ruby using an AVL Tree
38
26
  email: liebler.dominik@googlemail.com
39
27
  executables: []
40
28
  extensions: []
41
29
  extra_rdoc_files:
42
30
  - History.txt
43
31
  files:
44
- - .gitignore
45
- - History.txt
46
- - README.md
47
- - Rakefile
48
- - benchmark/benchmark.rb
49
- - lib/consistent_hashing.rb
50
32
  - lib/consistent_hashing/avl_tree.rb
51
33
  - lib/consistent_hashing/ring.rb
52
34
  - lib/consistent_hashing/virtual_point.rb
35
+ - lib/consistent_hashing.rb
53
36
  - test/consistent_hashing/test_avl_tree.rb
54
37
  - test/consistent_hashing/test_ring.rb
55
38
  - test/consistent_hashing/test_virtual_point.rb
56
39
  - test/test_consistent_hashing.rb
40
+ - benchmark/benchmark.rb
41
+ - README.md
42
+ - History.txt
43
+ - Rakefile
57
44
  - version.txt
58
45
  homepage: https://github.com/domnikl/consistent-hashing
59
46
  licenses: []
@@ -80,8 +67,7 @@ rubyforge_project: consistent-hashing
80
67
  rubygems_version: 1.8.16
81
68
  signing_key:
82
69
  specification_version: 3
83
- summary: A generic implementation of the Consistent Hashing algorithm using an AVL
84
- tree.
70
+ summary: ''
85
71
  test_files:
86
72
  - test/consistent_hashing/test_avl_tree.rb
87
73
  - test/consistent_hashing/test_ring.rb
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- # RubyMine
2
- .idea
3
- *.gemspec
4
-
5
- # gem/bones
6
- announcement.txt
7
- coverage
8
- doc
9
- pkg