Class: Mate::Tmproj
- Inherits:
-
Object
- Object
- Mate::Tmproj
- Defined in:
- lib/mate/tmproj.rb
Defined Under Namespace
Classes: Ignores
Constant Summary collapse
- TMPROJ_DIR =
Pathname('~'). + '.tmprojs'
Instance Attribute Summary collapse
-
#dirs ⇒ Object
readonly
Returns the value of attribute dirs.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(dirs) ⇒ Tmproj
constructor
A new instance of Tmproj.
- #open ⇒ Object
Constructor Details
#initialize(dirs) ⇒ Tmproj
Returns a new instance of Tmproj.
10 11 12 13 14 15 16 |
# File 'lib/mate/tmproj.rb', line 10 def initialize(dirs) @dirs = dirs.map{ |dir| Pathname(dir). } @file = TMPROJ_DIR + [ Digest::SHA256.hexdigest(@dirs.join('-').downcase), "#{common_dir(@dirs).basename}.tmproj" ].join('/') end |
Instance Attribute Details
#dirs ⇒ Object (readonly)
Returns the value of attribute dirs.
9 10 11 |
# File 'lib/mate/tmproj.rb', line 9 def dirs @dirs end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
9 10 11 |
# File 'lib/mate/tmproj.rb', line 9 def file @file end |
Instance Method Details
#open ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mate/tmproj.rb', line 18 def open data = Plist::parse_xml(file) rescue {} data['documents'] = dirs.map do |dir| ignores = Ignores.new(dir) { :expanded => true, :name => dir.basename.to_s, :regexFileFilter => "!#{ignores.file_r}", :regexFolderFilter => "!#{ignores.folder_r}", :sourceDirectory => dir.to_s } end data['fileHierarchyDrawerWidth'] ||= 269 data['metaData'] ||= {} data['showFileHierarchyDrawer'] = true unless data.has_key?('showFileHierarchyDrawer') dimensions = IO.popen(%q{osascript -e 'tell application "Finder" to get bounds of window of desktop'}, &:read).scan(/\d+/).map(&:to_i) data['windowFrame'] ||= "{{#{dimensions[0] + 100}, #{dimensions[1] + 50}}, {#{dimensions[2] - 200}, #{dimensions[3] - 100}}}" file.dirname.mkpath file.open('w'){ |f| f.write(data.to_plist) } system 'open', file.to_s end |