foundation 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb3bc52b1c9dcc4063f50c7b28d8aad6406ea066
4
- data.tar.gz: 506484d17cb937e7b1d8aaea0fd3699155d7cdb0
3
+ metadata.gz: 24f80ba2417fe4e64205b1e8b551c080ebdea5cf
4
+ data.tar.gz: 5825e9b114c83d4c2c374c0e9b5c5c4036a8cc9f
5
5
  SHA512:
6
- metadata.gz: ef92abf78e8e6328b0eda237b4bf5736b12092bad898b3913ffc850ce7985a2c684c619cd92cb14deab516394002a495f3bc63d9b121b593465bd926bf0dfbf0
7
- data.tar.gz: eecc070821666e97c1ddf23f5d05779ea7b203bf32884c037eee860f7594a201309da2c98958e698e9fbc2ce25ccf1dfa308383baf28c2c6d5451dd1615955c0
6
+ metadata.gz: 35fe01b9f7564ac3bc5289ce6b6c89177f537e3c6dc2cf9029059312ad8d7c59c4f89547811c69de87b5b324eadcc8c201ce3ef57b25dd112202947e8254b3ad
7
+ data.tar.gz: 3aa494412fb08343f4b764bb48fccb3efc5501eb866d91fb5c2e3d018c6baafd2f970e50b6a135e356a7566109c9c99f3379c72dabbf1052d5d11a80c889b7aa
@@ -1,4 +1,5 @@
1
1
  require "thor"
2
+ require "json"
2
3
 
3
4
  module Foundation
4
5
  module CLI
@@ -16,6 +17,38 @@ module Foundation
16
17
  end
17
18
  return nil
18
19
  end
20
+
21
+ def install_dependencies(deps=[])
22
+ if deps.include?("git") && !which("git")
23
+ say "Can't find git. You can install it by going here: http://git-scm.com/"
24
+ exit 1
25
+ end
26
+
27
+ if deps.include?("node") && !which("node")
28
+ say "Can't find NodeJS. You can install it by going here: http://nodejs.org"
29
+ exit 1
30
+ end
31
+
32
+ if deps.include?("bower") && !which("bower")
33
+ say "Can't find bower. You can install it by running: sudo npm install -g bower"
34
+ exit 1
35
+ end
36
+
37
+ if deps.include?("grunt") && !which("grunt")
38
+ say "Can't find grunt. You can install it by running: sudo npm install -g grunt-cli"
39
+ exit 1
40
+ end
41
+
42
+ if deps.include?("compass") && !which("compass")
43
+ # Auto install Compass as a convenience
44
+ run("gem install compass", capture: true, verbose: false)
45
+ run("rbenv rehash", capture: true, verbose: false) if which("rbenv")
46
+ unless which("compass")
47
+ say "Can't find compass. You can install it by running: gem install compass"
48
+ exit 1
49
+ end
50
+ end
51
+ end
19
52
  end
20
53
 
21
54
  desc "version", "Display CLI version"
@@ -23,53 +56,89 @@ module Foundation
23
56
  puts "v#{Foundation::CLI::VERSION}"
24
57
  end
25
58
 
26
- desc "new", "create new project"
27
- option :libsass, type: :boolean, default: false
28
- option :version, type: :string
29
- def new(name)
30
- # RUBY_VERSION == "2.0.0"
31
- unless which("compass")
32
- run("gem install compass", capture: true, verbose: false)
33
- run("rbenv rehash", capture: true, verbose: false) if which("rbenv")
59
+ desc "upgrade", "Upgrade your Foundation 4 compass project"
60
+ def upgrade
61
+ install_dependencies(%w{git node bower compass})
62
+
63
+ if File.exists?(".bowerrc")
64
+ begin json = JSON.parse(File.read(".bowerrc"))
65
+ rescue JSON::ParserError
66
+ json = {}
67
+ end
68
+ unless json.has_key?("directory")
69
+ json["directory"] = "bower_components"
70
+ end
71
+ File.open(".bowerrc", "w") {|f| f.puts json.to_json}
72
+ else
73
+ create_file ".bowerrc" do
74
+ {:directory=>"bower_components"}.to_json
75
+ end
34
76
  end
