laces 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/CONTRIBUTING.md +38 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +122 -0
  4. data/LICENSE +21 -0
  5. data/README.md +5 -0
  6. data/Rakefile +8 -0
  7. data/bin/laces +16 -0
  8. data/features/creating_a_heroku_app.feature +9 -0
  9. data/features/rake_clean.feature +21 -0
  10. data/features/skipping_clearance.feature +13 -0
  11. data/features/step_definitions/gem_steps.rb +5 -0
  12. data/features/step_definitions/heroku_steps.rb +3 -0
  13. data/features/step_definitions/shell_steps.rb +55 -0
  14. data/features/support/bin/heroku +5 -0
  15. data/features/support/env.rb +15 -0
  16. data/features/support/fake_heroku.rb +21 -0
  17. data/laces-0.0.1.gem +0 -0
  18. data/laces.gemspec +35 -0
  19. data/lib/laces/actions.rb +35 -0
  20. data/lib/laces/app_builder.rb +237 -0
  21. data/lib/laces/generators/app_generator.rb +111 -0
  22. data/lib/laces/version.rb +3 -0
  23. data/templates/.DS_Store +0 -0
  24. data/templates/Gemfile_template +76 -0
  25. data/templates/HEROKU_README.md +66 -0
  26. data/templates/Procfile +1 -0
  27. data/templates/README.md +81 -0
  28. data/templates/app/assets/imgs/glyphicons-halflings-white.png +0 -0
  29. data/templates/app/assets/imgs/glyphicons-halflings.png +0 -0
  30. data/templates/app/assets/javascripts/admin.coffee +20 -0
  31. data/templates/app/assets/javascripts/application.coffee +21 -0
  32. data/templates/app/assets/javascripts/lib/actinology.coffee +47 -0
  33. data/templates/app/assets/javascripts/lib/analytics.js +11 -0
  34. data/templates/app/assets/javascripts/lib/auth_token_sync.js +17 -0
  35. data/templates/app/assets/javascripts/lib/backbone-ui.js +2455 -0
  36. data/templates/app/assets/javascripts/lib/backbone.coffee +27 -0
  37. data/templates/app/assets/javascripts/lib/backbone/collection.js +249 -0
  38. data/templates/app/assets/javascripts/lib/backbone/events.js +64 -0
  39. data/templates/app/assets/javascripts/lib/backbone/helpers.js +68 -0
  40. data/templates/app/assets/javascripts/lib/backbone/history.js +144 -0
  41. data/templates/app/assets/javascripts/lib/backbone/model.js +291 -0
  42. data/templates/app/assets/javascripts/lib/backbone/router.coffee +45 -0
  43. data/templates/app/assets/javascripts/lib/backbone/sync.coffee +38 -0
  44. data/templates/app/assets/javascripts/lib/backbone/view.js +150 -0
  45. data/templates/app/assets/javascripts/lib/backbone_extended.coffee +276 -0
  46. data/templates/app/assets/javascripts/lib/bootstrap.js +1836 -0
  47. data/templates/app/assets/javascripts/lib/inflection.js +658 -0
  48. data/templates/app/assets/javascripts/lib/jquery-ui.js +343 -0
  49. data/templates/app/assets/javascripts/lib/jquery.hotkeys.js +102 -0
  50. data/templates/app/assets/javascripts/lib/jquery.js +4 -0
  51. data/templates/app/assets/javascripts/lib/milk.js.coffee +265 -0
  52. data/templates/app/assets/javascripts/lib/raw.js +143 -0
  53. data/templates/app/assets/javascripts/lib/strftime.js +732 -0
  54. data/templates/app/assets/javascripts/lib/throttle-debounce.js +251 -0
  55. data/templates/app/assets/javascripts/lib/timeago.js +148 -0
  56. data/templates/app/assets/javascripts/lib/underscore.js +28 -0
  57. data/templates/app/assets/styles/application.sass +21 -0
  58. data/templates/app/assets/styles/layouts/default.sass +15 -0
  59. data/templates/app/assets/styles/layouts/footer.sass +0 -0
  60. data/templates/app/assets/styles/layouts/forms.sass +34 -0
  61. data/templates/app/assets/styles/layouts/header.sass +0 -0
  62. data/templates/app/assets/styles/layouts/navigation.sass +0 -0
  63. data/templates/app/assets/styles/lib/backbone-ui.css +580 -0
  64. data/templates/app/assets/styles/lib/bootstrap.sass +4248 -0
  65. data/templates/app/assets/styles/pages/home.sass +0 -0
  66. data/templates/app/assets/styles/sessions/new.sass +0 -0
  67. data/templates/app/assets/styles/users/activate.sass +0 -0
  68. data/templates/app/assets/styles/users/new.sass +0 -0
  69. data/templates/app/assets/styles/users/suspended.sass +0 -0
  70. data/templates/app/controllers/app_controller.rb +14 -0
  71. data/templates/app/controllers/pages_controller.rb +2 -0
  72. data/templates/app/controllers/sessions_controller.rb +2 -0
  73. data/templates/app/controllers/templating_controller.rb +31 -0
  74. data/templates/app/controllers/users_controller.rb +2 -0
  75. data/templates/app/helpers/app_helper.rb +94 -0
  76. data/templates/app/helpers/users_helper.rb +53 -0
  77. data/templates/app/models/user.rb +9 -0
  78. data/templates/app/views/devise/confirmations/new.haml +9 -0
  79. data/templates/app/views/devise/passwords/edit.haml +11 -0
  80. data/templates/app/views/devise/passwords/new.haml +9 -0
  81. data/templates/app/views/devise/registrations/edit.haml +13 -0
  82. data/templates/app/views/devise/registrations/new.haml +8 -0
  83. data/templates/app/views/devise/sessions/_form.haml +7 -0
  84. data/templates/app/views/devise/sessions/new.haml +5 -0
  85. data/templates/app/views/devise/unlocks/new.haml +7 -0
  86. data/templates/app/views/layouts/_ascii.haml +0 -0
  87. data/templates/app/views/layouts/_column.haml +0 -0
  88. data/templates/app/views/layouts/_content.haml +1 -0
  89. data/templates/app/views/layouts/_extra.haml +0 -0
  90. data/templates/app/views/layouts/_footer.haml +9 -0
  91. data/templates/app/views/layouts/_head.haml +13 -0
  92. data/templates/app/views/layouts/_header.haml +6 -0
  93. data/templates/app/views/layouts/application.html.haml +16 -0
  94. data/templates/app/views/pages/home.haml +1 -0
  95. data/templates/config/app.yml +29 -0
  96. data/templates/config/application.erb +28 -0
  97. data/templates/config/database.yml +32 -0
  98. data/templates/config/initializers/devise.rb +232 -0
  99. data/templates/config/initializers/rabl_init.rb +4 -0
  100. data/templates/config/initializers/setup_mail.rb +13 -0
  101. data/templates/config/initializers/wrap_parameters.rb +12 -0
  102. data/templates/db/migrate/user_migration.rb +36 -0
  103. data/templates/laces_gitignore +9 -0
  104. data/templates/lib/development_mail_interceptor.rb +7 -0
  105. data/templates/lib/templating.rb +40 -0
  106. metadata +225 -0
