gluey 0.2.3 → 0.2.7
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 +4 -4
- data/.gitignore +1 -0
- data/lib/gluey/dependencies/directory.rb +4 -0
- data/lib/gluey/dependencies/handlebars_bundle.rb +4 -0
- data/lib/gluey/dependencies/single_file.rb +4 -0
- data/lib/gluey/dependencies/texts_bundle.rb +4 -0
- data/lib/gluey/glues/base.rb +3 -1
- data/lib/gluey/glues/sass.rb +3 -2
- data/lib/gluey/glues/script.rb +3 -3
- data/lib/gluey/material.rb +19 -16
- data/lib/gluey/url.rb +9 -0
- data/lib/gluey/version.rb +1 -1
- data/lib/gluey/warehouse.rb +4 -2
- data/lib/gluey/workshop.rb +27 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06efa92dcd6fd292dd71faf95ac07ce0dd921fdd
|
4
|
+
data.tar.gz: ea74e55f880c37e08b24a0002c8c243a5839016a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39c68be866dbfc940bb6841075474b39735174cf76048992827ce8b870d045881bf83b46304f0cc0a62bf4b4f7623d23301235b47fdc9d78ebb20af08b54b9a7
|
7
|
+
data.tar.gz: 11c54bcc7c1c2875d54f2246c849216ef9a9c9889a6942881bf5d4188d9777a350e76372b52165c899b50cc57616ab427816615183941badfe9306d111e362d1
|
data/.gitignore
CHANGED
@@ -19,6 +19,10 @@ module Gluey::Dependencies
|
|
19
19
|
@dependencies.any?{|d| d.changed?} || @dir_dep.changed? || (File.mtime(@file).to_i != @mtime rescue true)
|
20
20
|
end
|
21
21
|
|
22
|
+
def mark
|
23
|
+
@dependencies.map(&:mark).join
|
24
|
+
end
|
25
|
+
|
22
26
|
def actualize
|
23
27
|
# remove deleted files
|
24
28
|
@dependencies.delete_if{|dep| !dep.exists? }
|
@@ -26,6 +26,10 @@ module Gluey::Dependencies
|
|
26
26
|
@dependencies.any?{|d| d.changed?} || @dir_dep.changed? || (File.mtime(@file).to_i != @mtime rescue true)
|
27
27
|
end
|
28
28
|
|
29
|
+
def mark
|
30
|
+
@dependencies.map(&:mark).join
|
31
|
+
end
|
32
|
+
|
29
33
|
def actualize
|
30
34
|
# remove deleted files
|
31
35
|
@dependencies.delete_if{|dep| !dep.exists? }
|
data/lib/gluey/glues/base.rb
CHANGED
@@ -16,7 +16,7 @@ module Gluey::Glues
|
|
16
16
|
|
17
17
|
def read_base_file(file)
|
18
18
|
raw_content = File.read(file)
|
19
|
-
file[-4..-1]=='.erb' ? ERB.new(raw_content).result : raw_content
|
19
|
+
file[-4..-1]=='.erb' ? ERB.new(raw_content).result(@context.get_binding) : raw_content
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -24,6 +24,8 @@ module Gluey::Glues
|
|
24
24
|
def self.load(name, *addons_names)
|
25
25
|
require_relative name
|
26
26
|
addons_names.flatten.each{|an| require_relative "#{name}/#{an}_addons" }
|
27
|
+
rescue LoadError => e
|
28
|
+
raise e.message
|
27
29
|
end
|
28
30
|
|
29
31
|
end
|
data/lib/gluey/glues/sass.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'sass'
|
2
|
+
require_relative 'script'
|
2
3
|
require_relative '../dependencies/single_file'
|
3
4
|
|
4
5
|
module Gluey::Glues
|
5
|
-
class Sass <
|
6
|
+
class Sass < Script
|
6
7
|
|
7
8
|
def process(base_file, deps)
|
8
9
|
opts = {
|
@@ -12,7 +13,7 @@ module Gluey::Glues
|
|
12
13
|
filename: base_file,
|
13
14
|
line_comments: true
|
14
15
|
}
|
15
|
-
engine = ::Sass::Engine.new(
|
16
|
+
engine = ::Sass::Engine.new super(base_file, deps), opts
|
16
17
|
output = engine.render
|
17
18
|
|
18
19
|
engine.dependencies.each do |dependency|
|
data/lib/gluey/glues/script.rb
CHANGED
@@ -3,8 +3,8 @@ require_relative '../dependencies/single_file'
|
|
3
3
|
module Gluey::Glues
|
4
4
|
class Script < Base
|
5
5
|
|
6
|
-
PREFIXES = ['//'].map{|p| Regexp.escape(p)}
|
7
|
-
DIRECTIVES_REGEXP = Regexp.compile "\\A(?:\\s*#{PREFIXES.map{|p| "(?:#{p}
|
6
|
+
PREFIXES = ['//', '#'].map{|p| Regexp.escape(p)}
|
7
|
+
DIRECTIVES_REGEXP = Regexp.compile "\\A(?:\\s*#{PREFIXES.map{|p| "(?:#{p}>.*\\n?)+"}.join '|'})+"
|
8
8
|
|
9
9
|
def process(base_file, deps)
|
10
10
|
@script, @directives = strip_directives read_base_file(base_file)
|
@@ -46,7 +46,7 @@ module Gluey::Glues
|
|
46
46
|
if directives
|
47
47
|
script = $'
|
48
48
|
directives = directives.split("\n").reject{|dir| dir.empty?}.map do |dir|
|
49
|
-
dir.strip[/(?:#{PREFIXES.join '|'}
|
49
|
+
dir.strip[/(?:#{PREFIXES.join '|'})>\s*(.+)/, 1].split (' ')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
return script, directives
|
data/lib/gluey/material.rb
CHANGED
@@ -2,7 +2,7 @@ require_relative 'exceptions/file_not_found'
|
|
2
2
|
|
3
3
|
class Gluey::Material
|
4
4
|
|
5
|
-
attr_reader :name, :glue
|
5
|
+
attr_reader :name, :glue, :paths, :items
|
6
6
|
attr_accessor :asset, :file_extension, :public_dir
|
7
7
|
|
8
8
|
def initialize(name, glue, context)
|
@@ -24,17 +24,20 @@ class Gluey::Material
|
|
24
24
|
@items << declaration
|
25
25
|
end
|
26
26
|
|
27
|
-
def is_listed?(path, file
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
def is_listed?(path, file)
|
28
|
+
file[/\.(\w+)(?:\.erb)?$/, 1]==@file_extension &&
|
29
|
+
@items.any? do |items_declaration|
|
30
|
+
case items_declaration
|
31
|
+
when :all, :any
|
32
|
+
true
|
33
|
+
when String
|
34
|
+
path == items_declaration
|
35
|
+
when Regexp
|
36
|
+
path =~ items_declaration
|
37
|
+
when Proc
|
38
|
+
items_declaration[path, file]
|
39
|
+
end
|
40
|
+
end
|
38
41
|
end
|
39
42
|
|
40
43
|
def to_s
|
@@ -42,18 +45,18 @@ class Gluey::Material
|
|
42
45
|
end
|
43
46
|
|
44
47
|
def find_base_file(path)
|
45
|
-
|
48
|
+
full_paths.each do |base_path|
|
46
49
|
p = "#{base_path}/#{path}.#{@file_extension}"; return p if File.exists? p
|
47
50
|
p = "#{p}.erb"; return p if File.exists? p
|
48
51
|
p = "#{base_path}/#{path}/index.#{@file_extension}"; return p if File.exists? p
|
49
52
|
p = "#{p}.erb"; return p if File.exists? p
|
50
|
-
|
53
|
+
end
|
51
54
|
raise(::Gluey::FileNotFound.new "#{to_s} cannot find base file for #{path}")
|
52
55
|
end
|
53
56
|
|
54
57
|
def list_all_items
|
55
58
|
list = []
|
56
|
-
|
59
|
+
full_paths.map do |base_path|
|
57
60
|
glob_path = "#{base_path}/**/*.#{@file_extension}"
|
58
61
|
files = Dir[glob_path] + Dir["#{glob_path}.erb"]
|
59
62
|
files.select do |file|
|
@@ -67,7 +70,7 @@ class Gluey::Material
|
|
67
70
|
|
68
71
|
private
|
69
72
|
|
70
|
-
def
|
73
|
+
def full_paths
|
71
74
|
@paths.map{|p| "#{@context.root_path}/#{p}"}
|
72
75
|
end
|
73
76
|
|
data/lib/gluey/url.rb
ADDED
data/lib/gluey/version.rb
CHANGED
data/lib/gluey/warehouse.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require_relative '../gluey'
|
2
|
+
require_relative 'url'
|
2
3
|
require_relative 'exceptions/item_not_listed'
|
3
4
|
require 'json'
|
4
5
|
|
5
6
|
class Gluey::Warehouse
|
7
|
+
include Gluey::Url
|
6
8
|
|
7
9
|
attr_reader :assets
|
8
10
|
|
@@ -11,7 +13,7 @@ class Gluey::Warehouse
|
|
11
13
|
read_listing
|
12
14
|
end
|
13
15
|
|
14
|
-
def real_path(asset_type, path)
|
16
|
+
def real_path(asset_type, path, mark=nil)
|
15
17
|
listing = @assets[asset_type]
|
16
18
|
unless listing
|
17
19
|
raise ::Gluey::ItemNotListed.new("Asset type #{asset_type} is not defined! (listing file problem?)")
|
@@ -38,7 +40,7 @@ class Gluey::Warehouse
|
|
38
40
|
def write_listing(workshop)
|
39
41
|
@assets = workshop.materials.values.inject({}) do |listing, material|
|
40
42
|
list = material.list_all_items.inject({}) do |h, path|
|
41
|
-
h[path] = workshop.real_path material.name, path
|
43
|
+
h[path] = workshop.real_path material.name, path, true
|
42
44
|
h
|
43
45
|
end
|
44
46
|
listing[material.name.to_sym] = list
|
data/lib/gluey/workshop.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
require 'digest'
|
1
2
|
require_relative '../gluey'
|
3
|
+
require_relative 'url'
|
2
4
|
|
3
5
|
require_relative 'exceptions/item_not_listed'
|
4
6
|
|
@@ -6,8 +8,10 @@ require_relative 'material'
|
|
6
8
|
require_relative 'glues/base'
|
7
9
|
|
8
10
|
class Gluey::Workshop
|
11
|
+
include Gluey::Url
|
9
12
|
|
10
13
|
attr_reader :root_path, :tmp_path, :materials, :cache
|
14
|
+
attr_accessor :base_url
|
11
15
|
|
12
16
|
def initialize(root, tmp_dir='tmp/gluey')
|
13
17
|
@root_path = root
|
@@ -20,12 +24,13 @@ class Gluey::Workshop
|
|
20
24
|
def register_material(name, glue=::Gluey::Glues::Base, &block)
|
21
25
|
name = name.to_sym
|
22
26
|
material = ::Gluey::Material.new name, glue, self, &block
|
27
|
+
material.items << :any if material.items.empty?
|
23
28
|
@materials[name] = material
|
24
29
|
end
|
25
30
|
|
26
31
|
def fetch_file(material, path)
|
27
32
|
# check cache
|
28
|
-
cache_key =
|
33
|
+
cache_key = chache_asset_key material, path
|
29
34
|
file, dependencies = @cache[cache_key]
|
30
35
|
if file && File.exists?(file) && !dependencies.any?{|d| d.changed?}
|
31
36
|
return file
|
@@ -46,19 +51,37 @@ class Gluey::Workshop
|
|
46
51
|
file
|
47
52
|
end
|
48
53
|
|
49
|
-
def real_path(material, path)
|
54
|
+
def real_path(material, path, digest_mark=false)
|
50
55
|
material = @materials[material.to_sym]
|
51
56
|
file = material.find_base_file path
|
52
57
|
unless material.is_listed? path, file
|
53
58
|
raise ::Gluey::ItemNotListed.new("#{material.to_s} doesn't have enlisted item #{path} (file=#{file}).")
|
54
59
|
end
|
55
|
-
|
60
|
+
if digest_mark
|
61
|
+
fetch_file material.name, path
|
62
|
+
cache_key = chache_asset_key material.name, path
|
63
|
+
file, dependencies = @cache[cache_key]
|
64
|
+
digested_mark = Digest::MD5.new.digest dependencies.map(&:mark).join
|
65
|
+
"#{path}.#{Digest.hexencode digested_mark}.#{material.asset}"
|
66
|
+
else
|
67
|
+
"#{path}.#{material.asset}"
|
68
|
+
end
|
56
69
|
end
|
57
70
|
|
58
71
|
def try_real_path(path)
|
59
|
-
path.match /^(.+)
|
72
|
+
path.match /^(.+)\.(?:[a-f0-9]{32}\.)(\w+)$/ do |m|
|
60
73
|
yield m[1], m[2]
|
61
74
|
end
|
62
75
|
end
|
63
76
|
|
77
|
+
def get_binding
|
78
|
+
binding
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def chache_asset_key(material, path)
|
84
|
+
"lump:#{material}:#{path}"
|
85
|
+
end
|
86
|
+
|
64
87
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gluey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- doooby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/gluey/material.rb
|
68
68
|
- lib/gluey/tools/local_build.rb
|
69
69
|
- lib/gluey/tools/tools.rb
|
70
|
+
- lib/gluey/url.rb
|
70
71
|
- lib/gluey/version.rb
|
71
72
|
- lib/gluey/warehouse.rb
|
72
73
|
- lib/gluey/workshop.rb
|