77
+ bower_directory = JSON.parse(File.read(".bowerrc"))["directory"]
35
78
 
36
- unless which("node") || which("npm")
37
- say "Please install NodeJS. (psst, go here: http://nodejs.org) Aborting."
38
- exit 1
79
+ gsub_file "config.rb", /require [\"\']zurb-foundation[\"\']/ do |match|
80
+ match = "add_import_path \"#{bower_directory}/foundation/scss\""
81
+ end
39
82
 
83
+ unless File.exists?("bower.json")
84
+ create_file "bower.json" do
85
+ {:name => "foundation_project"}.to_json
86
+ end
40
87
  end
41
88
 
42
- unless which("bower")
43
- say "Please install bower. (psst, run: sudo npm install -g bower) Aborting."
44
- exit 1
45
- end
89
+ run "bower install zurb/bower-foundation --save"
46
90
 
47
91
 
48
- if options[:libsass]
49
- unless which("grunt")
50
- say "Please install grunt-cli. (psst, run: sudo npm install -g grunt-cli) Aborting."
51
- exit 1
92
+ if defined?(Bundler)
93
+ Bundler.with_clean_env do
94
+ run("compass compile", capture: true, verbose: false)
52
95
  end
96
+ else
97
+ run("compass compile", capture: true, verbose: false)
98
+ end
99
+
100
+ say <<-EOS
101
+
102
+ Foundation 5 has been setup in your project.
103
+
104
+ Please update references to javascript files to look something like:
105
+
106
+ <script src="#{bower_directory}/foundation/js/foundation.min.js"></script>
107
+
108
+ To update Foundation in the future, just run: foundation update
109
+
110
+ EOS
111
+ end
112
+
113
+ desc "new", "create new project"
114
+ option :libsass, type: :boolean, default: false
115
+ option :version, type: :string
116
+ def new(name)
117
+ if options[:libsass]
118
+ install_dependencies(%w{git node bower grunt})
53
119
  repo = "https://github.com/zurb/foundation-libsass-template.git"
54
120
  else
55
- unless which("compass")
56
- run("gem install compass", capture: true, verbose: false)
57
- run("rbenv rehash", capture: true, verbose: false) if which("rbenv")
58
- end
121
+ install_dependencies(%w{git node bower compass})
59
122
  repo = "https://github.com/zurb/foundation-compass-template.git"
60
123
  end
61
124
 
62
125
  say "Creating ./#{name}"
63
126
  empty_directory(name)
64
- run "git clone #{repo} #{name}", capture: true, verbose: false
127
+ run("git clone #{repo} #{name}", capture: true, verbose: false)
65
128
  inside(name) do
66
129
  say "Installing dependencies with bower..."
67
- run "bower install", capture: true, verbose: false
130
+ run("bower install", capture: true, verbose: false)
68
131
  create_file "scss/_settings.scss", File.read("#{destination_root}/bower_components/foundation/scss/foundation/_settings.scss")
69
- run "git remote rm origin", capture: true, verbose: false
132
+ run("git remote rm origin", capture: true, verbose: false)
70
133
  if options[:libsass]
71
134
  run "npm install"
72
135
  run "grunt build"
136
+ else
137
+ if defined?(Bundler)
138
+ Bundler.with_clean_env do
139
+ run "compass compile"
140
+ end
141
+ end
73
142
  end
74
143
  end
75
144
 
@@ -1,5 +1,5 @@
1
1
  module Foundation
2
2
  module CLI
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foundation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Hayes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-23 00:00:00.000000000 Z
11
+ date: 2013-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler