web_blocks 2.0.0.dev
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.
- 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
data/demo/Blockfile.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
2
|
+
#
|
3
|
+
# BLOCKSFILE EXAMPLE
|
4
|
+
#
|
5
|
+
# This file is intended to showcase some of the common features available to Blocksfile.rb. In production, it is likely
|
6
|
+
# that helpers will be used to cut down on boilerplate. Additionally, Blocksfile.rb is pure Ruby, so it supports being
|
7
|
+
# split into a number of files for organizational purposes.
|
8
|
+
#
|
9
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
10
|
+
|
11
|
+
#
|
12
|
+
# CUSTOM BLOCK DEFINITIONS
|
13
|
+
#
|
14
|
+
# Ideally, frameworks and tools should include Blockfile.rb; however, this will not always be the case. In some cases,
|
15
|
+
# frameworks may not explicitly support WebBlocks (even though, through this syntax, WebBlocks can support them), and,
|
16
|
+
# in others, it may be advantageous simply to download a build product.
|
17
|
+
#
|
18
|
+
|
19
|
+
# Adding a jQuery block as jQuery does not include a Blockfile.rb defining it
|
20
|
+
block 'jquery', :path => 'bower_components/jquery/dist' do
|
21
|
+
js_file 'jquery.js'
|
22
|
+
end
|
23
|
+
|
24
|
+
# Adding a dependency on the jquery block for efx to include jquery if including efx
|
25
|
+
block 'efx' do
|
26
|
+
dependency framework.route 'jquery'
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# BLOCK INCLUSIONS
|
31
|
+
#
|
32
|
+
# This registration defines which blocks will be included in the build.
|
33
|
+
#
|
34
|
+
|
35
|
+
include 'WebBlocks-visibility', 'breakpoint'
|
36
|
+
include 'WebBlocks-visibility', 'accessible'
|
37
|
+
|
38
|
+
include 'efx', 'driver', 'accordion'
|
39
|
+
include 'efx', 'driver', 'tabs'
|
40
|
+
include 'efx', 'driver', 'toggle'
|
41
|
+
|
42
|
+
# also valid would be either of these to include all efx drivers:
|
43
|
+
# include 'efx', 'driver'
|
44
|
+
# include 'efx'
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
#
|
49
|
+
# CUSTOM SOURCES
|
50
|
+
#
|
51
|
+
# This defines an 'src' block intended to for application-specific sources.
|
52
|
+
#
|
53
|
+
|
54
|
+
block 'WebBlocks', :path => Pathname.new(__FILE__).parent + 'src' do
|
55
|
+
|
56
|
+
block 'config', :path => 'config' do
|
57
|
+
|
58
|
+
block 'WebBlocks-breakpoints' do
|
59
|
+
|
60
|
+
scss_file 'WebBlocks-breakpoints.scss'
|
61
|
+
reverse_dependency framework.route 'WebBlocks-breakpoints'
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
data/demo/bower.json
ADDED
data/demo/package.json
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
//$breakpoint-xxsmall: 360px !default;
|
2
|
+
//$breakpoint-xsmall: 480px !default;
|
3
|
+
//$breakpoint-small: 640px !default;
|
4
|
+
//$breakpoint-medium-small: 768px !default;
|
5
|
+
//$breakpoint-medium: 900px !default;
|
6
|
+
//$breakpoint-medium-large: 1024px !default;
|
7
|
+
//$breakpoint-large: 1200px !default;
|
8
|
+
//$breakpoint-xlarge: 1500px !default;
|
9
|
+
//$breakpoint-xxlarge: 1800px !default;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module WebBlocks
|
2
|
+
module Framework
|
3
|
+
|
4
|
+
def framework options = {}, &block
|
5
|
+
|
6
|
+
# Lazy-load to avoid cyclical require loop with 'web_blocks/structure/framework'
|
7
|
+
require 'web_blocks/structure/framework'
|
8
|
+
@@framework ||= ::WebBlocks::Structure::Framework.new 'framework'
|
9
|
+
|
10
|
+
# Set options, if any were passed
|
11
|
+
options.each { |name, value| @@framework.set name, value }
|
12
|
+
|
13
|
+
# Evaluate block in context of WebBlocks::Structure::Framework singleton represented by this method
|
14
|
+
@@framework.instance_eval(&block) if block_given?
|
15
|
+
@@framework
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'json'
|
4
|
+
require 'ruby-bower'
|
5
|
+
|
6
|
+
module WebBlocks
|
7
|
+
module Manager
|
8
|
+
class Bower
|
9
|
+
|
10
|
+
attr_reader :base_path
|
11
|
+
attr_reader :bowerfile_path
|
12
|
+
attr_reader :cache_path
|
13
|
+
attr_reader :components_path
|
14
|
+
attr_reader :registry_cache_path
|
15
|
+
|
16
|
+
def initialize base_path
|
17
|
+
@base_path = base_path
|
18
|
+
@bowerfile_path = base_path + 'bower.json'
|
19
|
+
@cache_path = base_path + '.blocks/cache/bower'
|
20
|
+
@registry_cache_path = @cache_path + 'registry.json'
|
21
|
+
@components_path = base_path + 'bower_components'
|
22
|
+
@registry = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def installed?
|
26
|
+
File.exists? @components_path
|
27
|
+
end
|
28
|
+
|
29
|
+
def clean_registry_cache!
|
30
|
+
FileUtils.rm_f registry_cache_path
|
31
|
+
end
|
32
|
+
|
33
|
+
def clean_components_cache!
|
34
|
+
::Bower.context.call "bower.commands.cache.clean"
|
35
|
+
end
|
36
|
+
|
37
|
+
def prune_components!
|
38
|
+
::Bower.context.call "bower.commands.prune"
|
39
|
+
end
|
40
|
+
|
41
|
+
def update!
|
42
|
+
::Bower.context.call "bower.commands.update"
|
43
|
+
end
|
44
|
+
|
45
|
+
def clean_update!
|
46
|
+
clean_registry_cache!
|
47
|
+
clean_components_cache!
|
48
|
+
prune_components!
|
49
|
+
update!
|
50
|
+
end
|
51
|
+
|
52
|
+
def compute_registry
|
53
|
+
{
|
54
|
+
'name' => compute_registry_name,
|
55
|
+
'components' => compute_registry_components
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def compute_registry_name
|
60
|
+
definition = JSON.parse File.read bowerfile_path
|
61
|
+
definition['name']
|
62
|
+
end
|
63
|
+
|
64
|
+
def compute_registry_components
|
65
|
+
components = {}
|
66
|
+
dependencies = ::Bower.context.call("bower.commands.list", :sources => true)['dependencies'].values
|
67
|
+
while dependencies.length > 0
|
68
|
+
dependency = dependencies.pop
|
69
|
+
components[dependency['pkgMeta']['name']] = dependency['canonicalDir']
|
70
|
+
dependency['dependencies'].values.each do |dependency|
|
71
|
+
dependencies << dependency unless components.has_key? dependency['pkgMeta']['name']
|
72
|
+
end
|
73
|
+
end
|
74
|
+
components
|
75
|
+
end
|
76
|
+
|
77
|
+
def has_registry_cache?
|
78
|
+
File.exists? registry_cache_path
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_registry_cache
|
82
|
+
JSON.parse File.read registry_cache_path
|
83
|
+
end
|
84
|
+
|
85
|
+
def save_registry_cache registry
|
86
|
+
FileUtils.mkdir_p cache_path
|
87
|
+
File.open(registry_cache_path, 'w') {|f| f.write registry.to_json }
|
88
|
+
end
|
89
|
+
|
90
|
+
def get_registry
|
91
|
+
if has_registry_cache?
|
92
|
+
registry = get_registry_cache
|
93
|
+
else
|
94
|
+
registry = compute_registry
|
95
|
+
save_registry_cache registry
|
96
|
+
end
|
97
|
+
registry
|
98
|
+
end
|
99
|
+
|
100
|
+
def registry
|
101
|
+
@registry ||= OpenStruct.new get_registry
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module WebBlocks
|
2
|
+
module Manager
|
3
|
+
module Builder
|
4
|
+
class Base
|
5
|
+
|
6
|
+
attr_reader :log
|
7
|
+
attr_reader :task
|
8
|
+
|
9
|
+
def initialize task
|
10
|
+
|
11
|
+
@task = task
|
12
|
+
@log = task.log.scope 'BUILD'
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute!
|
17
|
+
|
18
|
+
yield if block_given?
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def save!
|
23
|
+
|
24
|
+
yield task.base_path + task.root.get(:build_dir) if block_given?
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'web_blocks/manager/builder/base'
|
3
|
+
require 'web_blocks/strategy/link/js'
|
4
|
+
|
5
|
+
module WebBlocks
|
6
|
+
module Manager
|
7
|
+
module Builder
|
8
|
+
class Js < Base
|
9
|
+
|
10
|
+
attr_reader :link_strategy
|
11
|
+
|
12
|
+
def initialize task
|
13
|
+
|
14
|
+
super task
|
15
|
+
|
16
|
+
@link_strategy = WebBlocks::Strategy::Link::Js.new(task)
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute!
|
21
|
+
|
22
|
+
super do
|
23
|
+
|
24
|
+
link_strategy.execute!
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def save!
|
31
|
+
|
32
|
+
super do |build_path|
|
33
|
+
|
34
|
+
log.info do
|
35
|
+
|
36
|
+
js_build_path = build_path + task.root.get(:js_build_dir)
|
37
|
+
FileUtils.mkdir_p js_build_path
|
38
|
+
|
39
|
+
source_path = link_strategy.product_path
|
40
|
+
product_path = js_build_path + source_path.basename
|
41
|
+
FileUtils.copy source_path, product_path
|
42
|
+
|
43
|
+
"Saved JS build #{product_path}"
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'web_blocks/manager/builder/base'
|
2
|
+
require 'web_blocks/strategy/link/scss'
|
3
|
+
require 'web_blocks/strategy/compile/scss'
|
4
|
+
|
5
|
+
module WebBlocks
|
6
|
+
module Manager
|
7
|
+
module Builder
|
8
|
+
class Scss < Base
|
9
|
+
|
10
|
+
attr_reader :link_strategy
|
11
|
+
attr_reader :compile_strategy
|
12
|
+
|
13
|
+
def initialize task
|
14
|
+
|
15
|
+
super task
|
16
|
+
|
17
|
+
@link_strategy = WebBlocks::Strategy::Link::Scss.new(task)
|
18
|
+
@compile_strategy = WebBlocks::Strategy::Compile::Scss.new(task)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def execute!
|
23
|
+
|
24
|
+
super do
|
25
|
+
|
26
|
+
link_strategy.execute!
|
27
|
+
compile_strategy.execute!
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def save!
|
34
|
+
|
35
|
+
super do |build_path|
|
36
|
+
|
37
|
+
log.info do
|
38
|
+
|
39
|
+
css_build_path = build_path + task.root.get(:css_build_dir)
|
40
|
+
FileUtils.mkdir_p css_build_path
|
41
|
+
|
42
|
+
source_path = compile_strategy.product_path
|
43
|
+
product_path = css_build_path + source_path.basename
|
44
|
+
FileUtils.copy source_path, product_path
|
45
|
+
|
46
|
+
"Saved CSS build #{product_path}"
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'web_blocks/support/parallel_jobs'
|
2
|
+
require 'web_blocks/manager/builder/js'
|
3
|
+
require 'web_blocks/manager/builder/scss'
|
4
|
+
|
5
|
+
module WebBlocks
|
6
|
+
module Manager
|
7
|
+
class ParallelBuilder
|
8
|
+
|
9
|
+
MAP = {
|
10
|
+
:scss => {
|
11
|
+
:scope_name => 'SCSS',
|
12
|
+
:strategy => WebBlocks::Manager::Builder::Scss
|
13
|
+
},
|
14
|
+
:js => { :scope_name => 'JS', :strategy => WebBlocks::Manager::Builder::Js }
|
15
|
+
}
|
16
|
+
|
17
|
+
attr_reader :task
|
18
|
+
attr_reader :log
|
19
|
+
|
20
|
+
def initialize task
|
21
|
+
|
22
|
+
@task = task
|
23
|
+
@log = task.log
|
24
|
+
@parallel_jobs = WebBlocks::Support::ParallelJobs.new
|
25
|
+
@started_strategies = []
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def start type
|
30
|
+
|
31
|
+
strategy = MAP[type][:strategy].new(task)
|
32
|
+
|
33
|
+
@parallel_jobs.start do
|
34
|
+
log.scope MAP[type][:scope_name] do |log|
|
35
|
+
strategy.execute!
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
@started_strategies << strategy
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def save_when_done!
|
44
|
+
|
45
|
+
@parallel_jobs.wait_for_complete!
|
46
|
+
@started_strategies.each { |strategy| strategy.save! }
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module WebBlocks
|
2
|
+
module Product
|
3
|
+
module ConcatFile
|
4
|
+
class Raw
|
5
|
+
|
6
|
+
attr_reader :path
|
7
|
+
|
8
|
+
def initialize path
|
9
|
+
@path = Pathname.new(path)
|
10
|
+
@files = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def push file
|
14
|
+
@files << file
|
15
|
+
end
|
16
|
+
|
17
|
+
def content_for file
|
18
|
+
IO.read file.resolved_path.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def save!
|
22
|
+
FileUtils.mkdir_p @path.parent
|
23
|
+
File.open(@path, 'w') do |f|
|
24
|
+
@files.each do |file|
|
25
|
+
f.puts "#{content_for file}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'web_blocks/product/concat_file/raw'
|
2
|
+
|
3
|
+
module WebBlocks
|
4
|
+
module Product
|
5
|
+
module ConcatFile
|
6
|
+
class Scss < Raw
|
7
|
+
|
8
|
+
def content_for file
|
9
|
+
file_path = file.resolved_path.to_s.gsub(/"/, '\\"')
|
10
|
+
if file_path.match /\.css$/
|
11
|
+
file_path = "CSS:#{file_path.gsub(/\.css$/, '')}" # this syntax is supported by 'sass-css-importer' plugin
|
12
|
+
elsif file_path.match /\.scss$/
|
13
|
+
file_path.gsub!(/\.scss$/, '') # allow it to resolve with or without underscore by dropping extension
|
14
|
+
end
|
15
|
+
"@import \"#{file_path}\";"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'compass'
|
2
|
+
require 'sass/plugin'
|
3
|
+
require 'sass-css-importer'
|
4
|
+
|
5
|
+
module WebBlocks
|
6
|
+
module Strategy
|
7
|
+
module Compile
|
8
|
+
class Scss
|
9
|
+
|
10
|
+
attr_reader :task
|
11
|
+
attr_reader :log
|
12
|
+
attr_reader :workspace_path
|
13
|
+
attr_reader :cache_path
|
14
|
+
attr_reader :product_path
|
15
|
+
attr_reader :source_path
|
16
|
+
|
17
|
+
def initialize task
|
18
|
+
|
19
|
+
@task = task
|
20
|
+
@log = task.log.scope 'SCSS - Compile'
|
21
|
+
@workspace_path = task.base_path + '.blocks/workspace'
|
22
|
+
@cache_path = task.base_path + '.blocks/cache/sass'
|
23
|
+
@source_path = @workspace_path + 'scss/blocks.scss'
|
24
|
+
@product_path = @workspace_path + 'css/blocks.css'
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def execute!
|
29
|
+
|
30
|
+
log.info { "Starting" }
|
31
|
+
|
32
|
+
output = StringIO.new
|
33
|
+
|
34
|
+
with_compass_io output do
|
35
|
+
configure_compass!
|
36
|
+
compass_compile!
|
37
|
+
end
|
38
|
+
|
39
|
+
output.rewind
|
40
|
+
output.each_line { |line| log.debug("Compass"){ line.to_s.gsub(/\n/,'') } }
|
41
|
+
|
42
|
+
log.info { "Finished" }
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def configure_compass!
|
47
|
+
|
48
|
+
Compass.add_configuration({
|
49
|
+
:project_path => workspace_path,
|
50
|
+
:sass_path => 'scss',
|
51
|
+
:css_path => 'css',
|
52
|
+
:cache_path => cache_path
|
53
|
+
},
|
54
|
+
'blocks'
|
55
|
+
)
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
def compass_compile!
|
60
|
+
|
61
|
+
FileUtils.mkdir_p product_path.parent
|
62
|
+
Compass.compiler.compile source_path.to_s, product_path.to_s
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def with_compass_io io
|
67
|
+
|
68
|
+
alias_mapping = {
|
69
|
+
:color => Proc.new { |c| "" },
|
70
|
+
:log => Proc.new { |msg| io.puts msg }
|
71
|
+
}
|
72
|
+
|
73
|
+
alias_mapping.each do |method, proc|
|
74
|
+
Compass::Logger.send :alias_method, "___#{method}", method
|
75
|
+
Compass::Logger.send :define_method, method, &proc
|
76
|
+
end
|
77
|
+
|
78
|
+
yield
|
79
|
+
|
80
|
+
alias_mapping.keys.each do |method|
|
81
|
+
Compass::Logger.send :alias_method, method, "___#{method}"
|
82
|
+
Compass::Logger.send :remove_method, "___#{method}"
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module WebBlocks
|
2
|
+
module Strategy
|
3
|
+
module Link
|
4
|
+
class Base
|
5
|
+
|
6
|
+
attr_reader :task
|
7
|
+
attr_reader :log
|
8
|
+
attr_reader :linker_file
|
9
|
+
attr_accessor :files_to_link
|
10
|
+
|
11
|
+
def initialize task
|
12
|
+
|
13
|
+
@task = task
|
14
|
+
@log = task.log.scope 'Link'
|
15
|
+
@linker_file = make_linker_file
|
16
|
+
@files_to_link = compute_files_to_link
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute!
|
21
|
+
|
22
|
+
log.info { "Starting" }
|
23
|
+
|
24
|
+
files_to_link.each do |file|
|
25
|
+
log.debug do
|
26
|
+
linker_file.push file
|
27
|
+
"Linked #{file.resolved_path}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
log.debug do
|
32
|
+
linker_file.save!
|
33
|
+
"Saved #{linker_file.path}"
|
34
|
+
end
|
35
|
+
|
36
|
+
log.info { "Finished" }
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def make_linker_file
|
41
|
+
raise NoMethodError, "undefined method `make_linker_file!' for #{self}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def compute_files_to_link
|
45
|
+
[]
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'web_blocks/strategy/link/base'
|
2
|
+
require 'web_blocks/structure/js_file'
|
3
|
+
require 'web_blocks/product/concat_file/js'
|
4
|
+
|
5
|
+
module WebBlocks
|
6
|
+
module Strategy
|
7
|
+
module Link
|
8
|
+
class Js < Base
|
9
|
+
|
10
|
+
def initialize task
|
11
|
+
super task
|
12
|
+
@log = task.log.scope 'JS - Link'
|
13
|
+
end
|
14
|
+
|
15
|
+
def product_path
|
16
|
+
task.base_path + '.blocks/workspace/js/blocks.js'
|
17
|
+
end
|
18
|
+
|
19
|
+
def make_linker_file
|
20
|
+
::WebBlocks::Product::ConcatFile::Js.new product_path
|
21
|
+
end
|
22
|
+
|
23
|
+
def compute_files_to_link
|
24
|
+
task.root.get_file_load_order(::WebBlocks::Structure::JsFile)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'web_blocks/strategy/link/base'
|
2
|
+
require 'web_blocks/structure/scss_file'
|
3
|
+
require 'web_blocks/product/concat_file/scss'
|
4
|
+
|
5
|
+
module WebBlocks
|
6
|
+
module Strategy
|
7
|
+
module Link
|
8
|
+
class Scss < Base
|
9
|
+
|
10
|
+
def initialize task
|
11
|
+
super task
|
12
|
+
@log = task.log.scope 'SCSS - Link'
|
13
|
+
end
|
14
|
+
|
15
|
+
def product_path
|
16
|
+
task.base_path + '.blocks/workspace/scss/blocks.scss'
|
17
|
+
end
|
18
|
+
|
19
|
+
def make_linker_file
|
20
|
+
::WebBlocks::Product::ConcatFile::Scss.new product_path
|
21
|
+
end
|
22
|
+
|
23
|
+
def compute_files_to_link
|
24
|
+
task.root.get_file_load_order(::WebBlocks::Structure::ScssFile)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|