Class: Gena::Config
- Inherits:
-
Object
- Object
- Gena::Config
- Defined in:
- lib/config/config.rb
Class Method Summary collapse
Instance Method Summary collapse
- #collapse_to_project(path) ⇒ Object
- #data ⇒ Object
- #data=(new_data) ⇒ Object
- #data_without_plugins ⇒ Object
- #expand_to_project(path) ⇒ Object
- #header_dir ⇒ Object
- #load_plist_config ⇒ Object
- #project_dir ⇒ Object
- #save! ⇒ Object
- #sources_dir ⇒ Object
- #tests_dir ⇒ Object
- #xcode_project_path ⇒ Object
Class Method Details
.create ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/config/config.rb', line 13 def Config.create hash = Hash.new hash[:plugins_url] = [ '~/Development/gena-plugins' ] hash['sources_dir'] = '/Users/alex/Development/fisho-ios/Sources' File.open('gena.plist', 'w') { |f| f.write hash.to_plist } end |
.exists? ⇒ Boolean
9 10 11 |
# File 'lib/config/config.rb', line 9 def Config.exists? File.exists?('gena.plist') end |
Instance Method Details
#collapse_to_project(path) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/config/config.rb', line 63 def collapse_to_project(path) if path[0] == '/' path = path.dup path["#{$config.project_dir}/"] = '' end path end |
#data ⇒ Object
31 32 33 |
# File 'lib/config/config.rb', line 31 def data @data end |
#data=(new_data) ⇒ Object
35 36 37 |
# File 'lib/config/config.rb', line 35 def data=(new_data) @data = new_data end |
#data_without_plugins ⇒ Object
39 40 41 |
# File 'lib/config/config.rb', line 39 def data_without_plugins @data.reject { |k, v| k == GENA_PLUGINS_CONFIG_KEY } end |
#expand_to_project(path) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/config/config.rb', line 55 def (path) if path[0] == '/' path else File.join(self.project_dir, path) end end |
#header_dir ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/config/config.rb', line 43 def header_dir if @data['header'] && !@data['header'].empty? (@data['header']) else '' end end |
#load_plist_config ⇒ Object
27 28 29 |
# File 'lib/config/config.rb', line 27 def load_plist_config @data = Plist::parse_xml('gena.plist') end |
#project_dir ⇒ Object
51 52 53 |
# File 'lib/config/config.rb', line 51 def project_dir File.((!self.data['project_dir'] || self.data['project_dir'].empty?)? '.' : self.data['project_dir']) end |
#save! ⇒ Object
23 24 25 |
# File 'lib/config/config.rb', line 23 def save! File.open('gena.plist', 'w') { |f| f.write self.data.to_plist } end |
#sources_dir ⇒ Object
71 72 73 |
# File 'lib/config/config.rb', line 71 def sources_dir self.(self.data['sources_dir']) end |
#tests_dir ⇒ Object
75 76 77 |
# File 'lib/config/config.rb', line 75 def tests_dir self.(self.data['tests_dir']) end |
#xcode_project_path ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/config/config.rb', line 79 def xcode_project_path path = self.("#{@data['project_name']}.xcodeproj") unless File.exists? path say "Can't find project with name '#{@data['project_name']}.xcodeproj''", Color::RED abort end path end |