droiuby 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/drby +8 -2
- data/lib/droiuby/project.rb +74 -28
- metadata +68 -55
data/bin/drby
CHANGED
@@ -34,6 +34,8 @@ case command
|
|
34
34
|
device_ip = ARGV[2]
|
35
35
|
elsif ARGV.size == 2
|
36
36
|
device_ip = ARGV[1]
|
37
|
+
elsif ARGV.size == 1
|
38
|
+
device_ip = nil
|
37
39
|
else
|
38
40
|
puts "zips and uploads app to device"
|
39
41
|
puts "usage: "
|
@@ -44,7 +46,8 @@ case command
|
|
44
46
|
|
45
47
|
|
46
48
|
project = Project.new
|
47
|
-
|
49
|
+
droiuby_host = ENV['DROIUBY_HOST'] || '10.0.2.2'
|
50
|
+
project.execute(project_name, device_ip, droiuby_host)
|
48
51
|
when 'live'
|
49
52
|
project_name = nil
|
50
53
|
if ARGV.size == 3
|
@@ -52,6 +55,8 @@ case command
|
|
52
55
|
device_ip = ARGV[2]
|
53
56
|
elsif ARGV.size == 2
|
54
57
|
device_ip = ARGV[1]
|
58
|
+
elsif ARGV.size == 1
|
59
|
+
device_ip = nil
|
55
60
|
else
|
56
61
|
puts "starts a live web server and point droiuby to it"
|
57
62
|
puts "usage: "
|
@@ -60,7 +65,8 @@ case command
|
|
60
65
|
exit(1)
|
61
66
|
end
|
62
67
|
project = Project.new
|
63
|
-
|
68
|
+
droiuby_host = ENV['DROIUBY_HOST'] || '10.0.2.2'
|
69
|
+
project.live(project_name, device_ip, droiuby_host, '')
|
64
70
|
else
|
65
71
|
puts "invalid command"
|
66
72
|
puts "Should be:"
|
data/lib/droiuby/project.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
|
3
2
|
require 'net/http'
|
4
3
|
require 'net/http/post/multipart'
|
5
4
|
require 'zip'
|
6
5
|
require 'thor'
|
7
6
|
require "uri"
|
8
7
|
require 'cgi'
|
9
|
-
|
10
8
|
require 'active_support/core_ext/object'
|
11
9
|
require 'active_support/core_ext/string'
|
12
10
|
|
@@ -18,6 +16,16 @@ class Project < Thor
|
|
18
16
|
|
19
17
|
desc "launch device IP [URL]","Tell droiuby to connect to app hosted at URL"
|
20
18
|
def launch(device_ip, url)
|
19
|
+
|
20
|
+
if device_ip.nil?
|
21
|
+
device_ip = '127.0.0.1'
|
22
|
+
begin
|
23
|
+
`adb forward tcp:4000 tcp:4000`
|
24
|
+
rescue Exception=>e
|
25
|
+
puts e.inspect
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
21
29
|
url_str = "http://#{device_ip}:4000/control?cmd=launch&url=#{CGI::escape(url)}"
|
22
30
|
puts "loading application at url #{url}"
|
23
31
|
puts url_str
|
@@ -29,17 +37,18 @@ class Project < Thor
|
|
29
37
|
end
|
30
38
|
|
31
39
|
desc "create NAME [WORKSPACE_DIR]","create a new droiuby project with NAME"
|
40
|
+
|
32
41
|
def create(name, output_dir = 'projects')
|
33
42
|
@name = name
|
34
43
|
@description = name
|
35
44
|
@launcher_icon = ''
|
36
45
|
@base_url = ''
|
37
46
|
@main_xml = 'index.xml'
|
38
|
-
|
47
|
+
|
39
48
|
if output_dir.blank?
|
40
49
|
output_dir = Dir.pwd
|
41
50
|
end
|
42
|
-
|
51
|
+
|
43
52
|
dest_folder = File.join(output_dir,"#{name}")
|
44
53
|
template File.join('ruby','config.droiuby.erb'), File.join(dest_folder,"config.droiuby")
|
45
54
|
template File.join('ruby','gitignore.erb'), File.join(dest_folder,".gitignore")
|
@@ -53,30 +62,39 @@ class Project < Thor
|
|
53
62
|
|
54
63
|
def package(name, source_dir = 'projects', force = "false")
|
55
64
|
src_folder = if name.blank?
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
65
|
+
Dir.pwd
|
66
|
+
else
|
67
|
+
File.join(source_dir, name)
|
68
|
+
end
|
60
69
|
say "compress #{src_folder}"
|
61
70
|
compress(src_folder, force)
|
62
71
|
end
|
63
72
|
|
64
73
|
require 'webrick'
|
65
74
|
include WEBrick
|
66
|
-
|
75
|
+
|
67
76
|
desc "live NAME DEVICE_IP [HOST NAME] [SOURCE]", "Allow live editing of apps by starting a web server and pointing droiuby to the local instance"
|
68
|
-
def live(name, device_ip, host_name = nil, source_dir = 'projects')
|
69
77
|
|
78
|
+
def live(name, device_ip = nil, host_name = nil, source_dir = 'projects')
|
70
79
|
|
71
80
|
source_dir_args = source_dir ? source_dir : 'projects'
|
72
81
|
host_name_args = host_name ? host_name : Socket.gethostname
|
73
|
-
|
82
|
+
|
74
83
|
src_dir = if name.blank?
|
75
84
|
Dir.pwd
|
76
85
|
else
|
77
86
|
File.join(source_dir_args, name)
|
78
87
|
end
|
79
88
|
|
89
|
+
if device_ip.nil?
|
90
|
+
device_ip = '127.0.0.1'
|
91
|
+
begin
|
92
|
+
`adb forward tcp:4000 tcp:4000`
|
93
|
+
rescue Exception=>e
|
94
|
+
puts e.inspect
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
80
98
|
port = 2000
|
81
99
|
|
82
100
|
ready = false
|
@@ -97,36 +115,51 @@ class Project < Thor
|
|
97
115
|
server.start
|
98
116
|
end
|
99
117
|
|
100
|
-
|
101
118
|
desc "upload NAME DEVICE_IP [WORKSPACE_DIR]","uploads a droiuby application to target device running droiuby client"
|
102
|
-
|
103
|
-
|
104
|
-
|
119
|
+
|
120
|
+
def upload(name, device_ip, source_dir = 'projects', framework = false)
|
121
|
+
|
122
|
+
source_dir = if name.blank? || framework
|
105
123
|
Dir.pwd
|
106
124
|
else
|
107
125
|
File.join(source_dir, name)
|
108
|
-
end
|
126
|
+
end
|
127
|
+
|
128
|
+
if device_ip.nil?
|
129
|
+
device_ip = '127.0.0.1'
|
130
|
+
begin
|
131
|
+
`adb forward tcp:4000 tcp:4000`
|
132
|
+
rescue Exception=>e
|
133
|
+
puts e.inspect
|
134
|
+
end
|
135
|
+
end
|
109
136
|
|
110
|
-
src_package =
|
137
|
+
src_package = if framework
|
138
|
+
File.join(source_dir,'framework_src','build',"#{name}.zip")
|
139
|
+
elsif !name.blank?
|
111
140
|
File.join(source_dir,name,'build',"#{name}.zip")
|
112
141
|
else
|
113
142
|
name = File.basename(source_dir)
|
114
143
|
File.join(source_dir,'build',"#{name}.zip")
|
115
144
|
end
|
116
|
-
|
117
145
|
|
118
146
|
url_str = "http://#{device_ip}:4000/upload"
|
119
147
|
uri = URI.parse(url_str)
|
120
148
|
say "uploading #{src_package} to #{url_str} -> #{uri.host}:#{uri.port}"
|
121
149
|
File.open(src_package) do |zip|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
150
|
+
|
151
|
+
params = {
|
152
|
+
"name" => name,
|
153
|
+
"run" => "true",
|
154
|
+
"file" => UploadIO.new(zip, "application/zip", src_package,"content-disposition" => "form-data; name=\"file\"; filename=\"#{File.basename(src_package)}\"\r\n")}
|
155
|
+
|
156
|
+
|
157
|
+
params.merge!(framework: 'true') if framework
|
158
|
+
req = Net::HTTP::Post::Multipart.new uri.path, params
|
126
159
|
|
127
160
|
retries = 0
|
128
161
|
res = nil
|
129
|
-
|
162
|
+
|
130
163
|
while (retries < 3)
|
131
164
|
sleep 1 + retries
|
132
165
|
begin
|
@@ -139,7 +172,7 @@ class Project < Thor
|
|
139
172
|
next
|
140
173
|
end
|
141
174
|
end
|
142
|
-
|
175
|
+
|
143
176
|
if res && res.code == "200"
|
144
177
|
|
145
178
|
say_status 'upload', src_package
|
@@ -147,15 +180,23 @@ class Project < Thor
|
|
147
180
|
if res
|
148
181
|
say_status 'upload','res.body', :red
|
149
182
|
else
|
150
|
-
say_status 'upload',"upload failed. cannot connect to #{url_str}", :red
|
183
|
+
say_status 'upload',"upload failed. cannot connect to #{url_str}", :red
|
151
184
|
end
|
152
|
-
|
185
|
+
|
153
186
|
end
|
154
187
|
|
155
188
|
end
|
156
189
|
end
|
157
190
|
|
191
|
+
desc "framework DEVICE_IP","updates the droiuby framework using code from framework_src"
|
192
|
+
|
193
|
+
def framework(device_ip = nil, source_dir = 'framework_src')
|
194
|
+
compress(source_dir, "true", "framework")
|
195
|
+
upload 'framework', device_ip, File.join(Dir.pwd,"framework_src"), true
|
196
|
+
end
|
197
|
+
|
158
198
|
desc "execute NAME DEVICE_IP [WORKSPACE_DIR]","package and execute a droiuby application to target device running droiuby client"
|
199
|
+
|
159
200
|
def execute(name, device_ip, source_dir = 'projects')
|
160
201
|
`adb shell am start -W -S --activity-clear-top --activity-brought-to-front -n com.droiuby.application/.CanvasActivity`
|
161
202
|
package name, source_dir, "true"
|
@@ -164,12 +205,17 @@ class Project < Thor
|
|
164
205
|
|
165
206
|
private
|
166
207
|
|
167
|
-
def compress(path, force = "false")
|
208
|
+
def compress(path, force = "false", archive_name = nil)
|
168
209
|
path.sub!(%r[/$],'')
|
169
210
|
unless Dir.exists?(File.join(path,'build'))
|
170
211
|
Dir.mkdir(File.join(path,'build'))
|
171
212
|
end
|
172
|
-
|
213
|
+
|
214
|
+
archive_name = File.basename(path) if archive_name.nil?
|
215
|
+
|
216
|
+
|
217
|
+
archive = File.join(path,'build',"#{archive_name}.zip")
|
218
|
+
|
173
219
|
if force=='true' || file_collision(archive)
|
174
220
|
|
175
221
|
FileUtils.rm archive, :force=>true
|
metadata
CHANGED
@@ -1,112 +1,112 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droiuby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Joseph Emmanuel Dayo
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
17
18
|
requirements:
|
18
|
-
- - '>='
|
19
|
+
- - ! '>='
|
19
20
|
- !ruby/object:Gem::Version
|
20
21
|
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
25
|
none: false
|
22
|
-
requirement: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
|
-
none: false
|
28
|
-
prerelease: false
|
29
|
-
type: :runtime
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: thor
|
32
|
-
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
33
34
|
requirements:
|
34
|
-
- - '>='
|
35
|
+
- - ! '>='
|
35
36
|
- !ruby/object:Gem::Version
|
36
37
|
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
41
|
none: false
|
38
|
-
requirement: !ruby/object:Gem::Requirement
|
39
42
|
requirements:
|
40
|
-
- - '>='
|
43
|
+
- - ! '>='
|
41
44
|
- !ruby/object:Gem::Version
|
42
45
|
version: '0'
|
43
|
-
none: false
|
44
|
-
prerelease: false
|
45
|
-
type: :runtime
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rubyzip
|
48
|
-
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
49
50
|
requirements:
|
50
|
-
- - '>='
|
51
|
+
- - ! '>='
|
51
52
|
- !ruby/object:Gem::Version
|
52
53
|
version: 1.0.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
57
|
none: false
|
54
|
-
requirement: !ruby/object:Gem::Requirement
|
55
58
|
requirements:
|
56
|
-
- - '>='
|
59
|
+
- - ! '>='
|
57
60
|
- !ruby/object:Gem::Version
|
58
61
|
version: 1.0.0
|
59
|
-
none: false
|
60
|
-
prerelease: false
|
61
|
-
type: :runtime
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: multipart-post
|
64
|
-
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
65
66
|
requirements:
|
66
|
-
- - '>='
|
67
|
+
- - ! '>='
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
73
|
none: false
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
71
74
|
requirements:
|
72
|
-
- - '>='
|
75
|
+
- - ! '>='
|
73
76
|
- !ruby/object:Gem::Version
|
74
77
|
version: '0'
|
75
|
-
none: false
|
76
|
-
prerelease: false
|
77
|
-
type: :runtime
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: properties-ruby
|
80
|
-
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
81
82
|
requirements:
|
82
|
-
- - '>='
|
83
|
+
- - ! '>='
|
83
84
|
- !ruby/object:Gem::Version
|
84
85
|
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
89
|
none: false
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
90
|
requirements:
|
88
|
-
- - '>='
|
91
|
+
- - ! '>='
|
89
92
|
- !ruby/object:Gem::Version
|
90
93
|
version: '0'
|
91
|
-
none: false
|
92
|
-
prerelease: false
|
93
|
-
type: :runtime
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: activesupport
|
96
|
-
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
97
98
|
requirements:
|
98
|
-
- - '>='
|
99
|
+
- - ! '>='
|
99
100
|
- !ruby/object:Gem::Version
|
100
101
|
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
105
|
none: false
|
102
|
-
requirement: !ruby/object:Gem::Requirement
|
103
106
|
requirements:
|
104
|
-
- - '>='
|
107
|
+
- - ! '>='
|
105
108
|
- !ruby/object:Gem::Version
|
106
109
|
version: '0'
|
107
|
-
none: false
|
108
|
-
prerelease: false
|
109
|
-
type: :runtime
|
110
110
|
description: Android development using ruby
|
111
111
|
email: joseph.dayo@gmail.com
|
112
112
|
executables:
|
@@ -116,35 +116,48 @@ extra_rdoc_files: []
|
|
116
116
|
files:
|
117
117
|
- lib/droiuby.rb
|
118
118
|
- lib/droiuby/project.rb
|
119
|
-
- lib/droiuby/templates/ruby/config.droiuby.erb
|
120
119
|
- lib/droiuby/templates/ruby/gitignore.erb
|
120
|
+
- lib/droiuby/templates/ruby/config.droiuby.erb
|
121
|
+
- lib/droiuby/templates/ruby/application.css.erb
|
121
122
|
- lib/droiuby/templates/ruby/index.rb.erb
|
122
123
|
- lib/droiuby/templates/ruby/index.xml.erb
|
123
|
-
- lib/droiuby/templates/ruby/application.css.erb
|
124
124
|
- bin/drby
|
125
125
|
homepage: http://rubygems.org/gems/droiuby
|
126
126
|
licenses:
|
127
127
|
- MIT
|
128
|
-
post_install_message:
|
128
|
+
post_install_message: ! 'Droiuby Gem Installed!
|
129
|
+
|
130
|
+
Post Install work:
|
131
|
+
|
132
|
+
1.Go install the droiuby development app here:
|
133
|
+
|
134
|
+
2. Download the android sdk (http://developer.android.com/sdk/index.html)
|
135
|
+
|
136
|
+
3. Setup your PATH to include <sdk directory>/sdk/platform-tools (make sure adb
|
137
|
+
works)
|
138
|
+
|
139
|
+
4. Attach your android phone to your PC via USB and start rocking!!
|
140
|
+
|
141
|
+
'
|
129
142
|
rdoc_options: []
|
130
143
|
require_paths:
|
131
144
|
- lib
|
132
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
133
147
|
requirements:
|
134
|
-
- - '>='
|
148
|
+
- - ! '>='
|
135
149
|
- !ruby/object:Gem::Version
|
136
150
|
version: '0'
|
137
|
-
none: false
|
138
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
139
153
|
requirements:
|
140
|
-
- - '>='
|
154
|
+
- - ! '>='
|
141
155
|
- !ruby/object:Gem::Version
|
142
156
|
version: '0'
|
143
|
-
none: false
|
144
157
|
requirements: []
|
145
|
-
rubyforge_project:
|
158
|
+
rubyforge_project:
|
146
159
|
rubygems_version: 1.8.24
|
147
|
-
signing_key:
|
160
|
+
signing_key:
|
148
161
|
specification_version: 3
|
149
162
|
summary: Droiuby GEM
|
150
163
|
test_files: []
|