Class: Pod::X::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-x/extension/configure.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_url, project_debug_url) ⇒ Configurator

Returns a new instance of Configurator.



39
40
41
# File 'lib/cocoapods-x/extension/configure.rb', line 39

def initialize project_url, project_debug_url
    @conf = { 'project_url' => project_url.to_s, 'project_debug_url' => project_debug_url.to_s }
end

Instance Attribute Details

#confObject (readonly)

Returns the value of attribute conf.



37
38
39
# File 'lib/cocoapods-x/extension/configure.rb', line 37

def conf
  @conf
end

Class Method Details

.create_conf!(project_url) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cocoapods-x/extension/configure.rb', line 21

def self.create_conf! project_url
    name = File.basename(project_url)
    projects = Pod::X::Sandbox::workspace::projects
    for index in 0..10000
        if index == 0 
            project_debug_url = projects::root + name
        else
            project_debug_url = projects::root + "#{name}@#{index}"
        end
        unless project_debug_url.exist?
            break
        end
    end
    Pod::X::Configurator::new project_url, project_debug_url
end

.find_conf?(project_url) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cocoapods-x/extension/configure.rb', line 7

def self.find_conf? project_url
    projects = Pod::X::Sandbox::workspace::projects
    for project_debug_url in Dir.glob(projects::root + '*') do
        conf = Pod::X::Configurator::new project_url, project_debug_url
        if conf.verify?
            break
        end
    end
    if conf.nil? || !conf.verify?
        conf = nil
    end
    conf
end

Instance Method Details

#project_debug_urlObject



51
52
53
# File 'lib/cocoapods-x/extension/configure.rb', line 51

def project_debug_url
    @conf['project_debug_url']
end

#project_urlObject



47
48
49
# File 'lib/cocoapods-x/extension/configure.rb', line 47

def project_url
    @conf['project_url']
end

#save!Object



77
78
79
80
# File 'lib/cocoapods-x/extension/configure.rb', line 77

def save!
    return nil if verify?
    File.write(url, @conf.to_json)
end

#syncObject



68
69
70
71
72
73
74
75
# File 'lib/cocoapods-x/extension/configure.rb', line 68

def sync
    begin json = JSON.parse(File.read(url))
    rescue => exception
    end
    unless json.nil?
        @conf = json.merge(@conf)
    end
end

#urlObject



43
44
45
# File 'lib/cocoapods-x/extension/configure.rb', line 43

def url
    File.join(project_debug_url, '.conf')
end

#verify?Boolean

Returns:

  • (Boolean)


55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cocoapods-x/extension/configure.rb', line 55

def verify?
    valid = false
    unless url.nil? || project_url.nil? || project_debug_url.nil?
        if File.exist?(url) && File.exist?(project_url) && File.exist?(project_debug_url)
            begin json = JSON.parse(File.read(url))
            rescue => exception 
            end
            valid = @conf == json
        end
    end
    valid
end