uki 1.1.2 → 1.1.3
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/VERSION +1 -1
- data/bin/uki +1 -1
- data/lib/uki/include_js.rb +37 -7
- metadata +8 -9
- data/.gitignore +0 -7
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.3
|
data/bin/uki
CHANGED
@@ -118,7 +118,7 @@ command :build do |c|
|
|
118
118
|
c.syntax = 'uki build [file1 [, file2]]'
|
119
119
|
c.summary = 'Build current project'
|
120
120
|
c.description = 'Merges and compresses javascript files.
|
121
|
-
Merges all include() and
|
121
|
+
Merges all include() and include_text() in js files. Merged output
|
122
122
|
is processed through google clousure compiler. Supports .js and .html
|
123
123
|
files as parameters.
|
124
124
|
|
data/lib/uki/include_js.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'base64'
|
2
3
|
|
3
4
|
module Uki
|
4
5
|
|
5
|
-
INCLUDE_REGEXP = %r{(
|
6
|
-
|
6
|
+
INCLUDE_REGEXP = %r{(^|^[^\n]*[^\w\n])include\s*\(\s*['"]([^"']+)["']\s*\)(?:\s*;)?(.*?\r?\n|$)}
|
7
|
+
INCLUDE_TEXT_REGEXP = %r{include_(?:text|css)\s*\(\s*['"]([^"']+)["']\s*\)}
|
8
|
+
|
9
|
+
BACKGROUND_URL_REGEXP = %r{url\s*\(\s*['"]?([^"'\)]+)["']?\s*\)}
|
10
|
+
DATA_URI_REGEXP = %r{/\*!\s*data:([^\s\*]*)\s*\*/['"]?([^"']+)['"]}
|
7
11
|
|
8
12
|
#
|
9
13
|
# Preprocesses include() calls in js files
|
@@ -18,7 +22,14 @@ module Uki
|
|
18
22
|
end
|
19
23
|
|
20
24
|
included[path] = true
|
21
|
-
code.gsub(
|
25
|
+
code.gsub(INCLUDE_TEXT_REGEXP) do |match|
|
26
|
+
include_text File.join(base, $1), &block
|
27
|
+
|
28
|
+
end.gsub(DATA_URI_REGEXP) do |match|
|
29
|
+
uri = to_data_uri File.join(base, $2), $1
|
30
|
+
"'#{uri}'"
|
31
|
+
|
32
|
+
end.gsub(INCLUDE_REGEXP) do |match|
|
22
33
|
if $1.include? '//' # include commented out
|
23
34
|
match
|
24
35
|
else
|
@@ -29,16 +40,35 @@ module Uki
|
|
29
40
|
$1 + $3
|
30
41
|
end
|
31
42
|
end
|
32
|
-
end.gsub(INCLUDE_CSS_REGEXP) do |match|
|
33
|
-
include_css File.join(base, $1), &block
|
34
43
|
end
|
35
44
|
end
|
36
45
|
|
37
|
-
def self.
|
46
|
+
def self.to_data_uri path, type = nil
|
47
|
+
if !type || type.empty?
|
48
|
+
ext = File.extname(path)
|
49
|
+
if ext == '.png'
|
50
|
+
type = 'image/png'
|
51
|
+
elsif ext == '.gif'
|
52
|
+
type = 'image/gif'
|
53
|
+
else
|
54
|
+
type = 'text/plain'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
"data:#{type};base64," + Base64.encode64(File.read(path)).gsub("\n", '')
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.include_text path, &block
|
38
61
|
code = if block_given?
|
39
62
|
yield path
|
40
63
|
else
|
41
|
-
File.read(path)
|
64
|
+
File.read(path).gsub(BACKGROUND_URL_REGEXP) do |match|
|
65
|
+
url = $1;
|
66
|
+
unless url =~ %r{^(/|\w+://)}
|
67
|
+
filename = File.join(File.dirname(path), url);
|
68
|
+
url = self.to_data_uri(filename)
|
69
|
+
end
|
70
|
+
"url(#{url})";
|
71
|
+
end
|
42
72
|
end
|
43
73
|
(code || '').to_json
|
44
74
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 21
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 3
|
10
|
+
version: 1.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vladimir Kolesnikov
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-05 00:00:00 -08:00
|
19
19
|
default_executable: uki
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -73,7 +73,6 @@ extensions: []
|
|
73
73
|
extra_rdoc_files:
|
74
74
|
- LICENSE
|
75
75
|
files:
|
76
|
-
- .gitignore
|
77
76
|
- .gitmodules
|
78
77
|
- LICENSE
|
79
78
|
- Rakefile
|
@@ -437,8 +436,8 @@ homepage: http://github.com/voloko/uki
|
|
437
436
|
licenses: []
|
438
437
|
|
439
438
|
post_install_message:
|
440
|
-
rdoc_options:
|
441
|
-
|
439
|
+
rdoc_options: []
|
440
|
+
|
442
441
|
require_paths:
|
443
442
|
- lib
|
444
443
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -462,7 +461,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
462
461
|
requirements: []
|
463
462
|
|
464
463
|
rubyforge_project:
|
465
|
-
rubygems_version: 1.
|
464
|
+
rubygems_version: 1.4.1
|
466
465
|
signing_key:
|
467
466
|
specification_version: 3
|
468
467
|
summary: uki development tools
|