ht 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +68 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/ht.gemspec +68 -0
- data/lib/ht.rb +5 -0
- data/lib/ht/cascade.rb +59 -0
- data/test/helper.rb +19 -0
- data/test/test_ht.rb +182 -0
- metadata +146 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "minitest", ">= 0"
|
10
|
+
gem "autotest", ">=0"
|
11
|
+
gem "bundler", "~> 1.0.0"
|
12
|
+
gem "jeweler", "~> 1.5.1"
|
13
|
+
gem "rcov", ">= 0"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
autotest (4.4.4)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.5.1)
|
7
|
+
bundler (~> 1.0.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
minitest (2.0.0)
|
11
|
+
rake (0.8.7)
|
12
|
+
rcov (0.9.9)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
autotest
|
19
|
+
bundler (~> 1.0.0)
|
20
|
+
jeweler (~> 1.5.1)
|
21
|
+
minitest
|
22
|
+
rcov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Jordan West
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
= HT
|
2
|
+
|
3
|
+
Simple templating for ruby hashes
|
4
|
+
|
5
|
+
= Example Usage
|
6
|
+
|
7
|
+
cascade = HT::Cascade.new(:my_cascade) do |t|
|
8
|
+
t.base do |t, data|
|
9
|
+
t.set_value :d, "abc"
|
10
|
+
end
|
11
|
+
|
12
|
+
t.layer :path_share do |t, data|
|
13
|
+
t.set_value :a, data[:a]
|
14
|
+
t.set_value :b, data[:b]
|
15
|
+
end
|
16
|
+
|
17
|
+
t.layer :path_1_mid, :path_share do |t, data|
|
18
|
+
t.set_value :a, data[:b]
|
19
|
+
end
|
20
|
+
|
21
|
+
t.layer :path_2_mid, :path_share do |t, data|
|
22
|
+
t.set_value t.get_value(:a), :a
|
23
|
+
t.set_value t.get_value(:b), :b
|
24
|
+
end
|
25
|
+
|
26
|
+
t.layer :path_1_all, :path_1_mid do |t, data|
|
27
|
+
t.set_value :b, data[:a]
|
28
|
+
t.set_value :c, t.get_value(:a) + t.get_value(:b)
|
29
|
+
end
|
30
|
+
|
31
|
+
t.layer :path_2_all, :path_2_mid do |t, data|
|
32
|
+
t.set_value :c, data[:a] * data[:b]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
>> cascade.build(:path_1_all, {:a => 1, :b => 2})
|
37
|
+
{:a => 2, :b => 1, :c => 3, :d => "abc"}
|
38
|
+
|
39
|
+
>> cascade.build(:path_1_mid, {:a => 1, :b => 2})
|
40
|
+
{:a => :2, :b => 2, :d => "abc"}
|
41
|
+
|
42
|
+
>> cascade.build(:path_2_all, {:a => 1, :b => 2})
|
43
|
+
{1 => :a, 2 => :b, :a => 1, :b => 2, :c => 2, :d => "abc"}
|
44
|
+
|
45
|
+
>> cascade.build(:path_2_mid, {:a => 1, :b => 2})
|
46
|
+
{1 => :a, 2 => :b, , :a => 1, :b => 2, :d => "abc"}
|
47
|
+
|
48
|
+
>> cascade.build(:path_share, {:a => 1, :b => 2})
|
49
|
+
{:a => 1, :b => 2, :d => "abc"}
|
50
|
+
|
51
|
+
>> cascade.build(:base, {:a => 1, :b => 2})
|
52
|
+
{:d => "abc"}
|
53
|
+
|
54
|
+
== Contributing to catheter
|
55
|
+
|
56
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
57
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
58
|
+
* Fork the project
|
59
|
+
* Start a feature/bugfix branch
|
60
|
+
* Commit and push until you are happy with your contribution
|
61
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
62
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
63
|
+
|
64
|
+
== Copyright
|
65
|
+
|
66
|
+
Copyright (c) 2010 Jordan West. See LICENSE.txt for
|
67
|
+
further details.
|
68
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "ht"
|
16
|
+
gem.homepage = "http://github.com/jrwest/catheter"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Simple Hash Templating for Ruby}
|
19
|
+
gem.description = %Q{Simple Hash Templating for Ruby}
|
20
|
+
gem.email = "jordanrw@gmail.com"
|
21
|
+
gem.authors = ["Jordan West"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rcov/rcovtask'
|
37
|
+
Rcov::RcovTask.new do |test|
|
38
|
+
test.libs << 'test'
|
39
|
+
test.pattern = 'test/**/test_*.rb'
|
40
|
+
test.verbose = true
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "catheter #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/ht.gemspec
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{ht}
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jordan West"]
|
12
|
+
s.date = %q{2010-11-24}
|
13
|
+
s.description = %q{Simple Hash Templating for Ruby}
|
14
|
+
s.email = %q{jordanrw@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"ht.gemspec",
|
28
|
+
"lib/ht.rb",
|
29
|
+
"lib/ht/cascade.rb",
|
30
|
+
"test/helper.rb",
|
31
|
+
"test/test_ht.rb"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://github.com/jrwest/catheter}
|
34
|
+
s.licenses = ["MIT"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.7}
|
37
|
+
s.summary = %q{Simple Hash Templating for Ruby}
|
38
|
+
s.test_files = [
|
39
|
+
"test/helper.rb",
|
40
|
+
"test/test_ht.rb"
|
41
|
+
]
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_development_dependency(%q<minitest>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<autotest>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
51
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
52
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<minitest>, [">= 0"])
|
55
|
+
s.add_dependency(%q<autotest>, [">= 0"])
|
56
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
58
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<minitest>, [">= 0"])
|
62
|
+
s.add_dependency(%q<autotest>, [">= 0"])
|
63
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
65
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
data/lib/ht/cascade.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module HT
|
2
|
+
class Cascade
|
3
|
+
attr_accessor :name
|
4
|
+
attr_reader :cascade
|
5
|
+
|
6
|
+
def initialize(name)
|
7
|
+
self.name = name
|
8
|
+
@cascade = {base: nil}
|
9
|
+
if block_given?
|
10
|
+
yield(self)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def base(&block)
|
15
|
+
@cascade[:base] = {depends: nil, block: block}
|
16
|
+
end
|
17
|
+
|
18
|
+
def layer(name, dependency=:base, &block)
|
19
|
+
@cascade[name] = {depends: dependency, block: block}
|
20
|
+
end
|
21
|
+
|
22
|
+
def build(name, opts)
|
23
|
+
@result = {}
|
24
|
+
|
25
|
+
top = @cascade[name]
|
26
|
+
dependency_list = build_dependency_list(name).reverse
|
27
|
+
dependency_list.each do |dependency|
|
28
|
+
next unless @cascade.has_key?(dependency) && @cascade[dependency].has_key?(:block)
|
29
|
+
@cascade[dependency][:block].call(self, opts)
|
30
|
+
end
|
31
|
+
|
32
|
+
top[:block].call(self, opts)
|
33
|
+
|
34
|
+
@result
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_dependency_list(name, cascade = @cascade)
|
38
|
+
if direct_dependency = cascade[name][:depends]
|
39
|
+
[direct_dependency] + build_dependency_list(direct_dependency, cascade)
|
40
|
+
else
|
41
|
+
[]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_direct_dependencies(name, cascade)
|
46
|
+
(cascade[name] || {})[:depends] || []
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_value(k, v)
|
50
|
+
return unless @result
|
51
|
+
|
52
|
+
@result[k] = v
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_value(k)
|
56
|
+
@result[k] if @result
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'minitest/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
require 'ht'
|
15
|
+
|
16
|
+
class MiniTest::Unit::TestCase
|
17
|
+
end
|
18
|
+
|
19
|
+
MiniTest::Unit.autorun
|
data/test/test_ht.rb
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
CASCADE = HT::Cascade.new(:my_cascade) do |t|
|
4
|
+
t.base do |to, opts|
|
5
|
+
to.set_value :item, opts[:item]
|
6
|
+
to.set_value :image, "#{opts[:player]}.png"
|
7
|
+
end
|
8
|
+
|
9
|
+
t.layer :contribute_base do |to, opts|
|
10
|
+
to.set_value :player, opts[:player]
|
11
|
+
to.set_value :image, "#{opts[:item]}.png"
|
12
|
+
end
|
13
|
+
|
14
|
+
t.layer :contribute_part, :contribute_base do |to, opts|
|
15
|
+
to.set_value :body, to.get_value(:image)
|
16
|
+
end
|
17
|
+
|
18
|
+
t.layer :contribute_part_1, :contribute_base do |to, opts|
|
19
|
+
to.set_value :body, "zxy"
|
20
|
+
to.set_value :field, "def"
|
21
|
+
to.set_value :field2, "123"
|
22
|
+
end
|
23
|
+
|
24
|
+
t.layer :contribute_super, :contribute_part do |to, opts|
|
25
|
+
to.set_value :field, to.get_value(:image)
|
26
|
+
to.set_value :body, "abc"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
OPTS = {:player => "jordanrw", :item => "cool-thing"}
|
32
|
+
|
33
|
+
class TestHT < MiniTest::Unit::TestCase
|
34
|
+
def test_base
|
35
|
+
result = CASCADE.build(:base, OPTS)
|
36
|
+
|
37
|
+
assert_equal OPTS[:item], result[:item]
|
38
|
+
assert_equal "#{OPTS[:player]}.png", result[:image]
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_one_layer
|
42
|
+
result = CASCADE.build(:contribute_base, OPTS)
|
43
|
+
|
44
|
+
assert_equal OPTS[:player], result[:player]
|
45
|
+
assert_equal "#{OPTS[:item]}.png", result[:image]
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_two_layers
|
49
|
+
result = CASCADE.build(:contribute_super, OPTS)
|
50
|
+
|
51
|
+
assert_equal OPTS[:player], result[:player]
|
52
|
+
assert_equal OPTS[:item], result[:item]
|
53
|
+
assert_equal "#{OPTS[:item]}.png", result[:field]
|
54
|
+
assert_equal "abc", result[:body]
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_three_layers
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
def test_build_dependency_list_base_case
|
63
|
+
cascade = {base: {depends: nil, block: nil}}
|
64
|
+
|
65
|
+
assert_equal [], CASCADE.build_dependency_list(:base, cascade)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_build_dependency_base_case_when_layers_exist
|
69
|
+
cascade = {base: {depends: nil, block: nil}, contribute_base: {depends: :base, block: nil}}
|
70
|
+
|
71
|
+
assert_equal [], CASCADE.build_dependency_list(:base, cascade)
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def test_build_dependency_one_layer_up
|
76
|
+
cascade = {base: {depends: nil, block: nil},
|
77
|
+
contribute_base: {depends: :base, block: nil}}
|
78
|
+
|
79
|
+
assert_equal [:base], CASCADE.build_dependency_list(:contribute_base, cascade)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_build_dependency_two_layers_up
|
83
|
+
cascade = {base: {depends: nil, block: nil},
|
84
|
+
contribute_base: {depends: :base, block: nil},
|
85
|
+
contribute_part: {depends: :contribute_base, block: nil}}
|
86
|
+
|
87
|
+
assert_equal [:contribute_base, :base] , CASCADE.build_dependency_list(:contribute_part, cascade)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_build_dependency_three_layers_up
|
91
|
+
cascade = {base: {depends: nil, block: nil},
|
92
|
+
contribute_base: {depends: :base, block: nil},
|
93
|
+
contribute_part: {depends: :contribute_base, block: nil},
|
94
|
+
contribute_part_2: {depends: :contribute_part, block: nil}}
|
95
|
+
|
96
|
+
assert_equal [:contribute_part, :contribute_base, :base] , CASCADE.build_dependency_list(:contribute_part_2, cascade)
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_build_dependency_six_layers_up
|
100
|
+
cascade = {base: {depends: nil}, block: nil,
|
101
|
+
contribute_base: {depends: :base, block: nil},
|
102
|
+
contribute_part: {depends: :contribute_base, block: nil},
|
103
|
+
contribute_part_2: {depends: :contribute_part, block: nil},
|
104
|
+
contribute_part_3: {depends: :contribute_part_2, block: nil},
|
105
|
+
contribute_part_4: {depends: :contribute_part_3, block: nil},
|
106
|
+
contribute_part_5: {depends: :contribute_part_4, block: nil}}
|
107
|
+
|
108
|
+
expected = [:contribute_part_4, :contribute_part_3, :contribute_part_2, :contribute_part, :contribute_base, :base]
|
109
|
+
|
110
|
+
|
111
|
+
assert_equal [], CASCADE.build_dependency_list(:base, cascade)
|
112
|
+
assert_equal [:contribute_part_2, :contribute_part, :contribute_base, :base], CASCADE.build_dependency_list(:contribute_part_3, cascade)
|
113
|
+
assert_equal expected, CASCADE.build_dependency_list(:contribute_part_5, cascade)
|
114
|
+
end
|
115
|
+
#
|
116
|
+
#
|
117
|
+
# def test_build_dependency_two_layers_two_branches
|
118
|
+
# cascade = {base: {depends: nil, block: nil},
|
119
|
+
# contribute_base_1: {depends: [:base], block:nil},
|
120
|
+
# contribute_base_2: {depends: [:base], block:nil},
|
121
|
+
# contribute_part_1: {depends: [:contribute_base_1, :contribute_base_2]}}
|
122
|
+
#
|
123
|
+
#
|
124
|
+
# assert_equal [:contribute_base_1, :contribute_base_2, :base], CASCADE.build_dependency_list(:contribute_part_1, cascade)
|
125
|
+
#
|
126
|
+
# cascade = {base: {depends: nil, block: nil},
|
127
|
+
# contribute_base_1: {depends: [:base], block:nil},
|
128
|
+
# contribute_base_2: {depends: [:base], block:nil},
|
129
|
+
# contribute_part_1: {depends: [:contribute_base_2, :contribute_base_1]}}
|
130
|
+
#
|
131
|
+
# assert_equal [:contribute_base_2, :contribute_base_1, :base], CASCADE.build_dependency_list(:contribute_part_1, cascade)
|
132
|
+
# end
|
133
|
+
#
|
134
|
+
# def test_build_dependency_two_layers_three_branches
|
135
|
+
# cascade = {base: {depends: nil, block: nil},
|
136
|
+
# contribute_base_1: {depends: [:base], block:nil},
|
137
|
+
# contribute_base_2: {depends: [:base], block:nil},
|
138
|
+
# contribute_base_3: {depends: [:base], block:nil},
|
139
|
+
# contribute_part_1: {depends: [:contribute_base_1, :contribute_base_2]},
|
140
|
+
# contribute_part_2: {depends: [:contribute_base_3, :contribute_base_1, :contribute_base_2]}}
|
141
|
+
#
|
142
|
+
# assert_equal [:contribute_base_1, :contribute_base_2, :base], CASCADE.build_dependency_list(:contribute_part_1, cascade)
|
143
|
+
# assert_equal [:contribute_base_3, :contribute_base_1, :contribute_base_2, :base], CASCADE.build_dependency_list(:contribute_part_2, cascade)
|
144
|
+
#
|
145
|
+
# end
|
146
|
+
#
|
147
|
+
# def test_build_dependency_three_layers_5_branches
|
148
|
+
# cascade = {base: {depends: nil, block: nil},
|
149
|
+
# contribute_base_1: {depends: [:base], block:nil},
|
150
|
+
# contribute_base_2: {depends: [:base], block:nil},
|
151
|
+
# contribute_base_3: {depends: [:base], block:nil},
|
152
|
+
# contribute_part_1: {depends: [:contribute_base_1, :contribute_base_2]},
|
153
|
+
# contribute_part_2: {depends: [:contribute_base_3, :contribute_base_1, :contribute_base_2]},
|
154
|
+
# contribute_top: {depends: [:contribute_part_1, :contribute_part_2], block: nil}}
|
155
|
+
#
|
156
|
+
#
|
157
|
+
#
|
158
|
+
# expected = [:contribute_part_1, :contribute_part_2, :contribute_base_1, :contribute_base_2, :contribute_base_3, :base]
|
159
|
+
# assert_equal [:contribute_base_1, :contribute_base_2, :base], CASCADE.build_dependency_list(:contribute_part_1, cascade)
|
160
|
+
# assert_equal [:contribute_base_3, :contribute_base_1, :contribute_base_2, :base], CASCADE.build_dependency_list(:contribute_part_2, cascade)
|
161
|
+
# assert_equal expected, CASCADE.build_dependency_list(:contribute_top, cascade)
|
162
|
+
# end
|
163
|
+
#
|
164
|
+
# def test_build_dependency_medium_test
|
165
|
+
# cascade = {base: {depends: nil, block: nil},
|
166
|
+
# contribute_base_1: {depends: [:base]},
|
167
|
+
# contribute_base_2: {depends: [:base]},
|
168
|
+
# contribute_interim: {depends: [:contribute_base_1]},
|
169
|
+
# contribute_part_1: {depends: [:contribute_interim]},
|
170
|
+
# contribute_part_2: {depends: [:contribute_base_2, :contribute_base_1]},
|
171
|
+
# contribute_part_3: {depends: [:contribute_part_1]},
|
172
|
+
# contribute_part_4: {depends: [:contribute_part_2]},
|
173
|
+
# contribute_all: {depends: [:contribute_part_3, :contribute_part_4]}}
|
174
|
+
#
|
175
|
+
# #expected [:contribute_part_4, :contribute_part_2, :contribute_base_2, :contribute_part_3, :contribute_part_1, :contribute_interim, :contribute_base_1, :base]
|
176
|
+
# #expected [:contribute_part_3, :contribute_part_1, :contribute_interim, :contribute_base_1, :contribute_part_4, :contribute_part_2, :contribute_base_2, :base]
|
177
|
+
# #expected = [:contribute_part_3, :contribute_part_4, :contribute_part_1, :contribute_part_2, :contribute_interim, :contribute_base_2, :contribute_base_1, :base]
|
178
|
+
# #expected = [:contribute_part_3, :contribute_part_4, :contribute_part_1, :contribute_part_2, :contribute_interim, :contribute_base_1, :contribute_base_2, :base]
|
179
|
+
# assert_equal expected, CASCADE.build_dependency_list(:contribute_all, cascade)
|
180
|
+
#
|
181
|
+
# end
|
182
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ht
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jordan West
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-11-24 00:00:00 -08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: minitest
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
prerelease: false
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: autotest
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
version: "0"
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 1
|
55
|
+
- 0
|
56
|
+
- 0
|
57
|
+
version: 1.0.0
|
58
|
+
type: :development
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: *id003
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: jeweler
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 1
|
70
|
+
- 5
|
71
|
+
- 1
|
72
|
+
version: 1.5.1
|
73
|
+
type: :development
|
74
|
+
prerelease: false
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: rcov
|
78
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: *id005
|
89
|
+
description: Simple Hash Templating for Ruby
|
90
|
+
email: jordanrw@gmail.com
|
91
|
+
executables: []
|
92
|
+
|
93
|
+
extensions: []
|
94
|
+
|
95
|
+
extra_rdoc_files:
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.rdoc
|
98
|
+
files:
|
99
|
+
- .document
|
100
|
+
- Gemfile
|
101
|
+
- Gemfile.lock
|
102
|
+
- LICENSE.txt
|
103
|
+
- README.rdoc
|
104
|
+
- Rakefile
|
105
|
+
- VERSION
|
106
|
+
- ht.gemspec
|
107
|
+
- lib/ht.rb
|
108
|
+
- lib/ht/cascade.rb
|
109
|
+
- test/helper.rb
|
110
|
+
- test/test_ht.rb
|
111
|
+
has_rdoc: true
|
112
|
+
homepage: http://github.com/jrwest/catheter
|
113
|
+
licenses:
|
114
|
+
- MIT
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: -745928465697770621
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
version: "0"
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
version: "0"
|
137
|
+
requirements: []
|
138
|
+
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 1.3.7
|
141
|
+
signing_key:
|
142
|
+
specification_version: 3
|
143
|
+
summary: Simple Hash Templating for Ruby
|
144
|
+
test_files:
|
145
|
+
- test/helper.rb
|
146
|
+
- test/test_ht.rb
|