Module: Offroad

Defined in:
lib/version.rb,
lib/exceptions.rb,
lib/mirror_data.rb,
lib/view_helper.rb,
lib/module_funcs.rb,
lib/cargo_streamer.rb,
lib/model_extensions.rb,
lib/controller_extensions.rb,
lib/app/models/offroad/group_state.rb,
lib/app/models/offroad/mirror_info.rb,
lib/app/models/offroad/model_state.rb,
lib/app/models/offroad/system_state.rb,
lib/app/models/offroad/received_record_state.rb,
lib/app/models/offroad/sendable_record_state.rb

Defined Under Namespace

Modules: ControllerExtensions, ModelExtensions, ViewHelper Classes: AppModeUnknownError, CargoStreamer, CargoStreamerError, DataError, GroupState, MirrorData, MirrorInfo, ModelError, ModelState, OldDataError, PluginError, ReceivedRecordState, SendableRecordState, SystemState

Constant Summary collapse

VERSION =
"0.0.3"
@@app_online_flag =
nil
@@group_base_model =
nil
@@global_data_models =
{}
@@group_owned_models =
{}
@@group_single_models =
{}

Class Method Summary collapse

Class Method Details

.app_offline?Boolean

Returns true if the app is in offline mode (running on a local system without access to the main server)

Returns:

  • (Boolean)


15
16
17
# File 'lib/module_funcs.rb', line 15

def self.app_offline?
  not app_online?
end

.app_online?Boolean

Returns true if the app is in online mode (or in other words, this is the main server)

Returns:

  • (Boolean)


20
21
22
23
24
25
26
# File 'lib/module_funcs.rb', line 20

def self.app_online?
  case @@app_online_flag
    when true then true
    when false then false
    else raise AppModeUnknownError.new
  end
end

.app_versionObject

Returns a Time that identifies the version of the app Specifically, the modification timestamp (on the online app) of the most recently modified source file in the app



30
31
32
33
34
35
# File 'lib/module_funcs.rb', line 30

def self.app_version
  # TODO Implement
  # Online - When app is launched, scan all application files, returns the Time of the most recently changed file
  # Offline - Based on the app version noted in the last down-mirror file successfully loaded
  return 1
end

.config_app_online(flag) ⇒ Object

Used in the environment configuration file to set the app to online or offline mode. This should not be called from within the app.



10
11
12
# File 'lib/module_funcs.rb', line 10

def self.config_app_online(flag)
  @@app_online_flag = flag
end

.initObject

:nodoc#



38
39
40
# File 'lib/module_funcs.rb', line 38

def self.init
  @@config = YAML.load_file(File.join(RAILS_ROOT, "config", "offroad.yml"))
end

.offline_groupObject

Returns the record of the group base model that this app is in charge of This is only applicable if the app is offline

Raises:



44
45
46
47
# File 'lib/module_funcs.rb', line 44

def self.offline_group
  raise PluginError.new("'Offline group' is only meaningful if the app is offline") unless app_offline?
  group_base_model.first
end