sarah-xk 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ --tag copyright:Copyright
2
+ --tag license:License
3
+ -
4
+ HISTORY.txt
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gem 'sarah'
3
+ gem 'xkeys', '>=2.0.0'
@@ -0,0 +1,12 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ sarah (0.0.4)
5
+ xkeys (2.0.0)
6
+
7
+ PLATFORMS
8
+ ruby
9
+
10
+ DEPENDENCIES
11
+ sarah
12
+ xkeys (>= 2.0.0)
@@ -0,0 +1,7 @@
1
+ 2014-03-31 Version 0.0.2
2
+
3
+ Creates new nodes with #new_similar if available (sarah >= 2.0.0).
4
+
5
+ 2014-03-21 Version 0.0.1
6
+
7
+ First release.
@@ -0,0 +1,32 @@
1
+ # Sarah::XK - Sarah with XKeys extensions
2
+ #
3
+ # Sarah provides a hybrid data structure consisting of a sequential array,
4
+ # a sparse array, and a random-access hash. XKeys provides extended/nested
5
+ # key access into array- and hash-like structures.
6
+ #
7
+ # @author Brian Katzung (briank@kappacs.com), Kappa Computer Solutions, LLC
8
+ # @copyright 2014 Brian Katzung and Kappa Computer Solutions, LLC
9
+ # @license MIT License
10
+
11
+ require 'sarah'
12
+ require 'xkeys'
13
+
14
+ class Sarah::XK < Sarah
15
+ include XKeys::Hash
16
+
17
+ VERSION = "0.0.2"
18
+
19
+ # Returns a new Sarah::XK node for auto-vivification.
20
+ #
21
+ # @return [Sarah::XK]
22
+ def xkeys_new (*args)
23
+ if respond_to? :new_similar then self.new_similar
24
+ else
25
+ self.class.new :default => self.default,
26
+ :default_proc => self.default_proc
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ # END
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "sarah-xk"
3
+ s.version = "0.0.2"
4
+ s.date = "2014-03-31"
5
+ s.authors = ["Brian Katzung"]
6
+ s.email = ["briank@kappacs.com"]
7
+ s.homepage = "http://rubygems.org/gems/sarah-xk"
8
+ s.summary = "Sarah with XKeys extended keys"
9
+ s.description = "Sarah with XKeys extended keys"
10
+ s.license = "MIT"
11
+
12
+ s.files = Dir.glob("lib/**/*") +
13
+ %w{Gemfile Gemfile.lock sarah-xk.gemspec
14
+ .yardopts HISTORY.txt}
15
+ s.test_files = Dir.glob("test/**/*.rb")
16
+ s.require_path = 'lib'
17
+ end
@@ -0,0 +1,15 @@
1
+ require 'minitest/autorun'
2
+ require 'sarah/xk'
3
+
4
+ class TestSarah_XK_00 < MiniTest::Unit::TestCase
5
+
6
+ def test_cmethod
7
+ assert_respond_to Sarah::XK, :new
8
+ end
9
+
10
+ def test_imethod
11
+ s = Sarah::XK.new
12
+ assert_respond_to s, :xkeys_new
13
+ end
14
+
15
+ end
@@ -0,0 +1,37 @@
1
+ require 'minitest/autorun'
2
+ require 'sarah/xk'
3
+
4
+ class MySarahXK < Sarah::XK; end
5
+
6
+ class TestSarah_XK_01 < MiniTest::Unit::TestCase
7
+
8
+ def test_new
9
+ s1 = Sarah::XK.new
10
+ assert_kind_of Sarah, s1, 's1 is a Sarah'
11
+ assert_instance_of Sarah::XK, s1, 's1 is a Sarah::XK'
12
+
13
+ s2 = s1.xkeys_new
14
+ assert_instance_of Sarah::XK, s2, 's2 is also a Sarah::XK'
15
+
16
+ s3 = MySarahXK.new
17
+ assert_kind_of Sarah, s3, 's3 is a Sarah'
18
+ assert_kind_of Sarah::XK, s3, 's3 is a Sarah::XK'
19
+ assert_instance_of MySarahXK, s3, 's3 is a MySarahXK'
20
+
21
+ s4 = s3.xkeys_new
22
+ assert_instance_of MySarahXK, s4, 's4 is also a MySarahXK'
23
+ end
24
+
25
+ def test_next
26
+ s = Sarah::XK.new :array => [9, 8], :hash => { :key => 'value' }
27
+ assert_equal 2, s.seq_size, 's seq_size initially'
28
+ assert_equal [9, 8], s.seq, 's array initially'
29
+ assert_equal({ :key => 'value' }, s.rnd, 's hash initially')
30
+
31
+ s[:[]] = 7
32
+ assert_equal 3, s.seq_size, 's seq_size after [:[]]'
33
+ assert_equal [9, 8, 7], s.seq, 's array after [:[]]'
34
+ assert_equal({ :key => 'value' }, s.rnd, 's hash unchanged')
35
+ end
36
+
37
+ end
@@ -0,0 +1,31 @@
1
+ require 'minitest/autorun'
2
+ require 'sarah/xk'
3
+
4
+ class TestSarah_XK_02 < MiniTest::Unit::TestCase
5
+
6
+ def test_subnode
7
+ s1 = Sarah::XK.new
8
+ assert_kind_of Sarah, s1
9
+ assert_kind_of Sarah::XK, s1
10
+ assert_kind_of XKeys::Get, s1
11
+ assert_kind_of XKeys::Set_, s1
12
+
13
+ s1[0, 0, {}] = 1
14
+ s1[:first, :second] = :value
15
+
16
+ s2 = s1[0]
17
+ assert_kind_of Sarah, s2
18
+ assert_kind_of Sarah::XK, s2
19
+ assert_kind_of XKeys::Get, s2
20
+ assert_kind_of XKeys::Set_, s2
21
+ assert_equal [ 1 ], s2.seq, "s2.seq (s1[0])"
22
+
23
+ s3 = s1[:first]
24
+ assert_kind_of Sarah, s3
25
+ assert_kind_of Sarah::XK, s3
26
+ assert_kind_of XKeys::Get, s3
27
+ assert_kind_of XKeys::Set_, s3
28
+ assert_equal({ :second => :value }, s3.rnd, "s3.rnd (s1[:first])")
29
+ end
30
+
31
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sarah-xk
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - Brian Katzung
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2014-03-31 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Sarah with XKeys extended keys
22
+ email:
23
+ - briank@kappacs.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - lib/sarah/xk.rb
32
+ - Gemfile
33
+ - Gemfile.lock
34
+ - sarah-xk.gemspec
35
+ - .yardopts
36
+ - HISTORY.txt
37
+ - test/01basic.rb
38
+ - test/00class.rb
39
+ - test/02subnode.rb
40
+ has_rdoc: true
41
+ homepage: http://rubygems.org/gems/sarah-xk
42
+ licenses:
43
+ - MIT
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.3.7
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Sarah with XKeys extended keys
72
+ test_files:
73
+ - test/01basic.rb
74
+ - test/00class.rb
75
+ - test/02subnode.rb