droiuby 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/drby +9 -2
- data/lib/droiuby/scripts/project.rb +20 -13
- data/lib/droiuby/scripts/templates/ruby/Gemfile.erb +3 -1
- data/lib/droiuby/scripts/templates/ruby/index_spec.rb.erb +16 -0
- data/lib/droiuby/scripts/templates/ruby/spec_helper.rb.erb +13 -0
- data/lib/droiuby/spec/helper.rb +61 -0
- data/lib/droiuby/spec/loader.rb +17 -0
- data/lib/droiuby/spec/mock_objects/droiuby_app.rb +11 -0
- data/lib/droiuby/spec/mock_objects/system_wrapper.rb +5 -0
- data/lib/droiuby/support/asset.rb +18 -13
- data/lib/droiuby/support/autoload.rb +9 -10
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66f1b851db7272ef16731e1dbb62d891b3596a30
|
4
|
+
data.tar.gz: e83fb1c37367b7b0f758a34416c417e38057180b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c039489821c83bad6fc91006b43bab08bb51e507bf44bb6cce8516dcca7d2769ed79b516650af91480ff4961511471f700f51f5abf9b92c4db683fe7d2b4627a
|
7
|
+
data.tar.gz: ce55b3bd6ac358fb298e595f594b5a054d57b602a9eeea52b0687ad449f825ebe65602b27cc973d360ced125c958ebe74756b1b9a830400bb7af56f2f82918c8
|
data/bin/drby
CHANGED
@@ -10,13 +10,16 @@ require 'json'
|
|
10
10
|
$droiuby_host = ENV['DROIUBY_HOST'] || '10.0.2.2'
|
11
11
|
$device_ip = ENV['DROIUBY_DEVICE'] || nil
|
12
12
|
$app_name = nil
|
13
|
+
$no_project = false
|
14
|
+
$show_help = false
|
15
|
+
$ant_args = nil
|
13
16
|
|
14
17
|
options = OptionParser.new do |o|
|
15
18
|
o.banner =
|
16
19
|
"Usage: drby autostart true|false INSTANCE_NAME [options] # Set specified instance to start on droiuby launch
|
17
20
|
drby console [options] # Launch an interactive console to the target Android Device running Droiuby
|
18
21
|
drby framework update [FOLDER] [options] # updates the droiuby framework from folder (default src_framework)
|
19
|
-
drby go [PROJECT_NAME] [options]
|
22
|
+
drby go [PROJECT_NAME] [options] [--no-project] # packages an app and uploads to an Android Device running Droiuby
|
20
23
|
drby list [options] # Lists the app instances running on the phone
|
21
24
|
drby live [PROJECT_NAME] [options] # runs a web instance of the app and tells Droiuby to load it.
|
22
25
|
drby new PROJECT_NAME [options] # Create a new project
|
@@ -27,12 +30,16 @@ options = OptionParser.new do |o|
|
|
27
30
|
drby switch INSTANCE_NAME [options] # Switch to the specified instance
|
28
31
|
drby bundle # unzips all gems in vendor/cache for deployment to droiuby\n"
|
29
32
|
|
33
|
+
|
30
34
|
o.separator ""
|
31
35
|
o.separator "options:"
|
36
|
+
o.on('-X','--ant-args','additional params to pass to ant') { |b| $ant_args = b}
|
37
|
+
o.on('-h','--help','show this help screen') {|b| $show_help = true}
|
32
38
|
o.on('-n','--name app_name','The name of the app that appears in the launcher') {|b| $app_name =b }
|
33
39
|
o.on('-p','--package java_package','The java package name to use') {|b| $java_package = b}
|
34
40
|
o.on('-h','--host HOST_IP','The IP Address of the host computer (for droiuby live mode)') { |b| $droiuby_host = b }
|
35
41
|
o.on('-d','--device DEVICE_IP','The IP Address of the Android Device') { |b| $device_ip = b }
|
42
|
+
o.on('-P','--no-project','Tells drby go to ignore the android project if present') {|b| $no_project = true}
|
36
43
|
o.parse!
|
37
44
|
end
|
38
45
|
|
@@ -174,7 +181,7 @@ case command
|
|
174
181
|
end
|
175
182
|
end
|
176
183
|
|
177
|
-
project.execute(project_name, $device_ip, $droiuby_host)
|
184
|
+
project.execute(project_name, $device_ip, $droiuby_host, $no_project, $ant_args)
|
178
185
|
when 'bundle'
|
179
186
|
project.bundle
|
180
187
|
when 'live'
|
@@ -78,15 +78,15 @@ class Project < Thor
|
|
78
78
|
desc "list [DEVICE IP]","List running app instances"
|
79
79
|
def list(device_ip = nil)
|
80
80
|
device_ip = map_device_ip(device_ip)
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
81
|
+
url_str = "http://#{device_ip}:4000/control?cmd=list"
|
82
|
+
puts url_str
|
83
|
+
uri = URI.parse(url_str)
|
84
|
+
# Shortcut
|
85
|
+
response = Net::HTTP.get_response(uri)
|
86
|
+
result = JSON.parse(response.body)
|
87
|
+
result['list'].split(',').each do |item|
|
88
|
+
puts item
|
89
|
+
end
|
90
90
|
end
|
91
91
|
|
92
92
|
desc "cmd [command] [DEVICE_IP]", "Send command to a Droiuby instance"
|
@@ -218,6 +218,9 @@ class Project < Thor
|
|
218
218
|
template File.join('ruby','index.xml.erb'), File.join(dest_folder,"app","views","index.xml")
|
219
219
|
template File.join('ruby','application.css.erb'), File.join(dest_folder,"app","views","styles","application.css")
|
220
220
|
template File.join('ruby','index.rb.erb'), File.join(dest_folder,"app","activities","index.rb")
|
221
|
+
template File.join('ruby','index_spec.rb.erb'), File.join(dest_folder,"spec","activities","index_spec.rb")
|
222
|
+
template File.join('ruby','spec_helper.rb.erb'), File.join(dest_folder,"spec","spec_helper.rb")
|
223
|
+
|
221
224
|
empty_directory File.join(dest_folder,"lib")
|
222
225
|
say "running bundle install"
|
223
226
|
Dir.chdir dest_folder
|
@@ -358,8 +361,8 @@ class Project < Thor
|
|
358
361
|
upload 'framework', device_ip, File.join(Dir.pwd,"framework_src"), true
|
359
362
|
end
|
360
363
|
|
361
|
-
desc "execute NAME DEVICE_IP [WORKSPACE_DIR]","package and execute a droiuby application to target device running droiuby client"
|
362
|
-
def execute(name, device_ip, source_dir = 'projects')
|
364
|
+
desc "execute NAME DEVICE_IP [WORKSPACE_DIR] [IGNORE_PROJECT] [ANT_ARGS]","package and execute a droiuby application to target device running droiuby client"
|
365
|
+
def execute(name, device_ip, source_dir = 'projects', ignore_project = false, ant_args = nil)
|
363
366
|
|
364
367
|
package name, source_dir, "true"
|
365
368
|
|
@@ -373,7 +376,7 @@ class Project < Thor
|
|
373
376
|
project_directory = File.join(src_dir,'project')
|
374
377
|
|
375
378
|
say "exsits? #{project_directory}"
|
376
|
-
if File.exists?
|
379
|
+
if !ignore_project && File.exists?(project_directory)
|
377
380
|
say "Android Project exists. Building debug project instead ..."
|
378
381
|
Dir.chdir(project_directory)
|
379
382
|
doc = Nokogiri.XML(File.read('AndroidManifest.xml'))
|
@@ -390,7 +393,11 @@ class Project < Thor
|
|
390
393
|
`adb shell am start -S --activity-clear-top --activity-brought-to-front -n #{package_name}/.StartupActivity`
|
391
394
|
else
|
392
395
|
say "No device connected. will just build the project"
|
393
|
-
|
396
|
+
if ant_args.nil?
|
397
|
+
puts `ant debug`
|
398
|
+
else
|
399
|
+
puts `ant #{ant_args}`
|
400
|
+
end
|
394
401
|
end
|
395
402
|
else
|
396
403
|
upload name, device_ip, source_dir
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'droiuby/spec/helper'
|
2
|
+
|
3
|
+
ENV["DROIUBY_ENV"] ||= 'test'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
# ## Mock Framework
|
7
|
+
#
|
8
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
9
|
+
#
|
10
|
+
# config.mock_with :mocha
|
11
|
+
# config.mock_with :flexmock
|
12
|
+
config.mock_with :rr
|
13
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
$:.unshift Dir.pwd
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__),'loader')
|
4
|
+
$autoload_path << File.join('app','activities')
|
5
|
+
|
6
|
+
|
7
|
+
#Droiuby Mock Framework class
|
8
|
+
class DroiubyFramework
|
9
|
+
|
10
|
+
def before_activity_setup
|
11
|
+
fname = "#{File.dirname(__FILE__)}/../bootstrap.rb"
|
12
|
+
@bootstrap = @bootstrap || File.read(fname)
|
13
|
+
eval(@bootstrap, TOPLEVEL_BINDING, fname, __LINE__)
|
14
|
+
end
|
15
|
+
|
16
|
+
def preload
|
17
|
+
fname = "#{File.dirname(__FILE__)}/preload.rb"
|
18
|
+
@preload = @preload || File.read(fname)
|
19
|
+
eval(@preload, TOPLEVEL_BINDING, fname, __LINE__)
|
20
|
+
end
|
21
|
+
|
22
|
+
def on_click(view)
|
23
|
+
end
|
24
|
+
|
25
|
+
def script(controller, refresh = false)
|
26
|
+
klass = controller.camelize.constantize
|
27
|
+
instance = klass.new
|
28
|
+
|
29
|
+
skip_content_view = if instance.respond_to? :before_content_render
|
30
|
+
instance.before_content_render unless refresh
|
31
|
+
end
|
32
|
+
|
33
|
+
set_content_view unless skip_content_view
|
34
|
+
|
35
|
+
instance.on_create
|
36
|
+
instance
|
37
|
+
end
|
38
|
+
|
39
|
+
def resolve_view(name, node)
|
40
|
+
name_parts = name.split('#')
|
41
|
+
|
42
|
+
klass_str = if name_parts.size > 1
|
43
|
+
"#{name_parts[0].camelize}::#{name_parts[1].camelize}"
|
44
|
+
else
|
45
|
+
name.camelize
|
46
|
+
end
|
47
|
+
|
48
|
+
puts klass_str
|
49
|
+
klass = klass_str.constantize
|
50
|
+
|
51
|
+
instance = klass.new(_current_activity)
|
52
|
+
if instance.class < ViewWrapper
|
53
|
+
instance.native
|
54
|
+
else
|
55
|
+
instance._proxy_class([Java::android.content.Context.java_class], [_current_activity])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
$framework = DroiubyFramework.new
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'droiuby/support/utils'
|
2
|
+
require 'droiuby/support/fixnum'
|
3
|
+
require 'droiuby/support/autoload'
|
4
|
+
require 'droiuby/wrappers/collection/view_array'
|
5
|
+
require 'droiuby/wrappers/proxy_builder/interface_builder'
|
6
|
+
require 'droiuby/wrappers/listeners/auto_wrap'
|
7
|
+
require 'droiuby/wrappers/listeners/on_web_console_ready_listener'
|
8
|
+
require 'droiuby/support/string'
|
9
|
+
require 'droiuby/support/thread'
|
10
|
+
require 'droiuby/support/object'
|
11
|
+
require 'droiuby/support/to_query'
|
12
|
+
require 'droiuby/support/asset'
|
13
|
+
require 'droiuby/wrappers/java_helpers/java_method_helper'
|
14
|
+
require 'droiuby/wrappers/java_helpers/view_helper'
|
15
|
+
require 'droiuby/plugins/plugins'
|
16
|
+
require 'droiuby/application'
|
17
|
+
require 'droiuby/android'
|
@@ -2,46 +2,51 @@ class BitmapDrawableWrapper
|
|
2
2
|
def initialize(drawable)
|
3
3
|
@native = drawable
|
4
4
|
end
|
5
|
-
|
5
|
+
|
6
6
|
def native
|
7
7
|
@native
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def to_bitmap
|
11
11
|
@native.getBitmap
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def height
|
15
15
|
@native.getIntrinsicHeight
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def width
|
19
19
|
@native.getIntrinsicWidth
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
class AssetHandler
|
24
|
-
|
25
|
-
def initialize(url)
|
24
|
+
|
25
|
+
def initialize(url, asset_type)
|
26
26
|
@url = url
|
27
|
+
@asset_type = case asset_type
|
28
|
+
when :image
|
29
|
+
Java::com.droiuby.client.core.utils.Utils::ASSET_TYPE_IMAGE
|
30
|
+
end
|
31
|
+
|
27
32
|
end
|
28
|
-
|
29
|
-
def self.download(url)
|
30
|
-
AssetHandler.new(url)
|
33
|
+
|
34
|
+
def self.download(url, asset_type = :image)
|
35
|
+
AssetHandler.new(url, asset_type)
|
31
36
|
end
|
32
|
-
|
37
|
+
|
33
38
|
def start
|
34
39
|
async.perform {
|
35
40
|
result = BitmapDrawableWrapper.new(Java::com.droiuby.client.core.utils.Utils.loadAppAssetRuby(_execution_bundle, _current_app, _current_activity,
|
36
|
-
@url,
|
41
|
+
@url, @asset_type, Java::com.droiuby.client.core.utils.Utils::HTTP_GET))
|
37
42
|
result
|
38
43
|
}.done { |result|
|
39
44
|
@block.call(result)
|
40
45
|
}.start
|
41
46
|
end
|
42
|
-
|
47
|
+
|
43
48
|
def done(&block)
|
44
49
|
@block = block
|
45
50
|
self
|
46
51
|
end
|
47
|
-
end
|
52
|
+
end
|
@@ -1,22 +1,21 @@
|
|
1
1
|
$autoload_path = [nil,File.join('droiuby','wrappers')]
|
2
2
|
|
3
|
-
|
4
3
|
module MissingHandler
|
5
4
|
def const_missing(name)
|
6
5
|
@looked_for ||= {}
|
7
6
|
str_name = name.to_s
|
8
7
|
raise "Class not found: #{name}" if @looked_for[str_name] == :missing
|
9
|
-
|
10
|
-
|
8
|
+
|
9
|
+
|
11
10
|
name_parts = name.to_s.split('::').collect { |n| n.underscore }
|
12
|
-
|
13
|
-
|
11
|
+
|
12
|
+
|
14
13
|
$autoload_path.each do |path|
|
15
|
-
path_array = unless path.nil?
|
14
|
+
path_array = unless path.nil?
|
16
15
|
[path] + name_parts
|
17
16
|
else
|
18
17
|
name_parts
|
19
|
-
end
|
18
|
+
end
|
20
19
|
require_path = File.join(*path_array)
|
21
20
|
|
22
21
|
begin
|
@@ -25,9 +24,9 @@ module MissingHandler
|
|
25
24
|
return klass if klass
|
26
25
|
rescue LoadError=>e
|
27
26
|
end
|
28
|
-
|
27
|
+
|
29
28
|
end
|
30
|
-
|
29
|
+
|
31
30
|
@looked_for[str_name] = :missing
|
32
31
|
|
33
32
|
raise "Class not found: #{name}"
|
@@ -38,7 +37,7 @@ end
|
|
38
37
|
class Object
|
39
38
|
class << self
|
40
39
|
alias :const_missing_old :const_missing
|
41
|
-
|
40
|
+
|
42
41
|
include MissingHandler
|
43
42
|
end
|
44
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Emmanuel Dayo
|
@@ -117,6 +117,12 @@ files:
|
|
117
117
|
- lib/droiuby/scripts/templates/ruby/gitignore.erb
|
118
118
|
- lib/droiuby/scripts/templates/ruby/index.rb.erb
|
119
119
|
- lib/droiuby/scripts/templates/ruby/index.xml.erb
|
120
|
+
- lib/droiuby/scripts/templates/ruby/index_spec.rb.erb
|
121
|
+
- lib/droiuby/scripts/templates/ruby/spec_helper.rb.erb
|
122
|
+
- lib/droiuby/spec/helper.rb
|
123
|
+
- lib/droiuby/spec/loader.rb
|
124
|
+
- lib/droiuby/spec/mock_objects/droiuby_app.rb
|
125
|
+
- lib/droiuby/spec/mock_objects/system_wrapper.rb
|
120
126
|
- lib/droiuby/support/asset.rb
|
121
127
|
- lib/droiuby/support/autoload.rb
|
122
128
|
- lib/droiuby/support/fixnum.rb
|