droiuby 0.3.5 → 0.3.6
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.
- checksums.yaml +4 -4
- data/bin/drby +22 -2
- data/lib/droiuby/scripts/project.rb +187 -140
- data/lib/droiuby/support/autoload.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 394d5e9256c5bee153f804042a6d78f0bc30e7f8
|
4
|
+
data.tar.gz: 2c1dc306cf97d112a3f3002280f30c13f25df5e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 827df4df668365a07c06aabd65712b9742eb2e347564f53d3e71fbc3cc98544bda74b25c2aed7d03de47b0c9b261cbb400821f49147ddf072bd81a8fac392201
|
7
|
+
data.tar.gz: a21d9d5dd2c6fe7ea3d28f6b77e3945f6b64edf45109c3a5efc3744b84f7b86b488739df02944a4b1283f91349522e97b1130d859c1d35dd5553c78f369bf803
|
data/bin/drby
CHANGED
@@ -13,6 +13,7 @@ $app_name = nil
|
|
13
13
|
$no_project = false
|
14
14
|
$show_help = false
|
15
15
|
$ant_args = nil
|
16
|
+
$repo, $branch = nil
|
16
17
|
|
17
18
|
options = OptionParser.new do |o|
|
18
19
|
o.banner =
|
@@ -39,7 +40,10 @@ options = OptionParser.new do |o|
|
|
39
40
|
o.on('-n','--name app_name','The name of the app that appears in the launcher') {|b| $app_name =b }
|
40
41
|
o.on('-p','--package java_package','The java package name to use') {|b| $java_package = b}
|
41
42
|
o.on('-h','--host HOST_IP','The IP Address of the host computer (for droiuby live mode)') { |b| $droiuby_host = b }
|
43
|
+
o.on('-G','--gradle','Create a gradle android project') { |b| $repo = 'https://github.com/jedld/droiuby-template-gradle.git'}
|
42
44
|
o.on('-d','--device DEVICE_IP','The IP Address of the Android Device') { |b| $device_ip = b }
|
45
|
+
o.on('-r','--repo repo_git_url','The git repository to use for project templates') { |b| $repo = b }
|
46
|
+
o.on('-b','--branch repo_git_branch','The git branch to use for templates') { |b| $branch = b }
|
43
47
|
o.on('-P','--no-project','Tells drby go to ignore the android project if present') {|b| $no_project = true}
|
44
48
|
o.parse!
|
45
49
|
end
|
@@ -61,6 +65,12 @@ case command
|
|
61
65
|
when 'new'
|
62
66
|
n = 1
|
63
67
|
hybrid_mode = false
|
68
|
+
standalone = false
|
69
|
+
if ARGV[n] == 'standalone'
|
70
|
+
n+=1
|
71
|
+
standalone = true
|
72
|
+
end
|
73
|
+
|
64
74
|
if ARGV[n] == 'hybrid'
|
65
75
|
n+=1
|
66
76
|
hybrid_mode = true
|
@@ -80,7 +90,17 @@ case command
|
|
80
90
|
$app_name
|
81
91
|
end
|
82
92
|
|
83
|
-
|
93
|
+
opt = {repository: $repo, branch: $branch}
|
94
|
+
opt[:type] = if hybrid_mode
|
95
|
+
:hybrid
|
96
|
+
elsif standalone
|
97
|
+
:standalone
|
98
|
+
else
|
99
|
+
:droiuby
|
100
|
+
end
|
101
|
+
|
102
|
+
project.project_generator(project_name, app_name, '', opt)
|
103
|
+
|
84
104
|
when 'reload'
|
85
105
|
project_name = ARGV[1]
|
86
106
|
project.package(project_name, nil, 'true')
|
@@ -139,7 +159,7 @@ case command
|
|
139
159
|
puts '--package [JAVA_PACKAGE] is required.'
|
140
160
|
exit(1)
|
141
161
|
end
|
142
|
-
project.standalone(project_name, $java_package, $app_name,'')
|
162
|
+
project.standalone(project_name, $java_package, $app_name,'', $repo, $branch)
|
143
163
|
when 'switch'
|
144
164
|
instance_name = nil
|
145
165
|
unless ARGV[1].blank?
|
@@ -47,6 +47,148 @@ class Project < Thor
|
|
47
47
|
[]
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
def project_generator(name, app_name = :prompt, output_dir = 'projects', opt={})
|
52
|
+
@name = name
|
53
|
+
if app_name.nil?
|
54
|
+
@app_name = app_name
|
55
|
+
elsif app_name == :prompt
|
56
|
+
say("Please enter the display name for your app (Used for app launcher and Title):")
|
57
|
+
@app_name = ask("Display Name: ")
|
58
|
+
end
|
59
|
+
|
60
|
+
@description = name
|
61
|
+
@launcher_icon = ''
|
62
|
+
@base_url = ''
|
63
|
+
if opt[:type] == :droiuby || opt[:type] == :standalone
|
64
|
+
@main_xml = File.join("app","views","index.xml")
|
65
|
+
elsif opt[:type] == :hybrid
|
66
|
+
@main_xml = File.join("app","activities","index.rb")
|
67
|
+
else
|
68
|
+
say :red, "Invalid project type specified #{opt[:type]}"
|
69
|
+
exit(1);
|
70
|
+
end
|
71
|
+
|
72
|
+
if output_dir.blank?
|
73
|
+
output_dir = Dir.pwd
|
74
|
+
end
|
75
|
+
|
76
|
+
dest_folder = File.join(output_dir,"#{name}")
|
77
|
+
template File.join('ruby','Gemfile.erb'), File.join(dest_folder,"Gemfile")
|
78
|
+
template File.join('ruby','config.droiuby.erb'), File.join(dest_folder,"config.droiuby")
|
79
|
+
template File.join('ruby','gitignore.erb'), File.join(dest_folder,".gitignore")
|
80
|
+
|
81
|
+
if opt[:type] == :droiuby
|
82
|
+
template File.join('ruby','index.xml.erb'), File.join(dest_folder,"app","views","index.xml")
|
83
|
+
end
|
84
|
+
|
85
|
+
template File.join('ruby','application.css.erb'), File.join(dest_folder,"app","views","styles","application.css")
|
86
|
+
if opt[:type] == :droiuby
|
87
|
+
template File.join('ruby','index.rb.erb'), File.join(dest_folder,"app","activities","index.rb")
|
88
|
+
elsif opt[:type] == :hybrid
|
89
|
+
template File.join('ruby','index-hybrid.rb.erb'), File.join(dest_folder,"app","activities","index.rb")
|
90
|
+
end
|
91
|
+
template File.join('ruby','index_spec.rb.erb'), File.join(dest_folder,"spec","activities","index_spec.rb")
|
92
|
+
template File.join('ruby','spec_helper.rb.erb'), File.join(dest_folder,"spec","spec_helper.rb")
|
93
|
+
|
94
|
+
empty_directory File.join(dest_folder,"lib")
|
95
|
+
|
96
|
+
Dir.chdir dest_folder
|
97
|
+
if opt[:type] == :hybrid
|
98
|
+
template_generator(nil, :prompt, nil, nil, {xoptions: {hybrid: true}}.merge(opt))
|
99
|
+
elsif opt[:type] == :standalone
|
100
|
+
template_generator(nil, :prompt, nil, nil, opt)
|
101
|
+
end
|
102
|
+
|
103
|
+
say "running bundle install"
|
104
|
+
`bundle install`
|
105
|
+
end
|
106
|
+
|
107
|
+
def template_generator(name, package_name, title = nil, output_dir = 'projects', opt = {})
|
108
|
+
|
109
|
+
repository = opt[:repository]
|
110
|
+
branch = opt[:branch]
|
111
|
+
|
112
|
+
if output_dir.blank?
|
113
|
+
output_dir = Dir.pwd
|
114
|
+
end
|
115
|
+
|
116
|
+
if package_name == :prompt
|
117
|
+
say("Please enter the Java Package Name to be used for your app (e.g. com.awesome.sample ):")
|
118
|
+
package_name = ask("Package Name: ")
|
119
|
+
end
|
120
|
+
|
121
|
+
dest_folder = nil
|
122
|
+
unless name.nil?
|
123
|
+
dest_folder = File.join(output_dir,"#{name}")
|
124
|
+
Dir.chdir dest_folder
|
125
|
+
else
|
126
|
+
dest_folder = Dir.pwd
|
127
|
+
end
|
128
|
+
|
129
|
+
if title.nil?
|
130
|
+
|
131
|
+
doc = Nokogiri.XML(File.read('config.droiuby'))
|
132
|
+
|
133
|
+
doc.css('app_descriptor name').each do |element|
|
134
|
+
title = element.content
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
template_repository = ENV['droiuby_template'] || repository || 'https://github.com/jedld/droiuby-template.git'
|
140
|
+
|
141
|
+
say "using repository #{template_repository} ..."
|
142
|
+
|
143
|
+
template_namespace = URI.parse(template_repository).path.sub('.git','')
|
144
|
+
|
145
|
+
template_directory = File.expand_path(File.join("~/.droiuby/android_project_templates", "#{template_namespace}.#{branch.nil? ? 'master' : branch}"))
|
146
|
+
|
147
|
+
say "checking out to #{template_directory}"
|
148
|
+
|
149
|
+
unless File.exists?(template_directory)
|
150
|
+
say "no cached copy yet. obtaining template project from repository"
|
151
|
+
|
152
|
+
branch = unless branch.nil?
|
153
|
+
"-b #{branch}"
|
154
|
+
else
|
155
|
+
""
|
156
|
+
end
|
157
|
+
|
158
|
+
`git clone #{branch} --depth 1 #{template_repository} #{template_directory}`
|
159
|
+
else
|
160
|
+
say "checking for template updates..."
|
161
|
+
Dir.chdir template_directory
|
162
|
+
`git pull`
|
163
|
+
end
|
164
|
+
|
165
|
+
#prepare
|
166
|
+
directory template_directory, File.join(dest_folder,'project')
|
167
|
+
remove_dir "#{File.join(dest_folder,'project')}/.git"
|
168
|
+
|
169
|
+
Dir.chdir File.join(dest_folder,'project')
|
170
|
+
|
171
|
+
say "creating android project in #{dest_folder}"
|
172
|
+
require "#{File.join(dest_folder,'project','init.rb')}"
|
173
|
+
|
174
|
+
dest_folder = if dest_folder.end_with? '/'
|
175
|
+
dest_folder
|
176
|
+
else
|
177
|
+
"#{dest_folder}/"
|
178
|
+
end
|
179
|
+
|
180
|
+
archive_name = File.basename(dest_folder.sub!(%r[/$],'')) if archive_name.nil?
|
181
|
+
|
182
|
+
init = Init.new
|
183
|
+
init.options = opt[:xoptions] || {}
|
184
|
+
init.init(package_name, "#{archive_name}.zip", title)
|
185
|
+
Dir.chdir dest_folder
|
186
|
+
bundle
|
187
|
+
package(name, '', "true")
|
188
|
+
say "Your android project is located at #{dest_folder}/project."
|
189
|
+
end
|
190
|
+
|
191
|
+
|
50
192
|
}
|
51
193
|
|
52
194
|
|
@@ -140,136 +282,19 @@ class Project < Thor
|
|
140
282
|
end
|
141
283
|
|
142
284
|
desc "standalone NAME [PACKAGE_NAME]", "create an android project for this app with the specified java package name"
|
285
|
+
method_option :xoptions, :type => :hash, :default => {}
|
143
286
|
def standalone(name, package_name, title = nil, output_dir = 'projects', repository = nil, branch = nil)
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
if package_name == :prompt
|
150
|
-
say("Please enter the Java Package Name to be used for your app (e.g. com.awesome.sample ):")
|
151
|
-
package_name = ask("Package Name: ")
|
152
|
-
end
|
153
|
-
|
154
|
-
dest_folder = nil
|
155
|
-
unless name.nil?
|
156
|
-
dest_folder = File.join(output_dir,"#{name}")
|
157
|
-
Dir.chdir dest_folder
|
158
|
-
else
|
159
|
-
dest_folder = Dir.pwd
|
160
|
-
end
|
161
|
-
|
162
|
-
if title.nil?
|
163
|
-
|
164
|
-
doc = Nokogiri.XML(File.read('config.droiuby'))
|
165
|
-
|
166
|
-
doc.css('app_descriptor name').each do |element|
|
167
|
-
title = element.content
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
template_repository = ENV['droiuby_template'] || repository || 'https://github.com/jedld/droiuby-template.git'
|
173
|
-
template_directory = File.expand_path("~/.droiuby/android_project_templates.#{branch.nil? ? 'master' : branch}")
|
174
|
-
|
175
|
-
unless File.exists?(template_directory)
|
176
|
-
say "no cached copy yet. obtaining template project from repository"
|
177
|
-
|
178
|
-
branch = unless branch.nil?
|
179
|
-
"-b #{branch}"
|
180
|
-
else
|
181
|
-
""
|
182
|
-
end
|
183
|
-
|
184
|
-
`git clone #{branch} --depth 1 #{template_repository} #{template_directory}`
|
185
|
-
else
|
186
|
-
say "checking for template updates..."
|
187
|
-
Dir.chdir template_directory
|
188
|
-
`git pull`
|
189
|
-
end
|
190
|
-
|
191
|
-
#prepare
|
192
|
-
directory template_directory, File.join(dest_folder,'project')
|
193
|
-
remove_dir "#{File.join(dest_folder,'project')}/.git"
|
194
|
-
|
195
|
-
Dir.chdir File.join(dest_folder,'project')
|
196
|
-
|
197
|
-
say "creating android porject in #{dest_folder}"
|
198
|
-
require "#{File.join(dest_folder,'project','init.rb')}"
|
199
|
-
|
200
|
-
dest_folder = if dest_folder.end_with? '/'
|
201
|
-
dest_folder
|
202
|
-
else
|
203
|
-
"#{dest_folder}/"
|
204
|
-
end
|
205
|
-
|
206
|
-
archive_name = File.basename(dest_folder.sub!(%r[/$],'')) if archive_name.nil?
|
207
|
-
|
208
|
-
init = Init.new
|
209
|
-
init.init(package_name, "#{archive_name}.zip", title)
|
210
|
-
Dir.chdir dest_folder
|
211
|
-
bundle
|
212
|
-
package(name, '', "true")
|
213
|
-
say "Your android project is located at #{dest_folder}/project."
|
287
|
+
options[:repository] = respository
|
288
|
+
options[:branch] = branch
|
289
|
+
template_generator(name, package_name, title , output_dir , options)
|
214
290
|
end
|
215
291
|
|
216
292
|
|
217
293
|
desc "create PROJECT_NAME [APP_NAME] [WORKSPACE_DIR]","create a new droiuby project with NAME"
|
218
294
|
|
219
295
|
def create(name, app_name = :prompt, output_dir = 'projects', type = 'droiuby')
|
220
|
-
|
221
|
-
|
222
|
-
@app_name = app_name
|
223
|
-
elsif app_name == :prompt
|
224
|
-
say("Please enter the display name for your app (Used for app launcher and Title):")
|
225
|
-
@app_name = ask("Display Name: ")
|
226
|
-
end
|
227
|
-
|
228
|
-
@description = name
|
229
|
-
@launcher_icon = ''
|
230
|
-
@base_url = ''
|
231
|
-
if type == 'droiuby'
|
232
|
-
@main_xml = File.join("app","views","index.xml")
|
233
|
-
elsif type == 'hybrid'
|
234
|
-
@main_xml = File.join("app","activities","index.rb")
|
235
|
-
else
|
236
|
-
say_error "Invalid project type specified"
|
237
|
-
exit(1);
|
238
|
-
end
|
239
|
-
|
240
|
-
if output_dir.blank?
|
241
|
-
output_dir = Dir.pwd
|
242
|
-
end
|
243
|
-
|
244
|
-
dest_folder = File.join(output_dir,"#{name}")
|
245
|
-
template File.join('ruby','Gemfile.erb'), File.join(dest_folder,"Gemfile")
|
246
|
-
template File.join('ruby','config.droiuby.erb'), File.join(dest_folder,"config.droiuby")
|
247
|
-
template File.join('ruby','gitignore.erb'), File.join(dest_folder,".gitignore")
|
248
|
-
|
249
|
-
if type == 'droiuby'
|
250
|
-
template File.join('ruby','index.xml.erb'), File.join(dest_folder,"app","views","index.xml")
|
251
|
-
end
|
252
|
-
|
253
|
-
template File.join('ruby','application.css.erb'), File.join(dest_folder,"app","views","styles","application.css")
|
254
|
-
if type == 'droiuby'
|
255
|
-
template File.join('ruby','index.rb.erb'), File.join(dest_folder,"app","activities","index.rb")
|
256
|
-
elsif type == 'hybrid'
|
257
|
-
template File.join('ruby','index-hybrid.rb.erb'), File.join(dest_folder,"app","activities","index.rb")
|
258
|
-
end
|
259
|
-
template File.join('ruby','index_spec.rb.erb'), File.join(dest_folder,"spec","activities","index_spec.rb")
|
260
|
-
template File.join('ruby','spec_helper.rb.erb'), File.join(dest_folder,"spec","spec_helper.rb")
|
261
|
-
|
262
|
-
empty_directory File.join(dest_folder,"lib")
|
263
|
-
|
264
|
-
Dir.chdir dest_folder
|
265
|
-
if type == 'hybrid'
|
266
|
-
standalone(nil, :prompt, nil, nil, nil, 'hybrid-mode')
|
267
|
-
end
|
268
|
-
|
269
|
-
say "running bundle install"
|
270
|
-
`bundle install`
|
271
|
-
|
272
|
-
|
296
|
+
opt = {type: type.to_sym}
|
297
|
+
project_generator(name, app_name, output_dir, opt)
|
273
298
|
end
|
274
299
|
|
275
300
|
desc "package NAME [WORKSPACE_DIR] [true|false]","package a project"
|
@@ -288,7 +313,14 @@ class Project < Thor
|
|
288
313
|
say "exsits? #{project_directory}"
|
289
314
|
if File.exists? project_directory
|
290
315
|
say "Android Project exists. Updating build inside assets ..."
|
291
|
-
|
316
|
+
|
317
|
+
target_directory = if File.exists?(File.join(project_directory,'build.gradle'))
|
318
|
+
File.join(project_directory,'app','src','main','assets',File.basename(archive))
|
319
|
+
else
|
320
|
+
File.join(project_directory,'assets',File.basename(archive))
|
321
|
+
end
|
322
|
+
|
323
|
+
copy_file archive, target_directory, force: true
|
292
324
|
end
|
293
325
|
end
|
294
326
|
|
@@ -423,26 +455,41 @@ class Project < Thor
|
|
423
455
|
if !ignore_project && File.exists?(project_directory)
|
424
456
|
say "Android Project exists. Building debug project instead ..."
|
425
457
|
Dir.chdir(project_directory)
|
426
|
-
doc = Nokogiri.XML(File.read('AndroidManifest.xml'))
|
427
458
|
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
459
|
+
is_gradle = false
|
460
|
+
#figure out type of project
|
461
|
+
doc = if File.exists?('build.gradle')
|
462
|
+
is_gradle = true
|
463
|
+
Nokogiri.XML(File.read(File.join('app','src','main','AndroidManifest.xml')))
|
464
|
+
else
|
465
|
+
Nokogiri.XML(File.read('AndroidManifest.xml'))
|
466
|
+
end
|
432
467
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
468
|
+
package_name = nil
|
469
|
+
doc.css('manifest').each do |element|
|
470
|
+
package_name = element['package']
|
471
|
+
end
|
472
|
+
|
473
|
+
say "running build..."
|
474
|
+
if !get_connected_devices.empty?
|
475
|
+
|
476
|
+
if is_gradle
|
477
|
+
puts `gradle installDebug`
|
478
|
+
else
|
479
|
+
puts `ant debug install`
|
480
|
+
end
|
481
|
+
|
482
|
+
say "Starting activity #{package_name}"
|
483
|
+
`adb shell am start -S --activity-clear-top --activity-brought-to-front -n #{package_name}/.StartupActivity`
|
442
484
|
else
|
443
|
-
|
485
|
+
say "No device connected. will just build the project"
|
486
|
+
if ant_args.nil?
|
487
|
+
puts `ant debug`
|
488
|
+
else
|
489
|
+
puts `ant #{ant_args}`
|
490
|
+
end
|
444
491
|
end
|
445
|
-
|
492
|
+
|
446
493
|
else
|
447
494
|
upload name, device_ip, source_dir
|
448
495
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droiuby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Emmanuel Dayo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|