Class: ClearcaseHelper::View
- Inherits:
-
Object
- Object
- ClearcaseHelper::View
- Includes:
- Executables
- Defined in:
- lib/clearcase_helper/view.rb
Instance Attribute Summary collapse
-
#identity_map ⇒ Object
readonly
Returns the value of attribute identity_map.
-
#view_path ⇒ Object
readonly
Returns the value of attribute view_path.
Instance Method Summary collapse
- #add_view_only_files!(options = {}) ⇒ Object
- #all_files_with_status(refresh = false, options = {}) ⇒ Object
- #checkedout_files(refresh = false, options = {}) ⇒ Object
- #checkin_checkedout!(options = {}) ⇒ Object
- #checkin_hijacked!(options = {}) ⇒ Object
- #checkout_highjacked!(options = {}) ⇒ Object
- #file_for(file, options = {}) ⇒ CCFile
- #files(refresh = false, options = {}) ⇒ Object
-
#forget_file(file) ⇒ CCFile
Removes given file from this views identity map.
- #hijacked_files(refresh = false, options = {}) ⇒ Object
-
#initialize(view_path) ⇒ View
constructor
A new instance of View.
- #make_label(label, options = {}) ⇒ Object
- #make_label_type(label, options = {}) ⇒ Object
- #missing_files(refresh = false, options = {}) ⇒ Object
- #remove_missing_files!(options = {}) ⇒ Object
- #view_only_files(refresh = false, options = {}) ⇒ Object
Methods included from Executables
Constructor Details
#initialize(view_path) ⇒ View
Returns a new instance of View.
8 9 10 |
# File 'lib/clearcase_helper/view.rb', line 8 def initialize(view_path) @view_path = view_path end |
Instance Attribute Details
#identity_map ⇒ Object (readonly)
Returns the value of attribute identity_map.
6 7 8 |
# File 'lib/clearcase_helper/view.rb', line 6 def identity_map @identity_map end |
#view_path ⇒ Object (readonly)
Returns the value of attribute view_path.
5 6 7 |
# File 'lib/clearcase_helper/view.rb', line 5 def view_path @view_path end |
Instance Method Details
#add_view_only_files!(options = {}) ⇒ Object
110 111 112 113 114 |
# File 'lib/clearcase_helper/view.rb', line 110 def add_view_only_files!(={}) view_only_files(false, .merge(:nostdout => true, :noop => false)).sort.each do |file| file.add!() end end |
#all_files_with_status(refresh = false, options = {}) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/clearcase_helper/view.rb', line 56 def all_files_with_status(refresh=false, ={}) show_short = ![:long] files(refresh, ).reject {|file| show_short and file.is_checkedin?}.collect do |file| "#{file.short_status} #{file}" end end |
#checkedout_files(refresh = false, options = {}) ⇒ Object
48 49 50 |
# File 'lib/clearcase_helper/view.rb', line 48 def checkedout_files(refresh=false, ={}) files(refresh, ).select {|f| f.is_checkedout?} end |
#checkin_checkedout!(options = {}) ⇒ Object
88 89 90 91 92 |
# File 'lib/clearcase_helper/view.rb', line 88 def checkin_checkedout!(={}) checkedout_files(false, .merge(:nostdout => true, :noop => false)).each do |file| file.checkin!() end end |
#checkin_hijacked!(options = {}) ⇒ Object
102 103 104 105 106 107 |
# File 'lib/clearcase_helper/view.rb', line 102 def checkin_hijacked!(={}) hijacked_files(false, .merge(:nostdout => true, :noop => false)).each do |file| file.checkout!() file.checkin!() end end |
#checkout_highjacked!(options = {}) ⇒ Object
95 96 97 98 99 |
# File 'lib/clearcase_helper/view.rb', line 95 def checkout_highjacked!(={}) hijacked_files(false, .merge(:nostdout => true, :noop => false)).each do |file| file.checkout!() end end |
#file_for(file, options = {}) ⇒ CCFile
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/clearcase_helper/view.rb', line 66 def file_for(file, ={}) file = file.to_s.strip cc_file = @identity_map[file] if cc_file.nil? && !file.empty? cc_file = @identity_map[file] = CCFile.new(file, self).refresh_status() end cc_file end |
#files(refresh = false, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/clearcase_helper/view.rb', line 12 def files(refresh=false, ={}) if @files and !refresh return @files end success, stdout = cleartool("ls -recurse #{@view_path.shellescape}", ) # load excludes from .ccignore ccignore_file = File.join(@view_path,'.ccignore') ccignore = if File.exist?(ccignore_file) File.readlines(ccignore_file).map {|ignore| ignore.strip} else %w(\.hg|\.git|\.svn) end raw_files = stdout.split(/\n/) raw_files.reject! do |f| ccignore.any? do |ignore| f.match(/#{ignore}/) end end # filter excluded files / folders @files = raw_files.map {|f| CCFile.new(f, self)} @identity_map = @files.inject({}) {|memo, file| memo[file.to_s] = file; memo} @files end |
#forget_file(file) ⇒ CCFile
Removes given file from this views identity map. Used by the remove! file action to cleanup view state on success.
83 84 85 |
# File 'lib/clearcase_helper/view.rb', line 83 def forget_file(file) @identity_map.delete(file) end |
#hijacked_files(refresh = false, options = {}) ⇒ Object
44 45 46 |
# File 'lib/clearcase_helper/view.rb', line 44 def hijacked_files(refresh=false, ={}) files(refresh, ).select {|f| f.is_hijacked?} end |
#make_label(label, options = {}) ⇒ Object
132 133 134 135 |
# File 'lib/clearcase_helper/view.rb', line 132 def make_label(label, ={}) comment = [:comment] || '' cleartool("mklabel -c \"#{comment.shellescape}\" -recurse #{label.shellescape} #{@view_path.shellescape}", ) end |
#make_label_type(label, options = {}) ⇒ Object
125 126 127 128 |
# File 'lib/clearcase_helper/view.rb', line 125 def make_label_type(label, ={}) comment = ([:comment] || '') + ": #{@view_path}" cleartool("mklbtype -c \"#{comment.shellescape}\" #{label.shellescape}", ) end |
#missing_files(refresh = false, options = {}) ⇒ Object
52 53 54 |
# File 'lib/clearcase_helper/view.rb', line 52 def missing_files(refresh=false, ={}) files(refresh, ).select {|f| f.is_missing?} end |
#remove_missing_files!(options = {}) ⇒ Object
117 118 119 120 121 |
# File 'lib/clearcase_helper/view.rb', line 117 def remove_missing_files!(={}) missing_files(false, .merge(:nostdout => true, :noop => false)).sort.reverse.each do |file| file.remove!() end end |
#view_only_files(refresh = false, options = {}) ⇒ Object
40 41 42 |
# File 'lib/clearcase_helper/view.rb', line 40 def view_only_files(refresh=false, ={}) files(refresh, ).select {|f| f.is_view_only?} end |