droiuby 0.3.4 → 0.3.5

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: 66f1b851db7272ef16731e1dbb62d891b3596a30
4
- data.tar.gz: e83fb1c37367b7b0f758a34416c417e38057180b
3
+ metadata.gz: db6154ab45831e35e2dd08e540db6d528d4f39ad
4
+ data.tar.gz: 6b963f5f8334d787f13ac2fabec2211b7434e88e
5
5
  SHA512:
6
- metadata.gz: c039489821c83bad6fc91006b43bab08bb51e507bf44bb6cce8516dcca7d2769ed79b516650af91480ff4961511471f700f51f5abf9b92c4db683fe7d2b4627a
7
- data.tar.gz: ce55b3bd6ac358fb298e595f594b5a054d57b602a9eeea52b0687ad449f825ebe65602b27cc973d360ced125c958ebe74756b1b9a830400bb7af56f2f82918c8
6
+ metadata.gz: 445e4037a22975ff5c9cc5f6e89c666f0aa3ededee21f1adf2debc894071d907c5be6af5645d25dd01569bc09b3d94e53a6e3b2ad18b5789d8d503499bb0cc41
7
+ data.tar.gz: f2363511ba50edc097090ff2a2567991cdc80825caa47d0ba82d9cbbe4647abb5e3f16bfc4d43302e89c7e6a5b61d084a01054980c42c918d0275fb96be8a4a8
data/bin/drby CHANGED
@@ -23,6 +23,7 @@ options = OptionParser.new do |o|
23
23
  drby list [options] # Lists the app instances running on the phone
24
24
  drby live [PROJECT_NAME] [options] # runs a web instance of the app and tells Droiuby to load it.
25
25
  drby new PROJECT_NAME [options] # Create a new project
26
+ drby new hybrid PROJECT_NAME [options] # Create a new hybrid project
26
27
  drby pack [PROJECT_NAME] [options] # zips and packages an app
27
28
  drby standalone [PROJECT_NAME] --package JAVA_PACKAGE # creates a standalone android project for the current app
28
29
  [--name APP_NAME]
@@ -58,7 +59,14 @@ project = Project.new
58
59
 
59
60
  case command
60
61
  when 'new'
61
- project_name = ARGV[1]
62
+ n = 1
63
+ hybrid_mode = false
64
+ if ARGV[n] == 'hybrid'
65
+ n+=1
66
+ hybrid_mode = true
67
+ end
68
+
69
+ project_name = ARGV[n]
62
70
 
63
71
  if project_name.blank?
64
72
  puts "PROJECT_NAME is required"
@@ -72,7 +80,7 @@ case command
72
80
  $app_name
73
81
  end
74
82
 
75
- project.create(project_name, app_name, '')
83
+ project.create(project_name, app_name, '', hybrid_mode ? 'hybrid' : 'droiuby')
76
84
  when 'reload'
77
85
  project_name = ARGV[1]
78
86
  project.package(project_name, nil, 'true')
@@ -140,15 +140,24 @@ class Project < Thor
140
140
  end
141
141
 
142
142
  desc "standalone NAME [PACKAGE_NAME]", "create an android project for this app with the specified java package name"
143
- def standalone(name, package_name, title = nil, output_dir = 'projects')
143
+ def standalone(name, package_name, title = nil, output_dir = 'projects', repository = nil, branch = nil)
144
144
 
145
145
  if output_dir.blank?
146
146
  output_dir = Dir.pwd
147
147
  end
148
148
 
149
- dest_folder = File.join(output_dir,"#{name}")
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
150
153
 
151
- Dir.chdir dest_folder
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
152
161
 
153
162
  if title.nil?
154
163
 
@@ -160,12 +169,19 @@ class Project < Thor
160
169
 
161
170
  end
162
171
 
163
- template_repository = ENV['droiuby_template'] || 'https://github.com/jedld/droiuby-template.git'
164
- template_directory = File.expand_path('~/.droiuby/android_project_templates')
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}")
165
174
 
166
175
  unless File.exists?(template_directory)
167
176
  say "no cached copy yet. obtaining template project from repository"
