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, #template_root, #update_config_yaml

Constructor Details

- (Content) initialize(*args)

Returns a new instance of Content



125
126
127
# File 'lib/nesta/commands.rb', line 125

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

Instance Method Details

- (Object) clone_or_update_repository



129
130
131
132
133
134
135
136
137
# File 'lib/nesta/commands.rb', line 129

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) { system('git', 'pull', 'origin', 'master') }
  else
    system('git', 'clone', repository, path)
  end
end

- (Object) configure_git_to_ignore_repo



139
140
141
142
143
144
# File 'lib/nesta/commands.rb', line 139

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



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

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