Class: Foundation::CLI::Generator

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/foundation/cli/generator.rb

Instance Method Summary collapse

Instance Method Details

#new(name) ⇒ Object



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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/foundation/cli/generator.rb', line 29

def new(name)
  # RUBY_VERSION == "2.0.0"
  unless which("compass")
    run("gem install compass", capture: true, verbose: false)
    run("rbenv rehash", capture: true, verbose: false) if which("rbenv")
  end

  unless which("node") || which("npm")
    say "Please install NodeJS. (psst, go here: http://nodejs.org) Aborting."
    exit 1

  end

  unless which("bower")
    say "Please install bower. (psst, run: sudo npm install -g bower) Aborting."
    exit 1
  end      


  if options[:libsass]
    unless which("grunt")
      say "Please install grunt-cli. (psst, run: sudo npm install -g grunt-cli) Aborting."
      exit 1
    end
    repo = "https://github.com/zurb/foundation-libsass-template.git"
  else
    unless which("compass")
      run("gem install compass", capture: true, verbose: false)
      run("rbenv rehash", capture: true, verbose: false) if which("rbenv")
    end
    repo = "https://github.com/zurb/foundation-compass-template.git"
  end

  say "Creating ./#{name}"
  empty_directory(name)
  run "git clone #{repo} #{name}", capture: true, verbose: false
  inside(name) do
    say "Installing dependencies with bower..."
    run "bower install", capture: true, verbose: false
    create_file "scss/_settings.scss", File.read("#{destination_root}/bower_components/foundation/scss/foundation/_settings.scss")
    run "git remote rm origin", capture: true, verbose: false
    if options[:libsass]
      run "npm install"
      run "grunt build"
    end
  end

  say "./#{name} was created"
end

#updateObject



81
82
83
84
85
86
87
# File 'lib/foundation/cli/generator.rb', line 81

def update
  unless which("bower")
    "Please install bower. Aborting."
    exit 1
  end
  run "bower update"
end

#versionObject



22
23
24
# File 'lib/foundation/cli/generator.rb', line 22

def version
  puts "v#{Foundation::CLI::VERSION}"
end