Commit ad468569cd229019fe00a0d891f092224ae6ec26
1 parent
18d2d8a3
Exists in
master
and in
1 other branch
refactored not_installed? method to installed? method
Showing
1 changed file
with
11 additions
and
6 deletions
Show diff stats
script/create_project
... | ... | @@ -42,6 +42,11 @@ def not_installed?(gem_name) |
42 | 42 | gems.detect { |gem| gem.name == gem_name }.nil? |
43 | 43 | end |
44 | 44 | |
45 | +def installed?(gem_name) | |
46 | + installed_gems = Gem.source_index.find_name(gem_name) | |
47 | + installed_gems.any? | |
48 | +end | |
49 | + | |
45 | 50 | run("mkdir #{project_directory}") |
46 | 51 | Dir.chdir(project_directory) or fail("Couldn't change to #{project_directory}") |
47 | 52 | run("git init") |
... | ... | @@ -59,7 +64,7 @@ end |
59 | 64 | |
60 | 65 | run("git commit -a -m 'New Heroku Suspenders app'") |
61 | 66 | |
62 | -if not_installed?("rails") | |
67 | +unless installed?("rails") | |
63 | 68 | run "sudo gem install rails" |
64 | 69 | end |
65 | 70 | |
... | ... | @@ -68,23 +73,23 @@ run("sudo rake gems:install RAILS_ENV=test") |
68 | 73 | run("sudo rake gems:install RAILS_ENV=cucumber") |
69 | 74 | |
70 | 75 | # can't vendor nokogiri because it has native extensions |
71 | -if not_installed?("nokogiri") | |
76 | +unless installed?("nokogiri") | |
72 | 77 | run "sudo gem install nokogiri --version='1.3.2'" |
73 | 78 | end |
74 | 79 | |
75 | 80 | # need to install tpope-pickler for the 'pickler' command |
76 | -if not_installed?("tpope-pickler") | |
81 | +unless installed?("tpope-pickler") | |
77 | 82 | run "sudo gem install tpope-pickler" |
78 | 83 | end |
79 | 84 | |
80 | 85 | # need to install heroku gem for the 'heroku' commands |
81 | -if not_installed?("heroku") | |
86 | +unless installed?("heroku") | |
82 | 87 | run "sudo gem install heroku" |
83 | 88 | end |
84 | 89 | |
85 | 90 | # can't install rubaidh-google_analytics via rake gems:install because |
86 | 91 | # it is a production gem and we don't have a production database |
87 | -if not_installed?("rubaidh-google_analytics") | |
92 | +unless installed?("rubaidh-google_analytics") | |
88 | 93 | run "sudo gem install rubaidh-google_analytics --version='1.1.4'" |
89 | 94 | end |
90 | 95 | |
... | ... | @@ -98,12 +103,12 @@ run("sudo touch log/cucumber.log") |
98 | 103 | run("sudo chmod 0666 log/cucumber.log") |
99 | 104 | |
100 | 105 | run("script/generate clearance") |
101 | -run("rake db:migrate RAILS_ENV=development") | |
102 | 106 | run("script/generate clearance_features") |
103 | 107 | run("script/generate clearance_views") |
104 | 108 | run("git add .") |
105 | 109 | run("git commit -m 'installed clearance'") |
106 | 110 | |
111 | +run("rake db:migrate RAILS_ENV=development") | |
107 | 112 | run("rake db:migrate RAILS_ENV=test") |
108 | 113 | run("rake db:migrate RAILS_ENV=cucumber") |
109 | 114 | ... | ... |