Commit ad468569cd229019fe00a0d891f092224ae6ec26

Authored by Dan Croak
1 parent 18d2d8a3

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