tay 0.0.4 → 0.0.5
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/lib/tay/builder.rb +32 -10
- data/lib/tay/cli/new.rb +1 -0
- data/lib/tay/manifest_generator.rb +2 -2
- data/lib/tay/specification.rb +30 -0
- data/lib/tay/version.rb +1 -1
- metadata +4 -4
data/lib/tay/builder.rb
CHANGED
@@ -30,8 +30,7 @@ module Tay
|
|
30
30
|
# in this class.
|
31
31
|
def build!
|
32
32
|
create_output_directory
|
33
|
-
simple_compile_directory(
|
34
|
-
simple_compile_directory('assets')
|
33
|
+
spec.source_directories.each { |d| simple_compile_directory(d) }
|
35
34
|
compile_files(spec.all_javascript_paths)
|
36
35
|
compile_files(spec.all_stylesheet_paths)
|
37
36
|
write_manifest
|
@@ -56,7 +55,9 @@ module Tay
|
|
56
55
|
# If we know the type buy are missing the gem, raise an exception.
|
57
56
|
def get_compiled_file_content(path)
|
58
57
|
begin
|
59
|
-
Tilt.new(path.to_s).render
|
58
|
+
Tilt.new(path.to_s).render({}, {
|
59
|
+
:spec => spec
|
60
|
+
})
|
60
61
|
rescue RuntimeError
|
61
62
|
File.read(path)
|
62
63
|
end
|
@@ -72,11 +73,31 @@ module Tay
|
|
72
73
|
# Copy all the files from a directory to the output, compiling
|
73
74
|
# them if they are familiar to us. Does not do any sprocketing.
|
74
75
|
def simple_compile_directory(directory)
|
75
|
-
|
76
|
+
if directory.is_a?(String)
|
77
|
+
# If we just have a single dirname, assume it's under src
|
78
|
+
from_directory = (directory[/\//] ? '' : 'src/') + directory
|
79
|
+
|
80
|
+
directory = {
|
81
|
+
:from => from_directory,
|
82
|
+
:as => directory
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
directory[:use_tilt] |= true
|
87
|
+
|
88
|
+
Dir[@base_dir.join(directory[:from], '**/*')].each do |path|
|
76
89
|
file_in_path = Pathname.new(path)
|
77
|
-
file_out_path = asset_output_filename(src_path_to_out_path(path), Tilt.mappings.keys)
|
78
90
|
|
79
|
-
|
91
|
+
next unless file_in_path.file?
|
92
|
+
|
93
|
+
file_out_path = remap_path_to_build_directory(path, directory)
|
94
|
+
|
95
|
+
if directory[:use_tilt]
|
96
|
+
content = get_compiled_file_content(file_in_path)
|
97
|
+
file_out_path = asset_output_filename(file_out_path, Tilt.mappings.keys)
|
98
|
+
else
|
99
|
+
content = File.read(file_in_path)
|
100
|
+
end
|
80
101
|
|
81
102
|
FileUtils.mkdir_p(file_out_path.dirname)
|
82
103
|
File.open(file_out_path, 'w') do |f|
|
@@ -139,10 +160,11 @@ module Tay
|
|
139
160
|
end
|
140
161
|
|
141
162
|
##
|
142
|
-
# Helper function that converts a
|
143
|
-
#
|
144
|
-
def
|
145
|
-
@
|
163
|
+
# Helper function that converts a source path to an equivalent path in the
|
164
|
+
# output directory
|
165
|
+
def remap_path_to_build_directory(path, directory_info)
|
166
|
+
base_directory = @base_dir.join(directory_info[:from]).to_s
|
167
|
+
@output_dir.join(path.to_s.sub(/\A#{base_directory}\/?/, directory_info[:as] + '/'))
|
146
168
|
end
|
147
169
|
|
148
170
|
##
|
data/lib/tay/cli/new.rb
CHANGED
@@ -27,6 +27,7 @@ module Tay
|
|
27
27
|
empty_directory(outdir)
|
28
28
|
empty_directory(outdir.join('src'))
|
29
29
|
empty_directory(outdir.join('src/assets'))
|
30
|
+
empty_directory(outdir.join('src/img'))
|
30
31
|
empty_directory(outdir.join('src/html'))
|
31
32
|
empty_directory(outdir.join('src/javascripts'))
|
32
33
|
empty_directory(outdir.join('src/stylesheets'))
|
data/lib/tay/specification.rb
CHANGED
@@ -137,6 +137,35 @@ module Tay
|
|
137
137
|
# A Tay::Specification::PackagedApp or nil
|
138
138
|
attr_reader :packaged_app
|
139
139
|
|
140
|
+
##
|
141
|
+
# An array of directories that will be copied to the build directory.
|
142
|
+
# Defaults to "img", "assets", and "html", all files are run through
|
143
|
+
# Tilt before being copied
|
144
|
+
#
|
145
|
+
# If just a directory name is passed, it is assumed to be a sub-dir
|
146
|
+
# of src, and will be copied as the directory name, eg:
|
147
|
+
#
|
148
|
+
# spec.source_directories << "extras"
|
149
|
+
# # copies src/extras to build/extras
|
150
|
+
#
|
151
|
+
# If you provide a path, it is relative to the root directory, and will be
|
152
|
+
# copied to the build directory under this full relative path, eg:
|
153
|
+
#
|
154
|
+
# spec.source_directories << "non_code/fonts"
|
155
|
+
# # copies non_code/fonts to build/non_code/fonts
|
156
|
+
#
|
157
|
+
# If you need finer control over where files end up, you can also push an
|
158
|
+
# object on to this list detailing the source directory, and the directory
|
159
|
+
# it will be placed in under the build dir. You can optionally specify
|
160
|
+
# whether to run through Tilt or not (default: yes). eg:
|
161
|
+
#
|
162
|
+
# spec.source_directories << {
|
163
|
+
# :from => "vendor/bootstrap/img",
|
164
|
+
# :as => "img",
|
165
|
+
# :use_tilt => false
|
166
|
+
# } # copies vendor/bootstrap/img/* to build/img
|
167
|
+
attr_accessor :source_directories
|
168
|
+
|
140
169
|
##
|
141
170
|
# The path to the private key used to package this extension. Will default
|
142
171
|
# to ./EXTNAME.pem
|
@@ -153,6 +182,7 @@ module Tay
|
|
153
182
|
@icons = {}
|
154
183
|
@stylesheets = []
|
155
184
|
@javascripts = []
|
185
|
+
@source_directories = %w{img assets html}
|
156
186
|
|
157
187
|
yield self
|
158
188
|
end
|
data/lib/tay/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05
|
12
|
+
date: 2012-06-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -249,7 +249,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
249
249
|
version: '0'
|
250
250
|
segments:
|
251
251
|
- 0
|
252
|
-
hash:
|
252
|
+
hash: 3841744028028024914
|
253
253
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
254
|
none: false
|
255
255
|
requirements:
|
@@ -258,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
258
|
version: '0'
|
259
259
|
segments:
|
260
260
|
- 0
|
261
|
-
hash:
|
261
|
+
hash: 3841744028028024914
|
262
262
|
requirements: []
|
263
263
|
rubyforge_project:
|
264
264
|
rubygems_version: 1.8.24
|