168
- `git clone --depth 1 #{template_repository} #{template_directory}`
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}`
169
185
  else
170
186
  say "checking for template updates..."
171
187
  Dir.chdir template_directory
@@ -178,8 +194,15 @@ class Project < Thor
178
194
 
179
195
  Dir.chdir File.join(dest_folder,'project')
180
196
 
197
+ say "creating android porject in #{dest_folder}"
181
198
  require "#{File.join(dest_folder,'project','init.rb')}"
182
199
 
200
+ dest_folder = if dest_folder.end_with? '/'
201
+ dest_folder
202
+ else
203
+ "#{dest_folder}/"
204
+ end
205
+
183
206
  archive_name = File.basename(dest_folder.sub!(%r[/$],'')) if archive_name.nil?
184
207
 
185
208
  init = Init.new
@@ -193,7 +216,7 @@ class Project < Thor
193
216
 
194
217
  desc "create PROJECT_NAME [APP_NAME] [WORKSPACE_DIR]","create a new droiuby project with NAME"
195
218
 
196
- def create(name, app_name = :prompt, output_dir = 'projects')
219
+ def create(name, app_name = :prompt, output_dir = 'projects', type = 'droiuby')
197
220
  @name = name
198
221
  if app_name.nil?
199
222
  @app_name = app_name
@@ -205,7 +228,14 @@ class Project < Thor
205
228
  @description = name
206
229
  @launcher_icon = ''
207
230
  @base_url = ''
208
- @main_xml = File.join("app","views","index.xml")
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
209
239
 
210
240
  if output_dir.blank?
211
241
  output_dir = Dir.pwd
@@ -215,17 +245,31 @@ class Project < Thor
215
245
  template File.join('ruby','Gemfile.erb'), File.join(dest_folder,"Gemfile")
216
246
  template File.join('ruby','config.droiuby.erb'), File.join(dest_folder,"config.droiuby")
217
247
  template File.join('ruby','gitignore.erb'), File.join(dest_folder,".gitignore")
218
- template File.join('ruby','index.xml.erb'), File.join(dest_folder,"app","views","index.xml")
248
+
249
+ if type == 'droiuby'
250
+ template File.join('ruby','index.xml.erb'), File.join(dest_folder,"app","views","index.xml")
251
+ end
252
+
219
253
  template File.join('ruby','application.css.erb'), File.join(dest_folder,"app","views","styles","application.css")
220
- template File.join('ruby','index.rb.erb'), File.join(dest_folder,"app","activities","index.rb")
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
221
259
  template File.join('ruby','index_spec.rb.erb'), File.join(dest_folder,"spec","activities","index_spec.rb")
222
260
  template File.join('ruby','spec_helper.rb.erb'), File.join(dest_folder,"spec","spec_helper.rb")
223
261
 
224
262
  empty_directory File.join(dest_folder,"lib")
225
- say "running bundle install"
263
+
226
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"
227
270
  `bundle install`
228
- bundle
271
+
272
+
229
273
  end
230
274
 
231
275
  desc "package NAME [WORKSPACE_DIR] [true|false]","package a project"
@@ -0,0 +1,10 @@
1
+ #droiuby ruby script
2
+ class Index < Activity
3
+ def on_create
4
+ set_content_view(_R('R.layout.index'))
5
+ end
6
+
7
+ def on_activity_result(request_code, result_code, intent)
8
+ #callback from starting an activity with result
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ def _current_app
2
+ $mock_environment.current_app
3
+ end
4
+
5
+ def V(selector = nil)
6
+ end
@@ -2,13 +2,43 @@ $:.unshift Dir.pwd
2
2
 
3
3
  require File.join(File.dirname(__FILE__),'loader')
4
4
  $autoload_path << File.join('app','activities')
5
+ $working_directory = Dir.pwd
5
6
 
7
+ Dir[File.join("#{File.dirname(__FILE__)}",'mock_objects','java_classes',"*.rb")].each {|f| require f}
8
+ Dir[File.join("#{File.dirname(__FILE__)}",'mock_objects',"*.rb")].each {|f| require f}
9
+
10
+
11
+ class Java
12
+
13
+ class Stubber
14
+ def RubyContainerPayload
15
+ MockObjects::JavaClasses::RubyContainerPayload.new
16
+ end
17
+ end
18
+
19
+ def self.droiuby
20
+ self
21
+ end
22
+
23
+ def self.client
24
+ self
25
+ end
26
+
27
+ def self.core
28
+ Stubber.new
29
+ end
30
+
31
+ def self.com
32
+ self
33
+ end
34
+
35
+ end
6
36
 
7
37
  #Droiuby Mock Framework class
8
38
  class DroiubyFramework
9
39
 
10
40
  def before_activity_setup
11
- fname = "#{File.dirname(__FILE__)}/../bootstrap.rb"
41
+ fname = "#{File.dirname(__FILE__)}/bootstrap.rb"
12
42
  @bootstrap = @bootstrap || File.read(fname)
13
43
  eval(@bootstrap, TOPLEVEL_BINDING, fname, __LINE__)
14
44
  end
@@ -59,3 +89,23 @@ class DroiubyFramework
59
89
  end
60
90
 
61
91
  $framework = DroiubyFramework.new
92
+
93
+ def set_mock_environment(environment = nil)
94
+ puts "new environment"
95
+ if environment.nil?
96
+ doc = Nokogiri.XML(File.read('config.droiuby'))
97
+
98
+ title = ''
99
+ params = {}
100
+ doc.css('app_descriptor').tap do |e|
101
+ %w[name description base_url main framework].each do |attr|
102
+ params[attr.to_sym] = e.css(attr).first.content
103
+ end
104
+ end
105
+
106
+ $mock_environment = MockEnvironment.new(params)
107
+ else
108
+ $mock_environment = environment
109
+ end
110
+ $mock_environment
111
+ end
@@ -1,11 +1,7 @@
1
1
  class DroiubyApp
2
2
 
3
- def initialize(working_directory = nil)
4
- @working_directory = working_directory
5
- end
3
+ def getWorkingDirectory
4
+ $working_directory
5
+ end
6
6
 
7
- def getWorkingDirectory
8
- @working_directory
9
- end
10
-
11
7
  end
@@ -0,0 +1,9 @@
1
+ module MockObjects
2
+ module JavaClasses
3
+
4
+ class ExecutionBundle
5
+
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ module MockObjects
2
+ module JavaClasses
3
+
4
+ class RubyContainerPayload
5
+
6
+ def java_method(method, params)
7
+ puts "method #{method} : #{params.inspect}"
8
+ end
9
+
10
+ def getExecutionBundle
11
+ MockObjects::JavaClasses::ExecutionBundle.new
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ module MockObjects
2
+ module JavaClasses
3
+
4
+ class View
5
+ attr_accessor :id, :tag, :view_type
6
+
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,36 @@
1
+ class MockEnvironment
2
+
3
+ attr_accessor :current_app, :app_name, :base_url, :main_url
4
+
5
+ def initialize(params = {})
6
+ @current_app = DroiubyApp.new
7
+ @app_name = params[:app_name] || ''
8
+ @base_url = params[:base_url] || ''
9
+ @main_url = params[:main_url] || ''
10
+ @mock_view_heirarchy = []
11
+ end
12
+
13
+ def before_setup(activity_instance, template)
14
+ if (activity_instance.kind_of? Activity)
15
+ $framework.before_activity_setup
16
+ else
17
+ doc = Nokogiri.XML(File.read(template))
18
+
19
+ doc.css('app_descriptor name').each do |element|
20
+ title = element.content
21
+ end
22
+
23
+ end
24
+ end
25
+
26
+ def on_create(activity_instance, refresh = false)
27
+ skip_content_view = if activity_instance.respond_to? :before_content_render
28
+ activity_instance.before_content_render unless refresh
29
+ end
30
+
31
+ set_content_view unless skip_content_view
32
+
33
+ instance.on_create
34
+ instance
35
+ end
36
+ end
@@ -0,0 +1,6 @@
1
+ class MockTemplateParser
2
+ def initialize(template_name)
3
+ @template_name = tempate_name
4
+ @xml_content = Nokogiri.XML(File.read('config.droiuby'))
5
+ end
6
+ 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
4
+ version: 0.3.5
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-03-27 00:00:00.000000000 Z
11
+ date: 2014-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -115,13 +115,20 @@ files:
115
115
  - lib/droiuby/scripts/templates/ruby/application.css.erb
116
116
  - lib/droiuby/scripts/templates/ruby/config.droiuby.erb
117
117
  - lib/droiuby/scripts/templates/ruby/gitignore.erb
118
+ - lib/droiuby/scripts/templates/ruby/index-hybrid.rb.erb
118
119
  - lib/droiuby/scripts/templates/ruby/index.rb.erb
119
120
  - lib/droiuby/scripts/templates/ruby/index.xml.erb
120
121
  - lib/droiuby/scripts/templates/ruby/index_spec.rb.erb
121
122
  - lib/droiuby/scripts/templates/ruby/spec_helper.rb.erb
123
+ - lib/droiuby/spec/bootstrap.rb
122
124
  - lib/droiuby/spec/helper.rb
123
125
  - lib/droiuby/spec/loader.rb
124
126
  - lib/droiuby/spec/mock_objects/droiuby_app.rb
127
+ - lib/droiuby/spec/mock_objects/java_classes/execution_bundle.rb
128
+ - lib/droiuby/spec/mock_objects/java_classes/ruby_container_payload.rb
129
+ - lib/droiuby/spec/mock_objects/java_classes/view.rb
130
+ - lib/droiuby/spec/mock_objects/mock_environment.rb
131
+ - lib/droiuby/spec/mock_objects/mock_template_parser.rb
125
132
  - lib/droiuby/spec/mock_objects/system_wrapper.rb
126
133
  - lib/droiuby/support/asset.rb
127
134
  - lib/droiuby/support/autoload.rb