Class: Nesta::Commands::Demo::Content

Inherits:
Object
  • Object
show all
Includes:
Command
Defined in:
lib/nesta/commands.rb

Instance Method Summary (collapse)

Methods included from Command

#copy_template, #copy_templates, #fail, #run_process, #template_root, #update_config_yaml

Constructor Details

- (Content) initialize(*args)



138
139
140
# File 'lib/nesta/commands.rb', line 138

def initialize(*args)
  @dir = 'content-demo'
end

Instance Method Details

- (Object) clone_or_update_repository



142
143
144
145
146
147
148
149
150
# File 'lib/nesta/commands.rb', line 142

def clone_or_update_repository
  repository = 'git://github.com/gma/nesta-demo-content.git'
  path = Nesta::Path.local(@dir)
  if File.exist?(path)
    FileUtils.cd(path) { run_process('git', 'pull', 'origin', 'master') }
  else
    run_process('git', 'clone', repository, path)
  end
end

- (Object) configure_git_to_ignore_repo



152
153
154
155
156
157
# File 'lib/nesta/commands.rb', line 152

def configure_git_to_ignore_repo
  excludes = Nesta::Path.local('.git/info/exclude')
  if File.exist?(excludes) && File.read(excludes).scan(@dir).empty?
    File.open(excludes, 'a') { |file| file.puts @dir }
  end
end

- (Object) execute



159
160
161
162
163
# File 'lib/nesta/commands.rb', line 159

def execute
  clone_or_update_repository
  configure_git_to_ignore_repo
  update_config_yaml(/^\s*#?\s*content:.*/, "content: #{@dir}")
end