Class: MetaModel::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/metamodel/config.rb

Overview

Stores the global configuration of MetaModel.

Defined Under Namespace

Modules: Mixin

Constant Summary collapse

DEFAULTS =
{
  :verbose             => true,
  :silent              => false,
  :skip_build          => false,
}

Initialization collapse

Paths collapse

Singleton collapse

Instance Attribute Summary collapse

UI collapse

Paths collapse

Class Attribute Details

.instanceConfig

Returns the current config instance creating one if needed.

Returns:

  • (Config)

    the current config instance creating one if needed.



130
131
132
# File 'lib/metamodel/config.rb', line 130

def self.instance
  @instance ||= new
end

Instance Attribute Details

#installation_rootPathname Also known as: project_root

Returns the root of the MetaModel installation where the meta folder is located.

Returns:

  • (Pathname)

    the root of the MetaModel installation where the meta folder is located.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/metamodel/config.rb', line 49

def installation_root
  current_dir = ActiveSupport::Multibyte::Unicode.normalize(Dir.pwd)
  current_path = Pathname.new(current_dir)
  unless @installation_root
    until current_path.root?
      if metafile_in_dir(current_path)
        @installation_root = current_path
        break
      else
        current_path = current_path.parent
      end
    end
    @installation_root ||= Pathname.pwd
  end
  @installation_root
end

#skip_buildObject Also known as: skip_build?

Returns the value of attribute skip_build.



16
17
18
# File 'lib/metamodel/config.rb', line 16

def skip_build
  @skip_build
end

#verboseObject



27
28
29
# File 'lib/metamodel/config.rb', line 27

def verbose
  @verbose
end

Instance Method Details

#metafileObject



118
119
120
# File 'lib/metamodel/config.rb', line 118

def metafile
  @metafile ||= Metafile.from_file(metafile_path) if metafile_path
end

#metafile_in_dir(dir) ⇒ Pathname, Nil

Returns the path of the Metafile in the given dir if any exists.

Parameters:

  • dir (Pathname)

    The directory where to look for the meta.

Returns:

  • (Pathname)

    The path of the metafile.

  • (Nil)

    If not meta was found in the given dir



110
111
112
113
114
115
116
# File 'lib/metamodel/config.rb', line 110

def metafile_in_dir(dir)
  candidate = dir + 'Metafile'
  if candidate.exist?
    return candidate
  end
  nil
end

#metafile_pathPathname, Nil

Returns the path of the Metafile.

Returns:

  • (Pathname)
  • (Nil)


98
99
100
# File 'lib/metamodel/config.rb', line 98

def metafile_path
  @metafile_in_dir ||= installation_root + 'Metafile'
end

#metamodel_template_uriString

Returns the path of the metamodel template uri.

Returns:

  • (String)


73
74
75
# File 'lib/metamodel/config.rb', line 73

def metamodel_template_uri
  "[email protected]:MModel/MetaModel-Template.git"
end

#metamodel_xcode_projectString

Returns the path of the MetaModel.xcodeproj.

Returns:

  • (String)


81
82
83
# File 'lib/metamodel/config.rb', line 81

def metamodel_xcode_project
  "./metamodel/MetaModel.xcodeproj"
end

#metefile_exist?Bool

Returns whether or not metafile is in current project.

Returns:

  • (Bool)


89
90
91
# File 'lib/metamodel/config.rb', line 89

def metefile_exist?
  Pathname.new(metafile_path).exist?
end

#verbose?Bool

Returns Whether CocoaPods should provide detailed output about the performed actions.

Returns:

  • (Bool)

    Whether CocoaPods should provide detailed output about the performed actions.



28
29
30
# File 'lib/metamodel/config.rb', line 28

def verbose
  @verbose
end