sorted_array 0.0.1 → 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.
- data/README.md +32 -17
- data/Rakefile +7 -0
- data/TODO.md +2 -0
- data/lib/sorted_array/default_sorter.rb +1 -1
- data/lib/sorted_array/version.rb +1 -1
- data/spec/default_sorter_spec.rb +7 -5
- metadata +3 -3
data/README.md
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
# SortedArray
|
2
2
|
|
3
|
-
The gem
|
4
|
-
|
3
|
+
The gem is providing a class `SortedArray` which keeps sorted
|
4
|
+
after adding new items. When initializing a `SortedArray` you chose
|
5
|
+
a Sorter which must have a method `:sort`
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
A class `DefaultSorter` is included.
|
8
|
+
|
9
|
+
The included `DefaultSorter` sorts a list of Objects by a given method-name.
|
8
10
|
|
9
11
|
## Installation
|
10
12
|
|
13
|
+
* see [RubyGems](http://rubygems.org/gems/sorted_array)
|
14
|
+
* see [Github](https://github.com/iboard/sorted_array#readme)
|
15
|
+
|
11
16
|
Add this line to your application's Gemfile:
|
12
17
|
|
13
|
-
gem 'sorted_array'
|
18
|
+
gem 'sorted_array'
|
14
19
|
|
15
20
|
And then execute:
|
16
21
|
|
@@ -22,20 +27,28 @@ Or install it yourself as:
|
|
22
27
|
|
23
28
|
Run Tests
|
24
29
|
|
25
|
-
|
30
|
+
_If you clone from github you can run the following tasks:_
|
26
31
|
|
27
|
-
|
28
|
-
$
|
29
|
-
|
30
|
-
#
|
31
|
-
$
|
32
|
-
|
33
|
-
|
32
|
+
|
33
|
+
$ git clone git://github.com/iboard/sorted_array.git
|
34
|
+
$ cd sorted_array
|
35
|
+
$ bundle # update/install the bundle
|
36
|
+
$ rake # run all tests
|
37
|
+
$ rspec spec/ # run all specs manually
|
38
|
+
$ guard # start guard
|
39
|
+
|
40
|
+
## Documentation
|
34
41
|
|
35
42
|
$ yard
|
36
|
-
$ open doc/index.html
|
43
|
+
$ open doc/index.html # on Mac OS X
|
44
|
+
|
45
|
+
A copy of the YARDocumentation can be found at
|
46
|
+
[iboard.cc - yardoc](http://dav.iboard.cc/container/sorted_array_doc/)
|
47
|
+
|
48
|
+
And a copy of the last coverage-report is at
|
49
|
+
[iboard.cc - coverage](http://dav.iboard.cc/container/sorted_array_coverage/)
|
37
50
|
|
38
|
-
## Usage
|
51
|
+
## Usage-example
|
39
52
|
|
40
53
|
data = [
|
41
54
|
OpenStruct.new( foo: 1 ),
|
@@ -50,11 +63,13 @@ Build Documentation
|
|
50
63
|
|
51
64
|
## Persistent
|
52
65
|
|
53
|
-
_SortedArray_ defines a marshal_load and marshal_dump method and
|
54
|
-
|
66
|
+
_SortedArray_ defines a `marshal_load` and `marshal_dump` method and
|
67
|
+
can be used in a `PStore`
|
55
68
|
|
56
69
|
Example:
|
57
70
|
|
71
|
+
# assumes the previous example was executed before
|
72
|
+
|
58
73
|
store=PStore.new('example.pstore')
|
59
74
|
store.transaction do |w|
|
60
75
|
w[:data] = keep_sorted
|
data/Rakefile
CHANGED
@@ -27,3 +27,10 @@ desc 'Build documentation'
|
|
27
27
|
task :doc do
|
28
28
|
system 'yard'
|
29
29
|
end
|
30
|
+
|
31
|
+
desc 'Deploy documentation'
|
32
|
+
task :deploy_doc do
|
33
|
+
Rake::Task['doc'].execute
|
34
|
+
system 'rsync','-avze','ssh', '--delete', 'doc/', 'root@dav.iboard.cc:/var/www/dav/container/sorted_array_doc/'
|
35
|
+
system 'rsync','-avze','ssh', '--delete', 'coverage/', 'root@dav.iboard.cc:/var/www/dav/container/sorted_array_coverage/'
|
36
|
+
end
|
data/TODO.md
CHANGED
data/lib/sorted_array/version.rb
CHANGED
data/spec/default_sorter_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'pstore'
|
2
3
|
|
3
4
|
describe SortedArray::DefaultSorter do
|
4
5
|
|
@@ -9,6 +10,7 @@ describe SortedArray::DefaultSorter do
|
|
9
10
|
OpenStruct.new(foo: 2)
|
10
11
|
] }
|
11
12
|
let(:sorted) { items.sort{|a,b|a.foo <=> b.foo} }
|
13
|
+
let(:store) { PStore.new(SORTER_TEST_STORE) }
|
12
14
|
|
13
15
|
it 'initialize with a sort-method' do
|
14
16
|
expect(sorter.method).to eq(:foo)
|
@@ -20,15 +22,15 @@ describe SortedArray::DefaultSorter do
|
|
20
22
|
|
21
23
|
it 'stores the method-name to a PStore' do
|
22
24
|
sorter.should_receive(:marshal_dump)
|
23
|
-
|
25
|
+
store.transaction do |s|
|
24
26
|
s[:sorter] = sorter
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
it 'loads the method-name from a PStore' do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
_s = nil
|
32
|
+
store.transaction(true) { |r| _s = r[:sorter] }
|
33
|
+
expect(_s).to be_a SortedArray::DefaultSorter
|
34
|
+
expect(_s.method).to eq(:to_s)
|
33
35
|
end
|
34
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorted_array
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -209,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
209
|
version: '0'
|
210
210
|
segments:
|
211
211
|
- 0
|
212
|
-
hash: -
|
212
|
+
hash: -1794077783631359981
|
213
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
214
|
none: false
|
215
215
|
requirements:
|
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
218
|
version: '0'
|
219
219
|
segments:
|
220
220
|
- 0
|
221
|
-
hash: -
|
221
|
+
hash: -1794077783631359981
|
222
222
|
requirements: []
|
223
223
|
rubyforge_project:
|
224
224
|
rubygems_version: 1.8.25
|