Module: RhoDevelopment

Defined in:
lib/build/rhoDevelopment.rb,
lib/build/development/network.rb,
lib/build/development/platform.rb,
lib/build/development/subscriber.rb,
lib/build/development/web_server.rb,
lib/build/development/auto_updater.rb,
lib/build/development/build_server.rb,
lib/build/development/configuration.rb,
lib/build/development/device_finder.rb,
lib/build/development/live_update_task.rb

Defined Under Namespace

Classes: Alive, AllPlatformsFullBundleBuildingTask, AllPlatformsPartialBundleBuildingTask, AllSubscribersFullUpdateNotifyingTask, AllSubscribersPartialUpdateNotifyingTask, AutoUpdatePID, AutoUpdater, BuildServer, Configuration, DeviceFinder, LiveUpdateTask, Network, NewTask, PartialUpdateTask, Platform, PlatformPartialUpdateBuildingTask, ResponseFromDevice, RhofilelistItem, RhofilelistLoader, Shutdown, Subscriber, SubscriberFullBundleUpdateBuildingTask, SubscriberFullUpdateNotifyingTask, SubscriberPartialUpdateNotifyingTask, WebServer

Class Method Summary collapse

Class Method Details

.check_changes_from_last_build(add_file_path, remove_file_path) ⇒ Object



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/build/rhoDevelopment.rb', line 227

def check_changes_from_last_build(add_file_path, remove_file_path)

  has_changes = false

  currentdir = Dir.pwd()

  make_full_bundle

  #extract file with hashes
  tmp_folder = File.join($tmpdir, 'development')
  rm_rf tmp_folder
  mkdir_p tmp_folder

  current_state_file = File.join(tmp_folder, 'current_state_file.txt')

  full_bundle_path = get_full_bundle_zip_path

  extract_state_file_from_bundle_zip(full_bundle_path, current_state_file)

  old_state_file = get_last_state_file_path

  if !(File.exist? get_last_state_file_path)
    has_changes = nil
  end

  if has_changes == nil
    rm_rf get_last_state_file_path if File.exist? get_last_state_file_path
    cp current_state_file, get_last_state_file_path
    return has_changes
  end

  old_array = RhofilelistLoader.loadFromFile(old_state_file)
  current_array = RhofilelistLoader.loadFromFile(current_state_file)

  rm_rf get_last_state_file_path if File.exist? get_last_state_file_path
  cp current_state_file, get_last_state_file_path

  add_array = []
  remove_array = []
  has_changes = extract_changes(old_array, current_array, add_array, remove_array)

  if has_changes
     # save add and remove

     rm_rf add_file_path if File.exist? add_file_path
     rm_rf remove_file_path if File.exist? remove_file_path

     File.open(add_file_path, 'w') { |file|
        add_array.each { |each| file.puts(each) }
     }
     File.open(remove_file_path, 'w') { |file|
        remove_array.each { |each| file.puts(each) }
     }

  end

  rm_rf tmp_folder

  Dir.chdir currentdir

  return has_changes
end

.extract_changes(old_items, new_items, added_files, removed_files) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/build/rhoDevelopment.rb', line 174

def extract_changes(old_items, new_items, added_files, removed_files)

  new_items.each do |new_item|
    if !(old_items.any? { |each| each == new_item })
      added_files << new_item.fixed_path
    end
  end

  old_items.each do |old_item|
    if !(new_items.any? { |each| each.path == old_item.path })
      removed_files << old_item.fixed_path
    end
  end

  return ((not added_files.empty?) || (not removed_files.empty?))

end

.extract_item_path(item) ⇒ Object



162
163
164
165
166
167
168
169
170
171
# File 'lib/build/rhoDevelopment.rb', line 162

def extract_item_path(item)
  if item == nil
     return nil
  end
  item_tokenized = item.split('|')
  if item_tokenized.size >= 1
    return item_tokenized[0]
  end
  return nil
end

.extract_item_type(item) ⇒ Object

file,dir,nil



150
151
152
153
154
155
156
157
158
159
# File 'lib/build/rhoDevelopment.rb', line 150

def extract_item_type(item)
  if item == nil
     return nil
  end
  item_tokenized = item.split('|')
  if item_tokenized.size >= 2
    return item_tokenized[1]
  end
  return nil
end

.extract_state_file_from_bundle_zip(zip_path, path_for_save_state_file) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/build/rhoDevelopment.rb', line 194

def extract_state_file_from_bundle_zip(zip_path, path_for_save_state_file)

  currentdir = Dir.pwd()

  tmp_folder = File.join($tmpdir, 'development', 'tmp')
  mkdir_p tmp_folder

  chdir tmp_folder

  Jake.unzip(zip_path, tmp_folder)

  state_path = File.join(tmp_folder, 'RhoBundle','apps', 'rhofilelist.txt')

  rm_rf path_for_save_state_file if File.exist? path_for_save_state_file

  cp state_path, path_for_save_state_file

  rm_rf tmp_folder

  Dir.chdir currentdir
end

.get_full_bundle_zip_pathObject



217
218
219
# File 'lib/build/rhoDevelopment.rb', line 217

def get_full_bundle_zip_path
  return File.join($targetdir, "upgrade_bundle.zip")
end

.get_last_state_file_pathObject



134
135
136
# File 'lib/build/rhoDevelopment.rb', line 134

def get_last_state_file_path
  return File.join($RhoDevelopmentSettingsFolder, "last_build_content_state.#{$RhoDevelopmentPlatform}.txt")
end

.get_partial_bundle_zip_pathObject



222
223
224
# File 'lib/build/rhoDevelopment.rb', line 222

def get_partial_bundle_zip_path
  return File.join($targetdir, "upgrade_bundle_partial.zip")
end

.get_platformObject



129
130
131
# File 'lib/build/rhoDevelopment.rb', line 129

def get_platform
  return $RhoDevelopmentPlatform
end

.get_settings_folderObject



124
125
126
# File 'lib/build/rhoDevelopment.rb', line 124

def get_settings_folder
  return $RhoDevelopmentSettingsFolder
end

.is_require_full_updateObject



291
292
293
# File 'lib/build/rhoDevelopment.rb', line 291

def is_require_full_update
  return !(File.exist? get_last_state_file_path)
end

.make_full_bundleObject



139
140
141
# File 'lib/build/rhoDevelopment.rb', line 139

def make_full_bundle
  system("rake build:#{$RhoDevelopmentPlatform}:upgrade_package")
end

.make_partial_bundleObject



144
145
146
# File 'lib/build/rhoDevelopment.rb', line 144

def make_partial_bundle
  system("rake build:#{$RhoDevelopmentPlatform}:upgrade_package_partial")
end

.setup(settings_folder_path, platform) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/build/rhoDevelopment.rb', line 102

def setup(settings_folder_path, platform)

  puts 'RhoDevelopment.setup('+platform.to_s+')'

  $RhoDevelopmentSettingsFolder = settings_folder_path
  $RhoDevelopmentPlatform = platform

  $current_platform = platform
  $sdk = nil
  Rake::Task['config:common'].reenable
  Rake::Task['config:common'].invoke

  #disable checking XCode in config:iphone - it required for working on Win platfrom or on MAc OS without XCode
  $skip_checking_XCode = true
  $skip_checking_Android_SDK = true

  Rake::Task["config:#{$RhoDevelopmentPlatform}"].reenable
  Rake::Task["config:#{$RhoDevelopmentPlatform}"].invoke

end