Class: Pandora::Models::App

Inherits:
Object
  • Object
show all
Defined in:
lib/pandora/models/app.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, project_path, workspace_path, target_name, test_target_name, dependencies) ⇒ App

Initializes an App.

Parameters:

  • application (String)

    name.

  • project (String)

    path.

  • workspace (String)

    path.

  • application (String)

    main target name.

  • application (String)

    main tests target name.

  • dependencies. (String)

Raises:

  • (StandardError)

    if any of the attributes has a wrong format.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pandora/models/app.rb', line 32

def initialize(name, project_path, workspace_path, target_name, test_target_name, dependencies)
  @name = name
  @project_path = project_path
  raise "Wrong project path. It should be a .xcodeproj" unless @project_path.include?(".xcodeproj")
  @workspace_path = workspace_path
  raise "Wrong workspace path. It should be a .xcworkspace" unless @workspace_path.include?(".xcworkspace")
  @target_name = target_name
  @test_target_name = test_target_name
  @dependencies = dependencies
  raise "Dependencies must be an array" unless @dependencies.kind_of? Array
end

Instance Attribute Details

#dependenciesObject (readonly)

Application dependencies



21
22
23
# File 'lib/pandora/models/app.rb', line 21

def dependencies
  @dependencies
end

#nameObject (readonly)

Application name



6
7
8
# File 'lib/pandora/models/app.rb', line 6

def name
  @name
end

#project_pathObject (readonly)

Project directory (.xcodeproj)



9
10
11
# File 'lib/pandora/models/app.rb', line 9

def project_path
  @project_path
end

#target_nameObject (readonly)

Application target name



15
16
17
# File 'lib/pandora/models/app.rb', line 15

def target_name
  @target_name
end

#test_target_nameObject (readonly)

Application test target name



18
19
20
# File 'lib/pandora/models/app.rb', line 18

def test_target_name
  @test_target_name
end

#workspace_pathObject (readonly)

Workspace directory (.xcworkspace)



12
13
14
# File 'lib/pandora/models/app.rb', line 12

def workspace_path
  @workspace_path
end

Class Method Details

.from_yml(name, yml) ⇒ App

Initializes an App from a YAML hash.

Parameters:

  • application (String)

    name.

  • hash (Hash)

    that represents the app.

Returns:

  • (App)

    initialized App.

Raises:

  • (StandardError)

    if any of the required attributes are missing (project_path, workspace_path, target_name)



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/pandora/models/app.rb', line 49

def self.from_yml(name, yml)
  project_path = yml["project_path"]
  raise "The app #{name} doesn't include project_path attribute" unless project_path
  workspace_path = yml["workspace_path"]
  raise "The app #{name} doesn't include workspace_path attribute" unless workspace_path
  target_name = yml["target_name"]
  raise "The app #{name} doesn't include target_name attribute" unless target_name
  test_target_name = yml["test_target_name"]
  dependencies = yml["dependencies"]
  dependencies ||= []
  App.new(name, project_path, workspace_path, target_name, test_target_name, dependencies)
end