Class: Milkode::Updater

Inherits:
Object
  • Object
show all
Defined in:
lib/milkode/database/updater.rb

Defined Under Namespace

Classes: Result, ResultAccumulator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grndb, package_name) ⇒ Updater

Returns a new instance of Updater.



17
18
19
20
21
22
23
24
25
# File 'lib/milkode/database/updater.rb', line 17

def initialize(grndb, package_name)
  @grndb          = grndb
  @package_name   = package_name
  @package        = @grndb.packages[@package_name]
  @result         = Result.new
  @current_ignore = IgnoreChecker.new
  @options        = {}
  @out            = $stdout
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



15
16
17
# File 'lib/milkode/database/updater.rb', line 15

def result
  @result
end

Instance Method Details

#enable_display_infoObject



77
78
79
# File 'lib/milkode/database/updater.rb', line 77

def enable_display_info
  @options[:display_info] = true
end

#enable_no_auto_ignoreObject



69
70
71
# File 'lib/milkode/database/updater.rb', line 69

def enable_no_auto_ignore
  @options[:no_auto_ignore] = true
end

#enable_no_cleanObject



97
98
99
# File 'lib/milkode/database/updater.rb', line 97

def enable_no_clean
  @options[:no_clean] = true      
end

#enable_silent_modeObject



73
74
75
# File 'lib/milkode/database/updater.rb', line 73

def enable_silent_mode
  @options[:silent_mode] = true
end

#enable_update_with_ctagsObject



89
90
91
# File 'lib/milkode/database/updater.rb', line 89

def enable_update_with_ctags
  @options[:update_with_ctags] = true      
end

#enable_update_with_ctags_eObject



93
94
95
# File 'lib/milkode/database/updater.rb', line 93

def enable_update_with_ctags_e
  @options[:update_with_ctags_e] = true      
end

#enable_update_with_git_pullObject



81
82
83
# File 'lib/milkode/database/updater.rb', line 81

def enable_update_with_git_pull
  @options[:update_with_git_pull] = true      
end

#enable_update_with_svn_updateObject



85
86
87
# File 'lib/milkode/database/updater.rb', line 85

def enable_update_with_svn_update
  @options[:update_with_svn_update] = true
end

#execObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/milkode/database/updater.rb', line 27

def exec
  # git pull
  if @options[:update_with_git_pull]
    Dir.chdir(@package.directory) { system("git pull") }        
  end
  
  # svn update
  if @options[:update_with_svn_update]
    Dir.chdir(@package.directory) { system("svn update") }
  end

  # Add global .gitignore
  if @options[:global_gitignore]
    add_global_gitignore(@options[:global_gitignore])
  end

  # update
  update_dir(@package.directory)

  # cleanup
  unless @options[:no_clean]
    @grndb.documents.cleanup_package_name(@package_name, @current_ignore)
  end
  
  # ctags
  if @options[:update_with_ctags]
    Dir.chdir(@package.directory) { system("ctags -R") }
  end

  # ctags -e
  if @options[:update_with_ctags_e]
    Dir.chdir(@package.directory) { system("ctags -R -e") }
  end

  # 更新時刻の更新
  @grndb.packages.touch(@package_name, :updatetime)
end

#set_global_gitignore(filename) ⇒ Object



101
102
103
# File 'lib/milkode/database/updater.rb', line 101

def set_global_gitignore(filename)
  @options[:global_gitignore] = filename 
end

#set_package_ignore(ignore_setting) ⇒ Object



65
66
67
# File 'lib/milkode/database/updater.rb', line 65

def set_package_ignore(ignore_setting)
  @current_ignore.add ignore_setting
end