Class: Pod::Extension::Configurator
- Inherits:
-
Object
- Object
- Pod::Extension::Configurator
- Defined in:
- lib/cocoapods-extension/configure.rb
Instance Attribute Summary collapse
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(project_url, project_debug_url) ⇒ Configurator
constructor
A new instance of Configurator.
- #project_debug_url ⇒ Object
- #project_url ⇒ Object
- #save! ⇒ Object
- #sync ⇒ Object
- #url ⇒ Object
- #verify? ⇒ Boolean
Constructor Details
#initialize(project_url, project_debug_url) ⇒ Configurator
Returns a new instance of Configurator.
34 35 36 |
# File 'lib/cocoapods-extension/configure.rb', line 34 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
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
32 33 34 |
# File 'lib/cocoapods-extension/configure.rb', line 32 def conf @conf end |
Class Method Details
.create_conf!(project_url) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cocoapods-extension/configure.rb', line 21 def self.create_conf! project_url index = 0 name = File.basename(project_url) projects = Pod::Extension::Sandbox::workspace::projects begin project_debug_url = projects::root + "#{name}@#{index}" index += 1 end while project_debug_url.exist? Pod::Extension::Configurator::new project_url, project_debug_url end |
.find_conf?(project_url) ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cocoapods-extension/configure.rb', line 7 def self.find_conf? project_url projects = Pod::Extension::Sandbox::workspace::projects for project_debug_url in Dir.glob(projects::root + '*') do conf = Pod::Extension::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_url ⇒ Object
46 47 48 |
# File 'lib/cocoapods-extension/configure.rb', line 46 def project_debug_url @conf['project_debug_url'] end |
#project_url ⇒ Object
42 43 44 |
# File 'lib/cocoapods-extension/configure.rb', line 42 def project_url @conf['project_url'] end |
#save! ⇒ Object
72 73 74 75 |
# File 'lib/cocoapods-extension/configure.rb', line 72 def save! return nil if verify? File.write(url, @conf.to_json) end |
#sync ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/cocoapods-extension/configure.rb', line 63 def sync begin json = JSON.parse(File.read(url)) rescue => exception end unless json.nil? @conf = json.merge(@conf) end end |
#url ⇒ Object
38 39 40 |
# File 'lib/cocoapods-extension/configure.rb', line 38 def url File.join(project_debug_url, '.conf') end |
#verify? ⇒ Boolean
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cocoapods-extension/configure.rb', line 50 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 |