contact_us 0.0.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +5 -4
- data/lib/contact_us/tasks/install.rb +74 -0
- data/lib/contact_us/version.rb +1 -1
- data/lib/tasks/install.rake +11 -54
- data/spec/dummy/config/database.yml +3 -14
- data/spec/dummy/log/test.log +10637 -0
- data/spec/integration/navigation_spec.rb +1 -2
- data/spec/lib/install_spec.rb +43 -0
- data/spec/spec_helper.rb +4 -6
- metadata +22 -13
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Contact Us
|
2
2
|
|
3
|
-
A Rails 3 Engine providing a basic contact form. I used Formtastic to keep things simple, and to hook into your apps custom Formtastic stylesheets.
|
3
|
+
A Rails 3+ Engine providing a basic contact form. I used Formtastic to keep things simple, and to hook into your apps custom Formtastic stylesheets.
|
4
|
+
|
5
|
+
[](http://travis-ci.org/jdutil/contact_us)
|
4
6
|
|
5
7
|
## REQUIREMENTS
|
6
8
|
|
@@ -10,12 +12,12 @@ Contact Us requires the Formtastic Gem. Read more about Formtastic @ https://gi
|
|
10
12
|
|
11
13
|
In your `Gemfile`, add the following dependencies:
|
12
14
|
|
13
|
-
gem 'contact_us', '~> 0.0
|
15
|
+
gem 'contact_us', '~> 0.1.0'
|
14
16
|
|
15
17
|
From `Rails.root` run:
|
16
18
|
|
17
19
|
$ bundle
|
18
|
-
$ rake contact_us:install
|
20
|
+
$ bundle exec rake contact_us:install
|
19
21
|
|
20
22
|
In `config/initializers/contact_us.rb` modify:
|
21
23
|
|
@@ -58,7 +60,6 @@ Here are some ways *you* can contribute:
|
|
58
60
|
|
59
61
|
## TODO
|
60
62
|
|
61
|
-
* Installation tests
|
62
63
|
* Add new language translations
|
63
64
|
|
64
65
|
Copyright (c) 2011 Jeff Dutil, released under the [MIT license](https://github.com/jdutil/contact_us/tree/master/MIT-LICENSE).
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module ContactUs
|
4
|
+
module Tasks
|
5
|
+
class Install
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def run
|
9
|
+
copy_initializer_file
|
10
|
+
copy_locales_files
|
11
|
+
copy_view_files
|
12
|
+
puts "Done!"
|
13
|
+
end
|
14
|
+
|
15
|
+
def copy_initializer_file
|
16
|
+
print "Copying initializer file...\n"
|
17
|
+
app_path = Rails.root.join("config/initializers")
|
18
|
+
copier.copy_file File.join(gem_path, 'lib/templates/contact_us.rb'), File.join(app_path, 'contact_us.rb')
|
19
|
+
end
|
20
|
+
|
21
|
+
def copy_locales_files
|
22
|
+
print "Copying locales files...\n"
|
23
|
+
locales_path = gem_path + "/config/locales/*.yml"
|
24
|
+
app_path = Rails.root.join("config/locales")
|
25
|
+
|
26
|
+
unless File.directory?(app_path)
|
27
|
+
app_path.mkdir
|
28
|
+
end
|
29
|
+
|
30
|
+
Dir.glob(locales_path).each do |file|
|
31
|
+
copier.copy_file file, File.join(app_path, File.basename(file))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def copy_view_files
|
36
|
+
print "Copying view files...\n"
|
37
|
+
origin = File.join(gem_path, 'app/views')
|
38
|
+
destination = Rails.root.join('app/views')
|
39
|
+
copy_files(['.'], origin, destination)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def copy_files(directories, origin, destination)
|
45
|
+
directories.each do |directory|
|
46
|
+
Dir[File.join(origin, directory, 'contact_us', '**/*')].each do |file|
|
47
|
+
relative = file.gsub(/^#{origin}\//, '')
|
48
|
+
dest_file = File.join(destination, relative)
|
49
|
+
dest_dir = File.dirname(dest_file)
|
50
|
+
|
51
|
+
if !File.exist?(dest_dir)
|
52
|
+
FileUtils.mkdir_p(dest_dir)
|
53
|
+
end
|
54
|
+
|
55
|
+
copier.copy_file(file, dest_file) unless File.directory?(file)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def gem_path
|
61
|
+
File.expand_path('../../..', File.dirname(__FILE__))
|
62
|
+
end
|
63
|
+
|
64
|
+
def copier
|
65
|
+
unless @copier
|
66
|
+
Rails::Generators::Base.source_root(gem_path)
|
67
|
+
@copier = Rails::Generators::Base.new
|
68
|
+
end
|
69
|
+
@copier
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/contact_us/version.rb
CHANGED
data/lib/tasks/install.rake
CHANGED
@@ -1,61 +1,18 @@
|
|
1
|
-
require '
|
1
|
+
require File.expand_path('../../contact_us/tasks/install', __FILE__)
|
2
2
|
|
3
3
|
namespace :contact_us do
|
4
|
-
desc "Install
|
4
|
+
desc "Install contact_us"
|
5
5
|
task :install do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
gem_path = gem_path[0..-4]
|
10
|
-
gem_path = gem_path.join("/")
|
11
|
-
|
12
|
-
Rails::Generators::Base.source_root(gem_path)
|
13
|
-
copier = Rails::Generators::Base.new
|
14
|
-
|
15
|
-
unless File.exists?(Rails.root.join("config/initializers/contact_us.rb"))
|
16
|
-
print "Now copying initializer!\n"
|
17
|
-
|
18
|
-
locales_path = gem_path + "/lib/templates/*"
|
19
|
-
app_path = Rails.root.join("config/initializers")
|
20
|
-
unless File.directory?(app_path)
|
21
|
-
app_path.mkdir
|
22
|
-
end
|
23
|
-
Dir.glob(locales_path).each do |file|
|
24
|
-
copier.copy_file file, File.join(app_path, File.basename(file))
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
print "Now copying locales files!\n"
|
6
|
+
ContactUs::Tasks::Install.run
|
7
|
+
end
|
29
8
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
Dir.glob(locales_path).each do |file|
|
36
|
-
copier.copy_file file, File.join(app_path, File.basename(file))
|
37
|
-
end
|
9
|
+
desc "Copy only locale files (part of install, but useful for updates when only assets are needed)"
|
10
|
+
task :copy_locales do
|
11
|
+
ContactUs::Tasks::Install.copy_locales_files
|
12
|
+
end
|
38
13
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
locales_path = gem_path + "/app/views/contact_us/contact_mailer/*"
|
44
|
-
app_path = Rails.root.join("app/views/contact_us/contact_mailer")
|
45
|
-
unless File.directory?(app_path)
|
46
|
-
app_path.mkdir
|
47
|
-
end
|
48
|
-
Dir.glob(locales_path).each do |file|
|
49
|
-
copier.copy_file file, File.join(app_path, File.basename(file))
|
50
|
-
end
|
51
|
-
|
52
|
-
locales_path = gem_path + "/app/views/contact_us/contacts/*"
|
53
|
-
app_path = Rails.root.join("app/views/contact_us/contacts")
|
54
|
-
unless File.directory?(app_path)
|
55
|
-
app_path.mkdir
|
56
|
-
end
|
57
|
-
Dir.glob(locales_path).each do |file|
|
58
|
-
copier.copy_file file, File.join(app_path, File.basename(file))
|
59
|
-
end
|
14
|
+
desc "Copy only view files (part of install, but useful for updates when only assets are needed)"
|
15
|
+
task :copy_views do
|
16
|
+
ContactUs::Tasks::Install.copy_view_files
|
60
17
|
end
|
61
18
|
end
|
@@ -1,22 +1,11 @@
|
|
1
1
|
# SQLite version 3.x
|
2
2
|
# gem install sqlite3
|
3
|
-
development:
|
4
|
-
adapter: sqlite3
|
5
|
-
database: db/development.sqlite3
|
6
|
-
pool: 5
|
7
|
-
timeout: 5000
|
8
3
|
|
9
4
|
# Warning: The database defined as "test" will be erased and
|
10
5
|
# re-generated from your development database when you run "rake".
|
11
6
|
# Do not set this db to the same as development or production.
|
12
|
-
test:
|
13
|
-
adapter: sqlite3
|
14
|
-
database: db/test.sqlite3
|
15
|
-
pool: 5
|
16
|
-
timeout: 5000
|
17
7
|
|
18
|
-
|
8
|
+
test:
|
19
9
|
adapter: sqlite3
|
20
|
-
database:
|
21
|
-
|
22
|
-
timeout: 5000
|
10
|
+
database: ":memory:"
|
11
|
+
timeout: 500
|