qfill 0.0.1
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/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +152 -0
- data/Rakefile +1 -0
- data/lib/qfill.rb +13 -0
- data/lib/qfill/filter.rb +18 -0
- data/lib/qfill/list.rb +18 -0
- data/lib/qfill/list_set.rb +29 -0
- data/lib/qfill/manager.rb +91 -0
- data/lib/qfill/origin.rb +19 -0
- data/lib/qfill/popper.rb +96 -0
- data/lib/qfill/pusher.rb +85 -0
- data/lib/qfill/result.rb +116 -0
- data/lib/qfill/version.rb +3 -0
- data/qfill.gemspec +36 -0
- data/spec/qfill/filter_spec.rb +44 -0
- data/spec/qfill/list_set_spec.rb +36 -0
- data/spec/qfill/list_spec.rb +44 -0
- data/spec/qfill/manager_spec.rb +418 -0
- data/spec/qfill/origin_spec.rb +55 -0
- data/spec/qfill/popper_spec.rb +44 -0
- data/spec/qfill/pusher_spec.rb +38 -0
- data/spec/qfill/result_spec.rb +57 -0
- data/spec/qfill_spec.rb +11 -0
- data/spec/spec_helper.rb +48 -0
- metadata +102 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Qfill::Origin do
|
3
|
+
context "#new" do
|
4
|
+
context "with no arguments" do
|
5
|
+
it "should raise ArgumentError" do
|
6
|
+
expect { Qfill::Origin.new() }.to raise_error(ArgumentError)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
context "with name" do
|
10
|
+
before :each do
|
11
|
+
@arguments = { :name => "High List" }
|
12
|
+
end
|
13
|
+
it "should not raise any errors" do
|
14
|
+
expect { Qfill::Origin.new(@arguments) }.to_not raise_error
|
15
|
+
end
|
16
|
+
it "should instantiate with name" do
|
17
|
+
Qfill::Origin.new(@arguments).name.should == 'High List'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
context "with elements" do
|
21
|
+
before :each do
|
22
|
+
@arguments = { :name => "High List",
|
23
|
+
:elements => [1,2] }
|
24
|
+
end
|
25
|
+
it "should instantiate with elements" do
|
26
|
+
Qfill::Origin.new(@arguments).elements.should == [1,2]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
context "with backfill" do
|
30
|
+
before :each do
|
31
|
+
@arguments = { :name => "High List",
|
32
|
+
:elements => [1, 2],
|
33
|
+
:backfill => "Medium List" }
|
34
|
+
end
|
35
|
+
it "should instantiate with elements" do
|
36
|
+
Qfill::Origin.new(@arguments).backfill.should == 'Medium List'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
context "with filter" do
|
40
|
+
before :each do
|
41
|
+
lambda = -> (object) { !object.nil? }
|
42
|
+
@filter = Qfill::Filter.new(lambda)
|
43
|
+
@arguments = { :name => "High List",
|
44
|
+
:elements => [1, 2],
|
45
|
+
:backfill => "Medium List",
|
46
|
+
:filter => @filter }
|
47
|
+
end
|
48
|
+
it "should instantiate with processor" do
|
49
|
+
Qfill::Origin.new(@arguments).filter.should be_a(Qfill::Filter)
|
50
|
+
Qfill::Origin.new(@arguments).filter.should == @filter
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Qfill::Popper do
|
3
|
+
context "#new" do
|
4
|
+
context "with no arguments" do
|
5
|
+
it "should raise ArgumentError" do
|
6
|
+
expect { Qfill::Popper.new() }.to raise_error(ArgumentError)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
context "with arguments" do
|
10
|
+
before :each do
|
11
|
+
@filter = Qfill::Filter.new( -> (object) { object.is_a?(Numeric)} )
|
12
|
+
@origin_queues = [
|
13
|
+
Qfill::Origin.new(
|
14
|
+
:name => "High List",
|
15
|
+
:elements => [1, 2, 3, 'c'],
|
16
|
+
:backfill => "Medium List",
|
17
|
+
:filter => @filter),
|
18
|
+
Qfill::Origin.new( :name => "Medium List",
|
19
|
+
:elements => ['e', 'f', 4, 5],
|
20
|
+
:backfill => "Low List",
|
21
|
+
:filter => @filter),
|
22
|
+
Qfill::Origin.new( :name => "Low List",
|
23
|
+
:elements => [7, 8, 'd'],
|
24
|
+
:backfill => nil,
|
25
|
+
:filter => @filter)
|
26
|
+
]
|
27
|
+
end
|
28
|
+
it "should not raise any errors" do
|
29
|
+
expect { Qfill::Popper.new(*@origin_queues) }.to_not raise_error
|
30
|
+
end
|
31
|
+
it "should instantiate with name" do
|
32
|
+
popper = Qfill::Popper.new(*@origin_queues)
|
33
|
+
popper.queues.first.name.should == "High List"
|
34
|
+
popper.queues.last.name.should == "Low List"
|
35
|
+
end
|
36
|
+
it "should instantiate with elements" do
|
37
|
+
popper = Qfill::Popper.new(*@origin_queues)
|
38
|
+
popper.queues.first.elements.should == [1,2,3,'c']
|
39
|
+
popper.queues.last.elements.should == [7,8,'d']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Qfill::Pusher do
|
3
|
+
context "#new" do
|
4
|
+
context "with no arguments" do
|
5
|
+
it "should raise ArgumentError" do
|
6
|
+
expect { Qfill::Pusher.new() }.to raise_error(ArgumentError)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
context "with arguments" do
|
10
|
+
before :each do
|
11
|
+
@filter = Qfill::Filter.new( -> (object) { object.is_a?(Numeric)} )
|
12
|
+
@origin_queues = [
|
13
|
+
Qfill::Result.new({ :name => "Top Results",
|
14
|
+
:ratio => 0.4,
|
15
|
+
:list_ratios => {
|
16
|
+
"High Price" => 0.2,
|
17
|
+
"Medium Price" => 0.3,
|
18
|
+
"Low Price" => 0.5 } }),
|
19
|
+
Qfill::Result.new( { :name => "Page Results",
|
20
|
+
:ratio => 0.6,
|
21
|
+
:list_ratios => {
|
22
|
+
"High Price" => 0.5,
|
23
|
+
"Medium Price" => 0.3,
|
24
|
+
"Low Price" => 0.2 } })
|
25
|
+
]
|
26
|
+
end
|
27
|
+
it "should not raise any errors" do
|
28
|
+
expect { Qfill::Pusher.new(*@origin_queues) }.to_not raise_error
|
29
|
+
end
|
30
|
+
it "should instantiate with name" do
|
31
|
+
popper = Qfill::Pusher.new(*@origin_queues)
|
32
|
+
popper.queues.first.name.should == "Top Results"
|
33
|
+
popper.queues.last.name.should == "Page Results"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Qfill::Result do
|
3
|
+
context "#new" do
|
4
|
+
context "with no arguments" do
|
5
|
+
it "should raise ArgumentError" do
|
6
|
+
expect { Qfill::Result.new() }.to raise_error(ArgumentError)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
context "with name" do
|
10
|
+
before :each do
|
11
|
+
@arguments = { :name => "Best Results" }
|
12
|
+
end
|
13
|
+
it "should not raise any errors" do
|
14
|
+
expect { Qfill::Result.new(@arguments) }.to_not raise_error
|
15
|
+
end
|
16
|
+
it "should instantiate with name" do
|
17
|
+
Qfill::Result.new(@arguments).name.should == 'Best Results'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
context "with ratio" do
|
21
|
+
before :each do
|
22
|
+
@arguments = { :name => "Best Results",
|
23
|
+
:ratio => 0.5 }
|
24
|
+
end
|
25
|
+
it "should instantiate with elements" do
|
26
|
+
Qfill::Result.new(@arguments).ratio.should == 0.5
|
27
|
+
end
|
28
|
+
end
|
29
|
+
context "with filter" do
|
30
|
+
before :each do
|
31
|
+
lambda = -> (object) { !object.nil? }
|
32
|
+
@filter = Qfill::Filter.new(lambda)
|
33
|
+
@arguments = { :name => "Best Results",
|
34
|
+
:ratio => 0.5,
|
35
|
+
:filter => @filter }
|
36
|
+
end
|
37
|
+
it "should instantiate with filter" do
|
38
|
+
Qfill::Result.new(@arguments).filter.should be_a(Qfill::Filter)
|
39
|
+
Qfill::Result.new(@arguments).filter.should == @filter
|
40
|
+
end
|
41
|
+
end
|
42
|
+
context "with list_ratios" do
|
43
|
+
before :each do
|
44
|
+
@arguments = { :name => "Best Results",
|
45
|
+
:ratio => 0.5,
|
46
|
+
:list_ratios => {
|
47
|
+
"High Price" => 0.4,
|
48
|
+
"Medium Price" => 0.3,
|
49
|
+
"Low Price" => 0.3 } }
|
50
|
+
end
|
51
|
+
it "should instantiate with elements" do
|
52
|
+
Qfill::Result.new(@arguments).list_ratios["High Price"].should == 0.4
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/spec/qfill_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'qfill'
|
2
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
3
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
4
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
5
|
+
# loaded once.
|
6
|
+
#
|
7
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
10
|
+
config.run_all_when_everything_filtered = true
|
11
|
+
config.filter_run :focus
|
12
|
+
|
13
|
+
# Run specs in random order to surface order dependencies. If you find an
|
14
|
+
# order dependency and want to debug it, you can fix the order by providing
|
15
|
+
# the seed, which is printed after each run.
|
16
|
+
# --seed 1234
|
17
|
+
config.order = 'random'
|
18
|
+
end
|
19
|
+
|
20
|
+
# TODO: Write some specs with this dude:
|
21
|
+
#class RandomObject
|
22
|
+
#
|
23
|
+
# attr_accessor :rating, :queue
|
24
|
+
# def initialize(options = {})
|
25
|
+
# @rating = options[:rating] || RandomObject.random_rating
|
26
|
+
# @queue = RandomObject.list_designation(self.rating)
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# def self.random_rating
|
30
|
+
# rand(101) # 0 - 100
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# def self.list_designation(rating)
|
34
|
+
# if rating == 0
|
35
|
+
# 'none'
|
36
|
+
# elsif rating < 34
|
37
|
+
# 'low'
|
38
|
+
# elsif rating < 67
|
39
|
+
# 'medium'
|
40
|
+
# else
|
41
|
+
# 'high'
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# def to_s
|
46
|
+
# "RO:#{rating}:#{queue}"
|
47
|
+
# end
|
48
|
+
#end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qfill
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Peter Boling
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Advanced Queue Transformation
|
31
|
+
email:
|
32
|
+
- peter.boling@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- .rspec
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- lib/qfill.rb
|
44
|
+
- lib/qfill/filter.rb
|
45
|
+
- lib/qfill/list.rb
|
46
|
+
- lib/qfill/list_set.rb
|
47
|
+
- lib/qfill/manager.rb
|
48
|
+
- lib/qfill/origin.rb
|
49
|
+
- lib/qfill/popper.rb
|
50
|
+
- lib/qfill/pusher.rb
|
51
|
+
- lib/qfill/result.rb
|
52
|
+
- lib/qfill/version.rb
|
53
|
+
- qfill.gemspec
|
54
|
+
- spec/qfill/filter_spec.rb
|
55
|
+
- spec/qfill/list_set_spec.rb
|
56
|
+
- spec/qfill/list_spec.rb
|
57
|
+
- spec/qfill/manager_spec.rb
|
58
|
+
- spec/qfill/origin_spec.rb
|
59
|
+
- spec/qfill/popper_spec.rb
|
60
|
+
- spec/qfill/pusher_spec.rb
|
61
|
+
- spec/qfill/result_spec.rb
|
62
|
+
- spec/qfill_spec.rb
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
homepage: ''
|
65
|
+
licenses: []
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.8.25
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: 'You have a set of arrays that need to be turned into a different set of
|
88
|
+
arrays according to a potentially non-uniform set of rules. Now you can easily
|
89
|
+
turn this: source_a # => [1,2,3,4] source_b # => [5,6,7,8,9] into this: result_a
|
90
|
+
# => [1,2] result_b # => [3,5,7,9] result_c # => [4,6,8] by specifying filters
|
91
|
+
for handling each transformation.'
|
92
|
+
test_files:
|
93
|
+
- spec/qfill/filter_spec.rb
|
94
|
+
- spec/qfill/list_set_spec.rb
|
95
|
+
- spec/qfill/list_spec.rb
|
96
|
+
- spec/qfill/manager_spec.rb
|
97
|
+
- spec/qfill/origin_spec.rb
|
98
|
+
- spec/qfill/popper_spec.rb
|
99
|
+
- spec/qfill/pusher_spec.rb
|
100
|
+
- spec/qfill/result_spec.rb
|
101
|
+
- spec/qfill_spec.rb
|
102
|
+
- spec/spec_helper.rb
|