web_blocks 2.0.0.dev
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +23 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +1 -0
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +27 -0
- data/README.md +641 -0
- data/Rakefile +13 -0
- data/bin/blocks +9 -0
- data/demo/.gitignore +4 -0
- data/demo/Blockfile.rb +67 -0
- data/demo/bower.json +8 -0
- data/demo/package.json +5 -0
- data/demo/src/config/WebBlocks-breakpoints.scss +9 -0
- data/lib/web_blocks/framework.rb +20 -0
- data/lib/web_blocks/manager/bower.rb +106 -0
- data/lib/web_blocks/manager/builder/base.rb +31 -0
- data/lib/web_blocks/manager/builder/js.rb +54 -0
- data/lib/web_blocks/manager/builder/scss.rb +57 -0
- data/lib/web_blocks/manager/parallel_builder.rb +52 -0
- data/lib/web_blocks/product/concat_file/js.rb +15 -0
- data/lib/web_blocks/product/concat_file/raw.rb +33 -0
- data/lib/web_blocks/product/concat_file/scss.rb +21 -0
- data/lib/web_blocks/strategy/compile/scss.rb +90 -0
- data/lib/web_blocks/strategy/link/base.rb +51 -0
- data/lib/web_blocks/strategy/link/js.rb +30 -0
- data/lib/web_blocks/strategy/link/scss.rb +30 -0
- data/lib/web_blocks/structure/attribute/dependency.rb +25 -0
- data/lib/web_blocks/structure/attribute/loose_dependency.rb +25 -0
- data/lib/web_blocks/structure/attribute/reverse_dependency.rb +16 -0
- data/lib/web_blocks/structure/attribute/reverse_loose_dependency.rb +16 -0
- data/lib/web_blocks/structure/block.rb +95 -0
- data/lib/web_blocks/structure/font_file.rb +9 -0
- data/lib/web_blocks/structure/framework.rb +79 -0
- data/lib/web_blocks/structure/img_file.rb +9 -0
- data/lib/web_blocks/structure/js_file.rb +9 -0
- data/lib/web_blocks/structure/raw_file.rb +30 -0
- data/lib/web_blocks/structure/scss_file.rb +9 -0
- data/lib/web_blocks/structure/tree/leaf_node.rb +44 -0
- data/lib/web_blocks/structure/tree/node.rb +14 -0
- data/lib/web_blocks/structure.rb +7 -0
- data/lib/web_blocks/support/attributes/class/container.rb +24 -0
- data/lib/web_blocks/support/attributes/container.rb +41 -0
- data/lib/web_blocks/support/parallel_jobs.rb +26 -0
- data/lib/web_blocks/support/scoped_logger.rb +49 -0
- data/lib/web_blocks/support/tree/child.rb +23 -0
- data/lib/web_blocks/support/tree/node.rb +14 -0
- data/lib/web_blocks/support/tree/parent.rb +35 -0
- data/lib/web_blocks/support/tsort/hash.rb +29 -0
- data/lib/web_blocks/thor/base/class/type_get_class_from_string.rb +36 -0
- data/lib/web_blocks/thor/base/class/types.rb +21 -0
- data/lib/web_blocks/thor/base/initialize.rb +145 -0
- data/lib/web_blocks/thor/base/prepare_blocks.rb +155 -0
- data/lib/web_blocks/thor/base.rb +12 -0
- data/lib/web_blocks/thor/build/all.rb +30 -0
- data/lib/web_blocks/thor/build.rb +13 -0
- data/lib/web_blocks/thor/inspect/blocks/attribute_printer.rb +48 -0
- data/lib/web_blocks/thor/inspect/blocks/block_printer.rb +43 -0
- data/lib/web_blocks/thor/inspect/blocks/printer.rb +24 -0
- data/lib/web_blocks/thor/inspect/blocks.rb +27 -0
- data/lib/web_blocks/thor/inspect/bower_registry.rb +24 -0
- data/lib/web_blocks/thor/inspect/dependency_list.rb +30 -0
- data/lib/web_blocks/thor/inspect/dependency_order.rb +26 -0
- data/lib/web_blocks/thor/inspect.rb +11 -0
- data/lib/web_blocks/thor/partial/compile/scss.rb +24 -0
- data/lib/web_blocks/thor/partial/compile.rb +13 -0
- data/lib/web_blocks/thor/partial/link/js.rb +23 -0
- data/lib/web_blocks/thor/partial/link/scss.rb +23 -0
- data/lib/web_blocks/thor/partial/link.rb +13 -0
- data/lib/web_blocks/thor/partial/runner.rb +14 -0
- data/lib/web_blocks/thor/runner.rb +16 -0
- data/lib/web_blocks/thor/watch/all.rb +67 -0
- data/lib/web_blocks/thor/watch.rb +13 -0
- data/lib/web_blocks/version.rb +3 -0
- data/lib/web_blocks.rb +13 -0
- data/test/init.rb +7 -0
- data/test/web_blocks/framework.rb +40 -0
- data/test/web_blocks/structure.rb +42 -0
- data/test/web_blocks/support/attribute/class/container.rb +29 -0
- data/test/web_blocks/support/attribute/container.rb +71 -0
- data/test/web_blocks/support/tree/child.rb +60 -0
- data/test/web_blocks/support/tree/node.rb +18 -0
- data/test/web_blocks/support/tree/parent.rb +81 -0
- data/test/web_blocks/version.rb +10 -0
- data/web_blocks.gemspec +35 -0
- metadata +297 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'web_blocks/thor/partial/link'
|
2
|
+
require 'web_blocks/strategy/link/scss'
|
3
|
+
|
4
|
+
module WebBlocks
|
5
|
+
module Thor
|
6
|
+
module Partial
|
7
|
+
class Link
|
8
|
+
|
9
|
+
description = "Construct linked construct of SCSS files based on dependencies"
|
10
|
+
desc "scss", description
|
11
|
+
long_desc description
|
12
|
+
|
13
|
+
def scss
|
14
|
+
|
15
|
+
prepare_blocks!
|
16
|
+
::WebBlocks::Strategy::Link::Scss.new(self).execute!
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'web_blocks/thor/partial/link'
|
3
|
+
require 'web_blocks/thor/partial/compile'
|
4
|
+
|
5
|
+
module WebBlocks
|
6
|
+
module Thor
|
7
|
+
module Partial
|
8
|
+
class Runner < ::Thor
|
9
|
+
register ::WebBlocks::Thor::Partial::Link, :link, "link", "Linker that prepares assets for compilation"
|
10
|
+
register ::WebBlocks::Thor::Partial::Compile, :compile, "compile", "Compiler that builds assets from linked sources"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'web_blocks/thor/inspect'
|
3
|
+
require 'web_blocks/thor/partial/runner'
|
4
|
+
require 'web_blocks/thor/build'
|
5
|
+
require 'web_blocks/thor/watch'
|
6
|
+
|
7
|
+
module WebBlocks
|
8
|
+
module Thor
|
9
|
+
class Runner < ::Thor
|
10
|
+
register ::WebBlocks::Thor::Inspect, :inspect, "inspect", "Inspect the blocks configuration and tree"
|
11
|
+
register ::WebBlocks::Thor::Build, :build, "build", "Link, compile and optimize all assets"
|
12
|
+
register ::WebBlocks::Thor::Watch, :watch, "watch", "Watch for changes and rebuild all assets"
|
13
|
+
register ::WebBlocks::Thor::Partial::Runner, :partial, "partial", "Perform a single step of the build process"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'fssm'
|
3
|
+
require 'web_blocks/thor/watch'
|
4
|
+
require 'web_blocks/manager/parallel_builder'
|
5
|
+
|
6
|
+
module WebBlocks
|
7
|
+
module Thor
|
8
|
+
class Watch
|
9
|
+
|
10
|
+
description = "Watch and rebuild all assets"
|
11
|
+
desc "all", description
|
12
|
+
long_desc description
|
13
|
+
|
14
|
+
def all
|
15
|
+
|
16
|
+
# TODO: refactor this file so it's not a run-on routine
|
17
|
+
|
18
|
+
prepare_blocks!
|
19
|
+
|
20
|
+
task = self
|
21
|
+
|
22
|
+
triggers = root.adjacency_list.keys.map(){|f| f.resolved_path.to_s }
|
23
|
+
triggers << base_path + 'Blockfile.rb'
|
24
|
+
triggers << base_path + '.blocks/cache/bower/registry.yaml'
|
25
|
+
triggers << base_path + 'bower_components/*/Blockfile.rb'
|
26
|
+
|
27
|
+
handler = Proc.new do |base, relative|
|
28
|
+
|
29
|
+
changed_file = Pathname.new(base) + relative
|
30
|
+
relink_needed = changed_file.to_s.match(/Blockfile.rb$/)
|
31
|
+
|
32
|
+
log.info("Watch"){ "Detected change to #{changed_file}" }
|
33
|
+
|
34
|
+
if relink_needed
|
35
|
+
root.remove_all_children
|
36
|
+
prepare_blocks!
|
37
|
+
end
|
38
|
+
|
39
|
+
begin
|
40
|
+
|
41
|
+
jobs = WebBlocks::Manager::ParallelBuilder.new task
|
42
|
+
jobs.start :scss
|
43
|
+
jobs.start :js
|
44
|
+
jobs.save_when_done!
|
45
|
+
|
46
|
+
rescue ::TSort::Cyclic => e
|
47
|
+
|
48
|
+
log.error { "Build failed -- Cyclical dependencies detected" }
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
monitor = FSSM::Monitor.new
|
55
|
+
monitor.path @base_path do
|
56
|
+
glob triggers
|
57
|
+
update &handler
|
58
|
+
delete &handler
|
59
|
+
create &handler
|
60
|
+
end
|
61
|
+
monitor.run
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/web_blocks.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
# This module contains WebBlocks-related libraries:
|
4
|
+
#
|
5
|
+
# * {WebBlocks::Framework} defines singleton accessor method framework
|
6
|
+
# * {WebBlocks::Structure} defines the structures that comprise WebBlocks
|
7
|
+
# * {WebBlocks::Support} defines supporting libraries used by WebBlocks
|
8
|
+
#
|
9
|
+
# Also see {file:REFERENCE.md full WebBlocks reference}.
|
10
|
+
module WebBlocks; end
|
11
|
+
|
12
|
+
# Require all WebBlocks library files
|
13
|
+
Dir.glob(Pathname.new(__FILE__).parent.realpath + "**/*.rb").each { |r| require r }
|
data/test/init.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'web_blocks/framework'
|
3
|
+
|
4
|
+
class TestFramework < Test::Unit::TestCase
|
5
|
+
|
6
|
+
include WebBlocks::Framework
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@@framework = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_singleton
|
13
|
+
previous = framework
|
14
|
+
@@framework = nil
|
15
|
+
current = framework
|
16
|
+
assert previous != current, "Setting @@framework nil in WebBlocks::Framework context destroys singleton"
|
17
|
+
assert current === framework, "framework returns same object on subsequent calls"
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_type
|
21
|
+
assert framework, "framework method within WebBlocks::Framework"
|
22
|
+
assert framework.is_a?(::WebBlocks::Structure::Framework), "framework method returns ::WebBlocks::Structure::Framework"
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_attributes
|
26
|
+
framework :test => true
|
27
|
+
assert framework.get(:test), 'Attribute set from method parameters on singleton instantiation'
|
28
|
+
framework :added_attribute => true
|
29
|
+
assert framework.get(:added_attribute), 'Attribute set from method parameters on singleton access'
|
30
|
+
framework do
|
31
|
+
set :block_set_attribute, true
|
32
|
+
end
|
33
|
+
assert framework.get(:block_set_attribute), 'Block context executed'
|
34
|
+
framework :block_override_attribute => false do
|
35
|
+
set :block_override_attribute, true
|
36
|
+
end
|
37
|
+
assert framework.get(:block_override_attribute), 'Block context executed after attributes set from method parameters'
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'web_blocks/structure'
|
3
|
+
|
4
|
+
class TestStructure < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_namespace
|
7
|
+
|
8
|
+
assert_nothing_raised("Structure module defined"){ WebBlocks::Structure }
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_structures_classes
|
13
|
+
|
14
|
+
['Block','FontFile','Framework','ImgFile','JsFile','RawFile','ScssFile'].each do |type|
|
15
|
+
klass = nil
|
16
|
+
assert_nothing_raised("#{type} class defined"){ klass = eval "WebBlocks::Structure::#{type}" }
|
17
|
+
assert klass.class == Class
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_structure_attribute_modules
|
23
|
+
|
24
|
+
['Dependency','LooseDependency'].each do |type|
|
25
|
+
mod = nil
|
26
|
+
assert_nothing_raised("Attribute::#{type} module defined"){ mod = eval "WebBlocks::Structure::Attribute::#{type}" }
|
27
|
+
assert mod.class == Module
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_structure_tree_classes
|
33
|
+
|
34
|
+
['LeafNode','Node'].each do |type|
|
35
|
+
klass = nil
|
36
|
+
assert_nothing_raised("Tree::#{type} class defined"){ klass = eval "WebBlocks::Structure::Tree::#{type}" }
|
37
|
+
assert klass.class == Class
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'web_blocks/support/attributes/class/container'
|
3
|
+
|
4
|
+
class TestSupportAttributesClassContainer < Test::Unit::TestCase
|
5
|
+
|
6
|
+
class Container
|
7
|
+
class << self
|
8
|
+
include WebBlocks::Support::Attributes::Class::Container
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@name = Container.name
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_type
|
17
|
+
assert Container.attributes.is_a? Hash
|
18
|
+
assert Container.attributes(@name).is_a? Hash
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_set
|
22
|
+
assert Container.attributes(@name).length == 0
|
23
|
+
Container.set :test1, :value
|
24
|
+
assert Container.attributes(@name).is_a? Hash
|
25
|
+
assert Container.attributes(@name).length == 1
|
26
|
+
assert Container.attributes(@name)[:test1] == :value
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'web_blocks/support/attributes/container'
|
3
|
+
|
4
|
+
class TestSupportAttributesContainer < Test::Unit::TestCase
|
5
|
+
|
6
|
+
class Container
|
7
|
+
include WebBlocks::Support::Attributes::Container
|
8
|
+
end
|
9
|
+
|
10
|
+
class ClassContainer
|
11
|
+
class << self
|
12
|
+
include WebBlocks::Support::Attributes::Class::Container
|
13
|
+
end
|
14
|
+
include WebBlocks::Support::Attributes::Container
|
15
|
+
set :container, :container_value
|
16
|
+
set :container_overridden, :container_value
|
17
|
+
end
|
18
|
+
|
19
|
+
class ContainerWithClassContainers < ClassContainer
|
20
|
+
class << self
|
21
|
+
include WebBlocks::Support::Attributes::Class::Container
|
22
|
+
end
|
23
|
+
include WebBlocks::Support::Attributes::Container
|
24
|
+
set :container_overridden, :container_overridden_value
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_has_get_set
|
28
|
+
container = Container.new
|
29
|
+
assert !container.has?(:key)
|
30
|
+
container.set(:key, :value)
|
31
|
+
assert container.has?(:key)
|
32
|
+
assert container.get(:key) == :value
|
33
|
+
hash = container.set(:key2, :value2)
|
34
|
+
assert hash[:key] == :value
|
35
|
+
assert hash[:key2] == :value2
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_class_attributes
|
39
|
+
container = ContainerWithClassContainers.new
|
40
|
+
class_attributes = container.class_attributes
|
41
|
+
assert class_attributes[:container] == :container_value
|
42
|
+
assert class_attributes[:container_overridden] == :container_overridden_value
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_attributes_with_inheritance
|
46
|
+
container = ContainerWithClassContainers.new
|
47
|
+
assert container.get(:container) == :container_value
|
48
|
+
assert container.get(:container_overridden) == :container_overridden_value
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_attributes_inheritance_with_override
|
52
|
+
container = ContainerWithClassContainers.new
|
53
|
+
container.attributes :container => :instance_override,
|
54
|
+
:container_overridden => :instance_override
|
55
|
+
assert container.get(:container) == :instance_override
|
56
|
+
assert container.get(:container_overridden) == :instance_override
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_push
|
60
|
+
container = Container.new
|
61
|
+
container.set :arr, []
|
62
|
+
container.push :arr, :val1
|
63
|
+
assert container.get(:arr).length == 1
|
64
|
+
container.push :arr, :val2
|
65
|
+
arr = container.get(:arr)
|
66
|
+
assert arr.length == 2
|
67
|
+
assert arr[0] == :val1
|
68
|
+
assert arr[1] == :val2
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'web_blocks/support/tree/child'
|
3
|
+
|
4
|
+
class TestSupportTreeChild < Test::Unit::TestCase
|
5
|
+
|
6
|
+
class Child
|
7
|
+
include ::WebBlocks::Support::Tree::Child
|
8
|
+
end
|
9
|
+
|
10
|
+
class Parent
|
11
|
+
attr_accessor :child
|
12
|
+
# stub method that just sets @child as child rather than adds to array - just for testing purposes
|
13
|
+
# real version in WebBlocks::Support::Tree::Parent adds it to a children array
|
14
|
+
def add_child parent
|
15
|
+
@child = parent
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class ChildWithName < Child
|
20
|
+
attr_reader :name
|
21
|
+
def initialize name
|
22
|
+
@name = name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_parent
|
27
|
+
child = Child.new
|
28
|
+
assert child.respond_to? :parent
|
29
|
+
assert child.parent == nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_set_parent
|
33
|
+
child = Child.new
|
34
|
+
parent = Parent.new
|
35
|
+
child.set_parent parent
|
36
|
+
assert child.parent === parent
|
37
|
+
assert parent.child === child
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_set_parent_no_add_child_method
|
41
|
+
child = Child.new
|
42
|
+
parent_without_add_child = Child.new
|
43
|
+
child.set_parent parent_without_add_child
|
44
|
+
assert child.parent === parent_without_add_child
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_parents
|
48
|
+
child = Child.new
|
49
|
+
parent = Child.new
|
50
|
+
parent_parent = Child.new
|
51
|
+
child.set_parent parent
|
52
|
+
parent.set_parent parent_parent
|
53
|
+
assert child.parent === parent
|
54
|
+
assert parent.parent === parent_parent
|
55
|
+
parents = child.parents
|
56
|
+
assert parents[0] === parent
|
57
|
+
assert parents[1] === parent_parent
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'web_blocks/support/tree/node'
|
3
|
+
|
4
|
+
class TestSupportTreeNode < Test::Unit::TestCase
|
5
|
+
|
6
|
+
class Node
|
7
|
+
include ::WebBlocks::Support::Tree::Node
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_name
|
11
|
+
node = Node.new('name')
|
12
|
+
assert node.name == 'name'
|
13
|
+
assert_raise NoMethodError do
|
14
|
+
node.name = 'test'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'web_blocks/support/tree/parent'
|
3
|
+
|
4
|
+
class TestSupportTreeParent < Test::Unit::TestCase
|
5
|
+
|
6
|
+
class Parent
|
7
|
+
include ::WebBlocks::Support::Tree::Parent
|
8
|
+
end
|
9
|
+
|
10
|
+
# stub to check named node association
|
11
|
+
class NamedNode
|
12
|
+
attr_reader :name
|
13
|
+
def initialize name
|
14
|
+
@name = name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# stub to check proper call of add_parent
|
19
|
+
class Child < NamedNode
|
20
|
+
attr_reader :parent
|
21
|
+
def set_parent parent
|
22
|
+
@parent = parent
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_children
|
27
|
+
parent = Parent.new
|
28
|
+
assert parent.children.is_a? Hash
|
29
|
+
assert parent.children.size == 0
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_add_children
|
33
|
+
|
34
|
+
parent = Parent.new
|
35
|
+
child = Child.new 'name'
|
36
|
+
|
37
|
+
parent.add_child child
|
38
|
+
assert parent.children.is_a? Hash
|
39
|
+
assert parent.children.size == 1
|
40
|
+
assert parent.children.has_key? 'name'
|
41
|
+
assert parent.children['name'] === child
|
42
|
+
assert child.parent === parent
|
43
|
+
assert parent.has_child? 'name'
|
44
|
+
|
45
|
+
child2 = Child.new 'name2'
|
46
|
+
|
47
|
+
parent.add_child child2
|
48
|
+
assert parent.children.size == 2
|
49
|
+
|
50
|
+
parent.remove_child 'name2'
|
51
|
+
assert parent.children.size == 1
|
52
|
+
assert parent.children.has_key? 'name'
|
53
|
+
assert parent.has_child? 'name'
|
54
|
+
assert !parent.children.has_key?('name2')
|
55
|
+
assert !parent.has_child?('name2')
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
# Should use object as key if no #name method exists
|
60
|
+
def test_add_children_no_name
|
61
|
+
parent = Parent.new
|
62
|
+
child_without_name = Parent.new
|
63
|
+
parent.add_child child_without_name
|
64
|
+
assert parent.children.has_key?(child_without_name)
|
65
|
+
assert parent.children[child_without_name] == child_without_name
|
66
|
+
assert parent.has_child? child_without_name
|
67
|
+
parent.remove_child child_without_name
|
68
|
+
assert !parent.has_child?(child_without_name)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_add_children_no_set_parent
|
72
|
+
parent = Parent.new
|
73
|
+
named_node = NamedNode.new 'name'
|
74
|
+
assert_nothing_raised do
|
75
|
+
parent.add_child named_node
|
76
|
+
end
|
77
|
+
assert parent.children.has_key? 'name'
|
78
|
+
assert parent.children['name'] === named_node
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
data/web_blocks.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'web_blocks/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
|
8
|
+
spec.name = 'web_blocks'
|
9
|
+
spec.version = WebBlocks::VERSION
|
10
|
+
spec.authors = ['Eric Bollens']
|
11
|
+
spec.email = ['ebollens@ucla.edu']
|
12
|
+
spec.description = 'Package, configuration and dependency manager for web assets (SCSS, JS, images, and fonts)'
|
13
|
+
spec.summary = 'package, configuration and dependency manager for web assets (SCSS, JS, images, and fonts)'
|
14
|
+
spec.homepage = 'http://github.com/WebBlocks/WebBlocks'
|
15
|
+
spec.license = 'BSD'
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'thor'
|
23
|
+
spec.add_dependency 'ruby-bower'
|
24
|
+
spec.add_dependency 'execjs'
|
25
|
+
spec.add_dependency 'extend_method'
|
26
|
+
spec.add_dependency 'compass'
|
27
|
+
spec.add_dependency 'sass-css-importer'
|
28
|
+
spec.add_dependency 'fork'
|
29
|
+
spec.add_dependency 'fssm'
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler'
|
32
|
+
spec.add_development_dependency 'rake'
|
33
|
+
spec.add_development_dependency 'coveralls'
|
34
|
+
|
35
|
+
end
|