xqcoretools 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -20
- data/README.rdoc +13 -13
- data/bin/xqcoretools +185 -0
- metadata +24 -39
data/LICENSE.txt
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2013 Mark Wong
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2013 Mark Wong
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
= xqcoretools
|
2
|
-
|
3
|
-
Tools for using the XQ.Core framework.
|
4
|
-
|
5
|
-
Tools for synchronizing multiple CSharp projects and deploying to several platform
|
6
|
-
|
7
|
-
== Usage
|
8
|
-
|
9
|
-
* xqcoretools
|
10
|
-
|
11
|
-
== Copyright
|
12
|
-
|
13
|
-
Copyright (c) 2013 Mark Wong. See LICENSE.txt for further details.
|
1
|
+
= xqcoretools
|
2
|
+
|
3
|
+
Tools for using the XQ.Core framework.
|
4
|
+
|
5
|
+
Tools for synchronizing multiple CSharp projects and deploying to several platform
|
6
|
+
|
7
|
+
== Usage
|
8
|
+
|
9
|
+
* xqcoretools
|
10
|
+
|
11
|
+
== Copyright
|
12
|
+
|
13
|
+
Copyright (c) 2013 Mark Wong. See LICENSE.txt for further details.
|
data/bin/xqcoretools
CHANGED
@@ -4,8 +4,31 @@ require 'rubygems'
|
|
4
4
|
require 'thor'
|
5
5
|
require 'cross_platform_csproj'
|
6
6
|
require 'zip/zip'
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'net/http'
|
9
|
+
require 'execjs'
|
7
10
|
|
8
11
|
class XQCoreTools < Thor
|
12
|
+
desc "processcontent [PLATFORM] [OUTPUT] [PATHS]", "Process content packages"
|
13
|
+
def processcontent(platform, output, paths)
|
14
|
+
|
15
|
+
basePath = XQCoreTools::createTemporaryFolder('xqcoretoolscontent')
|
16
|
+
|
17
|
+
pathList = paths.split(';')
|
18
|
+
pathList.each do |path|
|
19
|
+
FileUtils.cp_r(path, basePath)
|
20
|
+
end
|
21
|
+
|
22
|
+
compile(platform, basePath)
|
23
|
+
|
24
|
+
case platform
|
25
|
+
when 'Android'
|
26
|
+
# archive(output, basePath)
|
27
|
+
when 'iOS', 'IOS'
|
28
|
+
# bundle(output, basePath)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
9
32
|
desc "archive [OUTPUT] [PATHS]", "Generates a compressed archive"
|
10
33
|
def archive(output, paths)
|
11
34
|
FileUtils.rm(output, :force=>true)
|
@@ -70,6 +93,168 @@ class XQCoreTools < Thor
|
|
70
93
|
puts "COPYING: #{package}"
|
71
94
|
end
|
72
95
|
end
|
96
|
+
|
97
|
+
desc "compile [PLATFORM] [PATH]", "Compiles a content package"
|
98
|
+
def compile(platform, path)
|
99
|
+
downloadCache = XQCoreToolsDownloadCache.new('library.xqcore.com', 'xqcoretoolslibrary')
|
100
|
+
|
101
|
+
XQCoreTools::compileDocumentRecursive(platform, path, downloadCache)
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.compileDocumentRecursive(platform, path, downloadCache)
|
105
|
+
Dir.foreach(path) do |item|
|
106
|
+
subPath = "#{path}/#{item}"
|
107
|
+
if File.file? subPath
|
108
|
+
if File.extname(item) == '.html'
|
109
|
+
fileHandle = File.open(subPath)
|
110
|
+
document = Nokogiri::HTML(fileHandle)
|
111
|
+
fileHandle.close
|
112
|
+
|
113
|
+
nodes = document.css('script')
|
114
|
+
|
115
|
+
isDirty = false
|
116
|
+
|
117
|
+
for node in nodes do
|
118
|
+
if node.has_attribute?('src')
|
119
|
+
srcComponents = node.get_attribute('src').scan(/library\.xqcore.com\/(.*)\/xqcore\-web\-debug\.js/)
|
120
|
+
if srcComponents.length > 0
|
121
|
+
scriptVersion = srcComponents[0][0]
|
122
|
+
|
123
|
+
includeFolder = 'inc'
|
124
|
+
|
125
|
+
runtimeFile = "xqcore-web-#{platform.downcase}.js"
|
126
|
+
runtimeFolder = "#{includeFolder}/#{runtimeFile}"
|
127
|
+
runtimePath = "#{path}/#{runtimeFolder}"
|
128
|
+
|
129
|
+
downloadCache.saveFile("#{scriptVersion}/#{runtimeFile}", runtimePath)
|
130
|
+
|
131
|
+
node.set_attribute('src', runtimeFolder)
|
132
|
+
|
133
|
+
XQCoreTools::compileTemplates(subPath, document, scriptVersion, downloadCache, node)
|
134
|
+
|
135
|
+
isDirty = true
|
136
|
+
break;
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
if isDirty
|
142
|
+
fileHandle = File.open(subPath, 'w')
|
143
|
+
fileHandle.puts(document.to_html(:indent => 4))
|
144
|
+
fileHandle.close
|
145
|
+
end
|
146
|
+
end
|
147
|
+
else
|
148
|
+
if item != '.' && item != '..'
|
149
|
+
XQCoreTools::compileDocumentRecursive(platform, subPath, downloadCache)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.compileTemplates(fileName, document, version, downloadCache, insertSibling)
|
156
|
+
script = ''
|
157
|
+
|
158
|
+
compilerFile = "compiler.js"
|
159
|
+
compilerPath = downloadCache.cacheFile("#{version}/#{compilerFile}")
|
160
|
+
|
161
|
+
compilerFileHandle = File.open(compilerPath)
|
162
|
+
compilerSource = compilerFileHandle.read
|
163
|
+
compilerFileHandle.close
|
164
|
+
|
165
|
+
context = ExecJS.compile(compilerSource)
|
166
|
+
|
167
|
+
nodes = document.css('script')
|
168
|
+
for node in nodes do
|
169
|
+
if node.has_attribute?('type') && node.get_attribute('type') == 'text/x-handlebars-template'
|
170
|
+
if node.has_attribute?('src')
|
171
|
+
puts "ERROR: currently xqcoretools does not support pre-compilation of templates with external source link"
|
172
|
+
continue;
|
173
|
+
end
|
174
|
+
|
175
|
+
if !node.has_attribute?('id')
|
176
|
+
puts "ERROR: a template in the file #{fileName}, does not contain an id, for xqcoretools precompilation"
|
177
|
+
continue;
|
178
|
+
end
|
179
|
+
|
180
|
+
id = node.get_attribute('id')
|
181
|
+
|
182
|
+
script += "XQ.Core.templates['#{id}'] = Handlebars.template(" + context.call("Handlebars.precompile", node.content) + ');'
|
183
|
+
|
184
|
+
node.remove()
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
templatesNode = Nokogiri::XML::Node.new('script', document)
|
189
|
+
templatesNode.set_attribute('type', 'text/javascript')
|
190
|
+
templatesNode.content = script
|
191
|
+
insertSibling.add_next_sibling(templatesNode)
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.createTemporaryFolder(name)
|
195
|
+
path = Dir::tmpdir() + "/#{name}"
|
196
|
+
FileUtils.rm_r(path, :force=>true)
|
197
|
+
|
198
|
+
# Wait because the OS might still have a file system lock on the removed path
|
199
|
+
begin
|
200
|
+
FileUtils.mkdir_p(path)
|
201
|
+
rescue
|
202
|
+
sleep 0.1
|
203
|
+
|
204
|
+
begin
|
205
|
+
FileUtils.mkdir_p(path)
|
206
|
+
rescue
|
207
|
+
sleep 1
|
208
|
+
FileUtils.mkdir_p(path)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
return path
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
class XQCoreToolsDownloadCache
|
217
|
+
def initialize(host, folder)
|
218
|
+
@host = host
|
219
|
+
@cacheFolder = XQCoreTools::createTemporaryFolder(folder)
|
220
|
+
end
|
221
|
+
|
222
|
+
def cacheFile(url)
|
223
|
+
file = @cacheFolder + "/#{url}"
|
224
|
+
dir = File.dirname(file)
|
225
|
+
|
226
|
+
if !Dir.exists? dir
|
227
|
+
FileUtils.mkdir_p dir
|
228
|
+
end
|
229
|
+
|
230
|
+
if !File.exists? file
|
231
|
+
downloadFile(url, file)
|
232
|
+
end
|
233
|
+
|
234
|
+
return file
|
235
|
+
end
|
236
|
+
|
237
|
+
def saveFile(url, file)
|
238
|
+
cachedFile = cacheFile(url)
|
239
|
+
|
240
|
+
dir = File.dirname(file)
|
241
|
+
if !Dir.exists? dir
|
242
|
+
FileUtils.mkdir_p dir
|
243
|
+
end
|
244
|
+
|
245
|
+
FileUtils.cp cachedFile, file
|
246
|
+
end
|
247
|
+
|
248
|
+
def downloadFile(url, file)
|
249
|
+
http = Net::HTTP.start(@host)
|
250
|
+
response = http.get("/#{url}")
|
251
|
+
|
252
|
+
fileHandle = File.open(file, 'w')
|
253
|
+
fileHandle.write(response.body)
|
254
|
+
fileHandle.close
|
255
|
+
|
256
|
+
http.finish
|
257
|
+
end
|
73
258
|
end
|
74
259
|
|
75
260
|
XQCoreTools.start
|
metadata
CHANGED
@@ -1,64 +1,49 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: xqcoretools
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
version: 0.0.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Mark Wong
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2013-03-05 00:00:00 -08:00
|
18
|
-
default_executable:
|
12
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
|
-
|
14
|
+
description: Tools for synchronizing multiple CSharp projects and deploying to several
|
15
|
+
platform
|
22
16
|
email: mark.sl.wong@gmail.com
|
23
|
-
executables:
|
17
|
+
executables:
|
24
18
|
- xqcoretools
|
25
19
|
extensions: []
|
26
|
-
|
27
20
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
files:
|
21
|
+
files:
|
30
22
|
- bin/xqcoretools
|
31
23
|
- README.rdoc
|
32
24
|
- LICENSE.txt
|
33
|
-
has_rdoc: true
|
34
25
|
homepage: http://github.com/markslwong/XQ.Core.Tools
|
35
26
|
licenses: []
|
36
|
-
|
37
27
|
post_install_message:
|
38
28
|
rdoc_options: []
|
39
|
-
|
40
|
-
require_paths:
|
29
|
+
require_paths:
|
41
30
|
- lib
|
42
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
|
54
|
-
- 0
|
55
|
-
version: "0"
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
56
43
|
requirements: []
|
57
|
-
|
58
44
|
rubyforge_project:
|
59
|
-
rubygems_version: 1.
|
45
|
+
rubygems_version: 1.8.25
|
60
46
|
signing_key:
|
61
47
|
specification_version: 3
|
62
48
|
summary: Tools for using the XQ.Core framework.
|
63
49
|
test_files: []
|
64
|
-
|