@@ -0,0 +1,38 @@
1
+ We love pull requests. Here's a quick guide:
2
+
3
+ 1. Fork the repo.
4
+
5
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
6
+ to know that you have a clean slate: `bundle && rake`
7
+
8
+ 3. Add a test for your change. Only refactoring and documentation changes
9
+ require no new tests. If you are adding functionality or fixing a bug, we need
10
+ a test!
11
+
12
+ 4. Make the test pass.
13
+
14
+ 5. Push to your fork and submit a pull request.
15
+
16
+
17
+ At this point you're waiting on us. We like to at least comment on, if not
18
+ accept, pull requests within three business days (and, typically, one business
19
+ day). We may suggest some changes or improvements or alternatives.
20
+
21
+ Some things that will increase the chance that your pull request is accepted,
22
+ taken straight from the Ruby on Rails guide:
23
+
24
+ * Use Rails idioms and helpers
25
+ * Include tests that fail without your code, and pass with it
26
+ * Update the documentation, the surrounding one, examples elsewhere, guides,
27
+ whatever is affected by your contribution
28
+
29
+ Syntax:
30
+
31
+ * Two spaces, no tabs.
32
+ * No trailing whitespace. Blank lines should not have any space.
33
+ * Prefer &&/|| over and/or.
34
+ * my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
35
+ * a = b and not a=b.
36
+ * Follow the conventions you see used in the source already.
37
+
38
+ And in case we didn't emphasize it enough: we love tests!
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,122 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ laces (0.0.1)
5
+ artii (= 2.0.1)
6
+ bundler (>= 1.1)
7
+ rails (= 3.2.3)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ actionmailer (3.2.3)
13
+ actionpack (= 3.2.3)
14
+ mail (~> 2.4.4)
15
+ actionpack (3.2.3)
16
+ activemodel (= 3.2.3)
17
+ activesupport (= 3.2.3)
18
+ builder (~> 3.0.0)
19
+ erubis (~> 2.7.0)
20
+ journey (~> 1.0.1)
21
+ rack (~> 1.4.0)
22
+ rack-cache (~> 1.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.1.2)
25
+ activemodel (3.2.3)
26
+ activesupport (= 3.2.3)
27
+ builder (~> 3.0.0)
28
+ activerecord (3.2.3)
29
+ activemodel (= 3.2.3)
30
+ activesupport (= 3.2.3)
31
+ arel (~> 3.0.2)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.2.3)
34
+ activemodel (= 3.2.3)
35
+ activesupport (= 3.2.3)
36
+ activesupport (3.2.3)
37
+ i18n (~> 0.6)
38
+ multi_json (~> 1.0)
39
+ arel (3.0.2)
40
+ artii (2.0.1)
41
+ aruba (0.4.11)
42
+ childprocess (>= 0.2.3)
43
+ cucumber (>= 1.1.1)
44
+ ffi (>= 1.0.11)
45
+ rspec (>= 2.7.0)
46
+ builder (3.0.0)
47
+ childprocess (0.3.1)
48
+ ffi (~> 1.0.6)
49
+ cucumber (1.1.9)
50
+ builder (>= 2.1.2)
51
+ diff-lcs (>= 1.1.2)
52
+ gherkin (~> 2.9.0)
53
+ json (>= 1.4.6)
54
+ term-ansicolor (>= 1.0.6)
55
+ diff-lcs (1.1.3)
56
+ erubis (2.7.0)
57
+ ffi (1.0.11)
58
+ gherkin (2.9.3)
59
+ json (>= 1.4.6)
60
+ hike (1.2.1)
61
+ i18n (0.6.0)
62
+ journey (1.0.4)
63
+ json (1.6.6)
64
+ mail (2.4.4)
65
+ i18n (>= 0.4.0)
66
+ mime-types (~> 1.16)
67
+ treetop (~> 1.4.8)
68
+ mime-types (1.19)
69
+ multi_json (1.3.6)
70
+ polyglot (0.3.3)
71
+ rack (1.4.1)
72
+ rack-cache (1.2)
73
+ rack (>= 0.4)
74
+ rack-ssl (1.3.2)
75
+ rack
76
+ rack-test (0.6.1)
77
+ rack (>= 1.0)
78
+ rails (3.2.3)
79
+ actionmailer (= 3.2.3)
80
+ actionpack (= 3.2.3)
81
+ activerecord (= 3.2.3)
82
+ activeresource (= 3.2.3)
83
+ activesupport (= 3.2.3)
84
+ bundler (~> 1.0)
85
+ railties (= 3.2.3)
86
+ railties (3.2.3)
87
+ actionpack (= 3.2.3)
88
+ activesupport (= 3.2.3)
89
+ rack-ssl (~> 1.3.2)
90
+ rake (>= 0.8.7)
91
+ rdoc (~> 3.4)
92
+ thor (~> 0.14.6)
93
+ rake (0.9.2.2)
94
+ rdoc (3.12)
95
+ json (~> 1.4)
96
+ rspec (2.9.0)
97
+ rspec-core (~> 2.9.0)
98
+ rspec-expectations (~> 2.9.0)
99
+ rspec-mocks (~> 2.9.0)
100
+ rspec-core (2.9.0)
101
+ rspec-expectations (2.9.0)
102
+ diff-lcs (~> 1.1.3)
103
+ rspec-mocks (2.9.0)
104
+ sprockets (2.1.3)
105
+ hike (~> 1.2)
106
+ rack (~> 1.0)
107
+ tilt (~> 1.1, != 1.3.0)
108
+ term-ansicolor (1.0.7)
109
+ thor (0.14.6)
110
+ tilt (1.3.3)
111
+ treetop (1.4.10)
112
+ polyglot
113
+ polyglot (>= 0.3.1)
114
+ tzinfo (0.3.33)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ aruba (~> 0.4.11)
121
+ cucumber (~> 1.1.9)
122
+ laces!
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Mike Burns
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,5 @@
1
+ laces
2
+ =====
3
+
4
+ gem build laces.gemspec
5
+ gem install laces-0.0.1.gem
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ require 'cucumber/rake/task'
4
+
5
+ Cucumber::Rake::Task.new
6
+
7
+ desc 'Run the test suite'
8
+ task :default => ['cucumber']
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', 'lib', 'laces', 'generators', 'app_generator'), File.dirname(__FILE__))
4
+ require File.expand_path(File.join('..', 'lib', 'laces', 'actions'), File.dirname(__FILE__))
5
+ require File.expand_path(File.join('..', 'lib', 'laces', 'app_builder'), File.dirname(__FILE__))
6
+
7
+ if ['create', '--create'].include? ARGV[0]
8
+ ARGV.shift
9
+ puts "[WARNING] the laces create argument is deprecated. Just use `laces #{ARGV.join}` instead"
10
+ end
11
+
12
+ templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
13
+ Laces::Generator.source_root templates_root
14
+ Laces::Generator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
15
+
16
+ Laces::Generator.start
@@ -0,0 +1,9 @@
1
+ @disable-bundler
2
+ Feature: Creating a Heroku app when suspending a project
3
+
4
+ Scenario: User uses the --heroku=true command line argument
5
+ When I suspend a project called "test_project" with:
6
+ | argument | value |
7
+ | --heroku | true |
8
+ Then the "test_project-staging" heroku app should exist
9
+ And the "test_project-production" heroku app should exist
@@ -0,0 +1,21 @@
1
+ @disable-bundler
2
+ Feature: Rake works in the suspended project
3
+
4
+ Scenario: Running rake in the suspended project
5
+ When I suspend a project called "test_project"
6
+ And I cd to the "test_project" root
7
+ When I drop and create the required databases
8
+ And I run the rake task "db:create"
9
+ And I run the rake task "db:migrate"
10
+ And I run the rake task "db:test:prepare"
11
+ And I run the rake task "cucumber"
12
+ Then I see a successful response in the shell
13
+
14
+ Scenario: Making a spec then running rake
15
+ When I drop and create the required databases
16
+ And I suspend a project called "test_project"
17
+ And I generate "model post title:string"
18
+ And I run the rake task "db:migrate"
19
+ And I run the rake task "db:test:prepare"
20
+ And I run the rake task "spec"
21
+ Then I see a successful response in the shell
@@ -0,0 +1,13 @@
1
+ @disable-bundler
2
+ Feature: Skipping clearance
3
+ As a developer
4
+ I want to suspend an app without clearance
5
+ So that I can build apps without users, or with other authentication libraries
6
+
7
+ Scenario: Passing --clearance=false
8
+ When I suspend a project called "test_project" with:
9
+ | argument | value |
10
+ | --clearance | false |
11
+ And I cd to the "test_project" root
12
+ Then "clearance" should not be installed
13
+ And I can cleanly rake the project
@@ -0,0 +1,5 @@
1
+ Then /^"(.*)" should not be installed$/ do |gem_name|
2
+ in_current_dir do
3
+ system("bundle show #{gem_name}").should be_false
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ Then /^the "([^"]*)" heroku app should exist$/ do |app_name|
2
+ FakeHeroku.should have_created_app(app_name)
3
+ end
@@ -0,0 +1,55 @@
1
+ require 'aruba/cucumber'
2
+
3
+ When 'I run the rake task "$task_name"' do |task_name|
4
+ in_current_dir do
5
+ run "bundle exec rake #{task_name}"
6
+ end
7
+ end
8
+
9
+ When 'I generate "$generator_with_args"' do |generator_with_args|
10
+ in_current_dir do
11
+ run "bundle exec rails generate #{generator_with_args}"
12
+ end
13
+ end
14
+
15
+ Then 'I see a successful response in the shell' do
16
+ assert_exit_status(0)
17
+ end
18
+
19
+ When 'I drop and create the required databases' do
20
+ in_current_dir do
21
+ run 'bundle exec rake db:drop RAILS_ENV=test'
22
+ run 'bundle exec rake db:drop'
23
+ run 'bundle exec rake db:create RAILS_ENV=test'
24
+ run 'bundle exec rake db:create'
25
+ end
26
+ end
27
+
28
+ When 'I suspend a project called "$project_name"' do |project_name|
29
+ laces_bin = File.expand_path(File.join('..', '..', 'bin', 'laces'), File.dirname(__FILE__))
30
+ run "#{laces_bin} #{project_name}"
31
+ assert_exit_status(0)
32
+ end
33
+
34
+ When /^I suspend a project called "([^"]*)" with:$/ do |project_name, arguments_table|
35
+ laces_bin = File.expand_path(File.join('..', '..', 'bin', 'laces'), File.dirname(__FILE__))
36
+ arguments = arguments_table.hashes.inject([]) do |accum, argument|
37
+ accum << "#{argument['argument']}=#{argument['value']}"
38
+ end.join
39
+ run "#{laces_bin} #{project_name} #{arguments}"
40
+ assert_exit_status(0)
41
+ end
42
+
43
+ When 'I cd to the "$test_project" root' do |dirname|
44
+ cd dirname
45
+ end
46
+
47
+ Then 'I can cleanly rake the project' do
48
+ steps %{
49
+ And I run the rake task "db:create"
50
+ And I run the rake task "db:migrate"
51
+ And I run the rake task "db:test:prepare"
52
+ And I run the rake task "cucumber"
53
+ Then I see a successful response in the shell
54
+ }
55
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', '..', 'support', 'fake_heroku'), File.dirname(__FILE__))
4
+
5
+ FakeHeroku.new(ARGV).run!
@@ -0,0 +1,15 @@
1
+ Before do
2
+ ENV['TESTING'] = 'true'
3
+ end
4
+
5
+ Before do
6
+ @aruba_timeout_seconds = 560
7
+ end
8
+
9
+ After do
10
+ FakeHeroku.clear!
11
+ end
12
+
13
+ After do
14
+ FileUtils.rm_rf('test_project')
15
+ end
@@ -0,0 +1,21 @@
1
+ class FakeHeroku
2
+ RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'heroku_commands'), File.dirname(__FILE__))
3
+
4
+ def initialize(args)
5
+ @args = args
6
+ end
7
+
8
+ def run!
9
+ File.open(RECORDER, 'a') do |file|
10
+ file.write @args.join(' ')
11
+ end
12
+ end
13
+
14
+ def self.clear!
15
+ FileUtils.rm_rf(RECORDER)
16
+ end
17
+
18
+ def self.has_created_app?(app_name)
19
+ File.open(RECORDER, 'r').read.include?("create #{app_name}")
20
+ end
21
+ end
Binary file
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "laces/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'laces'
7
+ s.version = Laces::VERSION
8
+ s.date = Date.today.strftime('%Y-%m-%d')
9
+ s.authors = ["notesolution"]
10
+ #s.email = 'support@thoughtbot.com'
11
+ #s.homepage = 'http://github.com/thoughtbot/suspenders'
12
+ s.summary = "Generate a Rails app using notesolution's best practices."
13
+ s.description = <<-HERE
14
+ Laces is a base Rails project that you can upgrade. It is used by
15
+ thoughtbot to get a jump start on a working app. Use Laces if you're in a
16
+ rush to build something amazing; don't use it if you like missing deadlines.
17
+ HERE
18
+
19
+ s.files = `git ls-files`.split("\n").
20
+ reject { |file| file =~ /^\./ }.
21
+ reject { |file| file =~ /^(rdoc|pkg)/ }
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+
26
+ s.rdoc_options = ["--charset=UTF-8"]
27
+ s.extra_rdoc_files = %w[README.md LICENSE]
28
+
29
+ s.add_dependency 'rails' , '=3.2.3'
30
+ s.add_dependency 'bundler', '>= 1.1'
31
+ s.add_dependency 'artii' , '=2.0.1'
32
+
33
+ s.add_development_dependency 'cucumber', '~> 1.1.9'
34
+ s.add_development_dependency 'aruba' , '~> 0.4.11'
35
+ end
@@ -0,0 +1,35 @@
1
+ module Laces
2
+ module Actions
3
+ def concat_file(source, destination)
4
+ contents = IO.read(find_in_source_paths(source))
5
+ append_file destination, contents
6
+ end
7
+
8
+ def replace_in_file(relative_path, find, replace)
9
+ path = File.join(destination_root, relative_path)
10
+ contents = IO.read(path)
11
+ unless contents.gsub!(find, replace)
12
+ raise "#{find.inspect} not found in #{relative_path}"
13
+ end
14
+ File.open(path, "w") { |file| file.write(contents) }
15
+ end
16
+
17
+ def action_mailer_host(rails_env, host)
18
+ inject_into_file(
19
+ "config/environments/#{rails_env}.rb",
20
+ "\n\n config.action_mailer.default_url_options = { :host => '#{host}' }",
21
+ :before => "\nend"
22
+ )
23
+ end
24
+
25
+ def download_file uri_string, destination
26
+ uri = URI.parse uri_string
27
+ http = Net::HTTP.new uri.host, uri.port
28
+ http.use_ssl = true if uri_string =~ /^https/
29
+ request = Net::HTTP::Get.new uri.path
30
+ contents = http.request(request).body
31
+ path = File.join destination_root, destination
32
+ File.open(path, "w") { |file| file.write(contents) }
33
+ end
34
+ end
35
+ end