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

#initializeContent

Returns a new instance of Content.



104
105
106
# File 'lib/nesta/commands.rb', line 104

def initialize
  @dir = 'content-demo'
end

Instance Method Details

#clone_or_update_repositoryObject



108
109
110
111
112
113
114
115
116
# File 'lib/nesta/commands.rb', line 108

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

#configure_git_to_ignore_repoObject



118
119
120
121
122
123
# File 'lib/nesta/commands.rb', line 118

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

#executeObject



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

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