droiuby 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a20c92e4f7910149a0baf89de5c4b3fa65923a54
|
4
|
+
data.tar.gz: ce2e50f8c9686819398224b543862c20f86e07b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c55561deb9cfd6ed18cc2edf12470f3e26da53bd0be282fd32b49d1f971ef1f949cba1cb0fa4fca9231f984134849a3bf7bde4b77c9fcbb0a739692d170f5114
|
7
|
+
data.tar.gz: 0ddf758c421e1a00fc76ee81ed494c14b5c857d98c41137350546b442acccb7812fd221a3c77d202a76536918ed5fea031a48e3040955e337617c05417421f86
|
data/lib/droiuby/application.rb
CHANGED
data/lib/droiuby/droiuby.rb
CHANGED
@@ -2,7 +2,7 @@ require 'droiuby/loader'
|
|
2
2
|
|
3
3
|
#Droiuby Framework class
|
4
4
|
class DroiubyFramework
|
5
|
-
|
5
|
+
|
6
6
|
def before_activity_setup
|
7
7
|
fname = "#{File.dirname(__FILE__)}/bootstrap.rb"
|
8
8
|
@bootstrap = @bootstrap || File.read(fname)
|
@@ -18,12 +18,12 @@ class DroiubyFramework
|
|
18
18
|
def on_click(view)
|
19
19
|
end
|
20
20
|
|
21
|
-
def script(controller)
|
21
|
+
def script(controller, refresh = false)
|
22
22
|
klass = controller.camelize.constantize
|
23
23
|
instance = klass.new
|
24
24
|
|
25
25
|
skip_content_view = if instance.respond_to? :before_content_render
|
26
|
-
instance.before_content_render
|
26
|
+
instance.before_content_render unless refresh
|
27
27
|
end
|
28
28
|
|
29
29
|
set_content_view unless skip_content_view
|
@@ -54,4 +54,4 @@ class DroiubyFramework
|
|
54
54
|
|
55
55
|
end
|
56
56
|
|
57
|
-
$framework = DroiubyFramework.new
|
57
|
+
$framework = DroiubyFramework.new
|
@@ -27,9 +27,9 @@ class Project < Thor
|
|
27
27
|
device_ip
|
28
28
|
end
|
29
29
|
}
|
30
|
-
|
31
|
-
|
32
|
-
desc "proximity [device_ip] [true|false]", "enable/disable proximity refresh"
|
30
|
+
|
31
|
+
|
32
|
+
desc "proximity [device_ip] [true|false]", "enable/disable proximity refresh"
|
33
33
|
def proximity(device_ip, proximity = 'false')
|
34
34
|
device_ip = map_device_ip(device_ip)
|
35
35
|
url_str = "http://#{device_ip}:4000/control?cmd=proximity&switch=#{proximity}"
|
@@ -38,12 +38,12 @@ class Project < Thor
|
|
38
38
|
response = Net::HTTP.get_response(uri)
|
39
39
|
response.body
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
desc "launch device IP [URL]","Tell droiuby to connect to app hosted at URL"
|
43
43
|
def launch(device_ip, url)
|
44
|
-
|
44
|
+
|
45
45
|
device_ip = map_device_ip(device_ip)
|
46
|
-
|
46
|
+
|
47
47
|
url_str = "http://#{device_ip}:4000/control?cmd=launch&url=#{CGI::escape(url)}"
|
48
48
|
puts "loading application at url #{url}"
|
49
49
|
puts url_str
|
@@ -67,7 +67,7 @@ class Project < Thor
|
|
67
67
|
puts item
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
desc "cmd [command] [DEVICE_IP]", "Send command to a Droiuby instance"
|
72
72
|
def command(command_line, device_ip=nil)
|
73
73
|
device_ip = map_device_ip(device_ip)
|
@@ -77,7 +77,7 @@ class Project < Thor
|
|
77
77
|
response = Net::HTTP.get_response(uri)
|
78
78
|
response.body
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
desc "reload [DEVICE_IP]", "Reload app at specified device"
|
82
82
|
def reload(device_ip = nil)
|
83
83
|
device_ip = map_device_ip(device_ip)
|
@@ -86,8 +86,8 @@ class Project < Thor
|
|
86
86
|
# Shortcut
|
87
87
|
response = Net::HTTP.get_response(uri)
|
88
88
|
response.body
|
89
|
-
end
|
90
|
-
|
89
|
+
end
|
90
|
+
|
91
91
|
desc "switch [name] [DEVICE IP]","switch to target app instance identified by name"
|
92
92
|
def switch(name, device_ip = nil)
|
93
93
|
device_ip = map_device_ip(device_ip)
|
@@ -99,7 +99,7 @@ class Project < Thor
|
|
99
99
|
# Will print response.body
|
100
100
|
response = Net::HTTP.get_print(uri)
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
desc "autostart MODE [NAME] [DEVICE IP]","set current app to load on startup"
|
104
104
|
def autostart(mode = 'on', name = nil, device_ip = nil)
|
105
105
|
device_ip = map_device_ip(device_ip)
|
@@ -108,16 +108,16 @@ class Project < Thor
|
|
108
108
|
else
|
109
109
|
"http://#{device_ip}:4000/control?cmd=clearautostart"
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
puts url_str
|
113
113
|
uri = URI.parse(url_str)
|
114
114
|
# Shortcut
|
115
115
|
response = Net::HTTP.get_response(uri)
|
116
116
|
# Will print response.body
|
117
117
|
Net::HTTP.get_print(uri)
|
118
|
-
|
118
|
+
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
desc "create NAME [WORKSPACE_DIR]","create a new droiuby project with NAME"
|
122
122
|
|
123
123
|
def create(name, output_dir = 'projects')
|
@@ -125,7 +125,7 @@ class Project < Thor
|
|
125
125
|
@description = name
|
126
126
|
@launcher_icon = ''
|
127
127
|
@base_url = ''
|
128
|
-
@main_xml =
|
128
|
+
@main_xml = File.join("app","views","index.xml")
|
129
129
|
|
130
130
|
if output_dir.blank?
|
131
131
|
output_dir = Dir.pwd
|
@@ -135,9 +135,9 @@ class Project < Thor
|
|
135
135
|
template File.join('ruby','Gemfile.erb'), File.join(dest_folder,"Gemfile")
|
136
136
|
template File.join('ruby','config.droiuby.erb'), File.join(dest_folder,"config.droiuby")
|
137
137
|
template File.join('ruby','gitignore.erb'), File.join(dest_folder,".gitignore")
|
138
|
-
template File.join('ruby','index.xml.erb'), File.join(dest_folder,"index.xml")
|
139
|
-
template File.join('ruby','application.css.erb'), File.join(dest_folder,"application.css")
|
140
|
-
template File.join('ruby','index.rb.erb'), File.join(dest_folder,"index.rb")
|
138
|
+
template File.join('ruby','index.xml.erb'), File.join(dest_folder,"app","views","index.xml")
|
139
|
+
template File.join('ruby','application.css.erb'), File.join(dest_folder,"app","views","styles","application.css")
|
140
|
+
template File.join('ruby','index.rb.erb'), File.join(dest_folder,"app","activities","index.rb")
|
141
141
|
empty_directory File.join(dest_folder,"lib")
|
142
142
|
say "running bundle install"
|
143
143
|
Dir.chdir dest_folder
|
@@ -172,9 +172,9 @@ class Project < Thor
|
|
172
172
|
else
|
173
173
|
File.join(source_dir_args, name)
|
174
174
|
end
|
175
|
-
|
175
|
+
|
176
176
|
device_ip = map_device_ip(device_ip)
|
177
|
-
|
177
|
+
|
178
178
|
port = 2000
|
179
179
|
|
180
180
|
ready = false
|
@@ -197,7 +197,7 @@ class Project < Thor
|
|
197
197
|
trap("INT"){ server.shutdown }
|
198
198
|
server.start
|
199
199
|
end
|
200
|
-
|
200
|
+
|
201
201
|
desc "upload NAME DEVICE_IP [WORKSPACE_DIR]","uploads a droiuby application to target device running droiuby client"
|
202
202
|
|
203
203
|
def upload(name, device_ip, source_dir = 'projects', framework = false, run = true)
|
@@ -209,9 +209,9 @@ class Project < Thor
|
|
209
209
|
end
|
210
210
|
|
211
211
|
device_ip = map_device_ip(device_ip)
|
212
|
-
|
212
|
+
|
213
213
|
src_package = if framework
|
214
|
-
File.join(source_dir,'framework_src','build',"#{name}.zip")
|
214
|
+
File.join(source_dir,'framework_src','build',"#{name}.zip")
|
215
215
|
elsif !name.blank?
|
216
216
|
File.join(source_dir,name,'build',"#{name}.zip")
|
217
217
|
else
|
@@ -223,14 +223,14 @@ class Project < Thor
|
|
223
223
|
uri = URI.parse(url_str)
|
224
224
|
say "uploading #{src_package} to #{url_str} -> #{uri.host}:#{uri.port}"
|
225
225
|
File.open(src_package) do |zip|
|
226
|
-
|
227
|
-
params = {
|
226
|
+
|
227
|
+
params = {
|
228
228
|
"name" => name,
|
229
229
|
"run" => run ? 'true' : 'false',
|
230
230
|
"file" => UploadIO.new(zip, "application/zip", src_package,"content-disposition" => "form-data; name=\"file\"; filename=\"#{File.basename(src_package)}\"\r\n")}
|
231
|
-
|
232
|
-
|
233
|
-
params.merge!(framework: 'true') if framework
|
231
|
+
|
232
|
+
|
233
|
+
params.merge!(framework: 'true') if framework
|
234
234
|
req = Net::HTTP::Post::Multipart.new uri.path, params
|
235
235
|
|
236
236
|
retries = 0
|
@@ -278,14 +278,14 @@ class Project < Thor
|
|
278
278
|
end
|
279
279
|
|
280
280
|
desc "bundle", "unpack all cached gems"
|
281
|
-
|
281
|
+
|
282
282
|
def bundle
|
283
283
|
cache_dir = File.join('vendor','cache')
|
284
|
-
|
284
|
+
|
285
285
|
unless Dir.exists?(cache_dir)
|
286
286
|
puts `bundle package --all`
|
287
287
|
end
|
288
|
-
|
288
|
+
|
289
289
|
if Dir.exists?(cache_dir)
|
290
290
|
path = cache_dir
|
291
291
|
puts 'watch out for exploding gems'
|
@@ -297,7 +297,7 @@ class Project < Thor
|
|
297
297
|
say_status 'error', "can't find cache directory /vendor/cache"
|
298
298
|
end
|
299
299
|
|
300
|
-
|
300
|
+
|
301
301
|
end
|
302
302
|
|
303
303
|
private
|
@@ -307,12 +307,12 @@ class Project < Thor
|
|
307
307
|
unless Dir.exists?(File.join(path,'build'))
|
308
308
|
Dir.mkdir(File.join(path,'build'))
|
309
309
|
end
|
310
|
-
|
310
|
+
|
311
311
|
archive_name = File.basename(path) if archive_name.nil?
|
312
|
-
|
313
|
-
|
312
|
+
|
313
|
+
|
314
314
|
archive = File.join(path,'build',"#{archive_name}.zip")
|
315
|
-
|
315
|
+
|
316
316
|
if force=='true' || file_collision(archive)
|
317
317
|
|
318
318
|
FileUtils.rm archive, :force=>true
|
@@ -1 +1,2 @@
|
|
1
|
-
build/**/*
|
1
|
+
build/**/*
|
2
|
+
.bundle
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<activity controller="index.rb#index">
|
2
|
-
<preload id="application_css" src="application.css" type="css"/>
|
1
|
+
<activity controller="app/activities/index.rb#index">
|
2
|
+
<preload id="application_css" src="app/views/styles/application.css" type="css"/>
|
3
3
|
<layout type="linear" width="match" height="match" orientation="vertical">
|
4
4
|
<t>Hello World!</t>
|
5
5
|
</layout>
|
6
|
-
</activity>
|
6
|
+
</activity>
|