sinatra_more 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -494,6 +494,7 @@ functionality on the server. However, smtp is also supported using the following
494
494
  Once those have been defined, the default will become smtp delivery unless overwritten in an individual mail definition.
495
495
  Next, we should define a custom mailer extended from <tt>SinatraMore::MailerBase</tt>.
496
496
 
497
+ # app/mailers/sample_mailer.rb
497
498
  class SampleMailer < SinatraMore::MailerBase
498
499
  def registration_email(name, user_email_address)
499
500
  from 'admin@site.com'
@@ -512,7 +513,7 @@ is passing the <tt>name</tt> attribute to the body message template which should
512
513
 
513
514
  # ./views/sample_mailer/registration_email.erb
514
515
  This is the body of the email and can access the <%= name %> that was passed in from the mailer definition
515
- That's all there is to defining the body of the email which can be plain text or email
516
+ That's all there is to defining the body of the email which can be plain text or html
516
517
 
517
518
  Once the mailer definition has been completed and the template has been defined, the email can be sent using:
518
519
 
@@ -527,6 +528,7 @@ A few variations are shown below for completeness.
527
528
 
528
529
  If we want to attach files to our email:
529
530
 
531
+ # app/mailers/sample_mailer.rb
530
532
  class SampleMailer < SinatraMore::MailerBase
531
533
  def attachment_email(name, user_email_address)
532
534
  from 'admin@site.com'
@@ -538,6 +540,7 @@ If we want to attach files to our email:
538
540
 
539
541
  or perhaps we want to have a short body without the need for a template file:
540
542
 
543
+ # app/mailers/sample_mailer.rb
541
544
  class SampleMailer < SinatraMore::MailerBase
542
545
  def short_email(name, user_email_address)
543
546
  from 'admin@site.com'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.6
1
+ 0.3.7
File without changes
@@ -1,5 +1,6 @@
1
1
  # This file is merely for beginning the boot process, check dependencies.rb for more information
2
2
 
3
+ RACK_ENV = ENV["RACK_ENV"] ||= "development" unless defined? RACK_ENV
3
4
  ROOT_DIR = File.dirname(__FILE__) + '/../' unless defined? ROOT_DIR
4
5
 
5
6
  # Helper method for file references.
@@ -23,6 +24,7 @@ class <%= @class_name %> < Sinatra::Application
23
24
  set :views, root_path("app", "views")
24
25
  set :images_path, public_path("images")
25
26
  set :default_builder, 'StandardFormBuilder'
27
+ set :environment, RACK_ENV if defined?(RACK_ENV)
26
28
 
27
29
  # Dependencies contains all required gems and core configuration
28
30
  require File.dirname(__FILE__) + '/dependencies.rb'
@@ -17,7 +17,7 @@ class <%= @class_name %> < Sinatra::Application
17
17
 
18
18
  # Returns the list of load paths for this sinatra application
19
19
  def self.file_loading_paths
20
- ["lib/**/*.rb", "app/helpers/**/*.rb", "app/routes/**/*.rb", "app/models/*.rb"]
20
+ ["lib/**/*.rb", "app/helpers/**/*.rb", "app/routes/**/*.rb", "app/models/*.rb", "app/mailers/*.rb"]
21
21
  end
22
22
 
23
23
  # Require all the folders and files necessary to run the application
@@ -1,6 +1,4 @@
1
- %w[rubygems sinatra].each {|gem| require gem }
1
+ RACK_ENV = 'test' unless defined?(RACK_ENV)
2
+ %w[rubygems sinatra/base].each {|gem| require gem }
2
3
  require 'rack/test'
3
4
  require File.dirname(__FILE__) + "/../app"
4
-
5
-
6
- set :environment, :test
@@ -21,7 +21,7 @@ module SinatraMore
21
21
  # insert_test_suite_setup('...CLASS_NAME...')
22
22
  # => inject_into_file("test/test_config.rb", TEST.gsub(/CLASS_NAME/, @class_name), :after => "set :environment, :test\n")
23
23
  def insert_test_suite_setup(suite_text, options={})
24
- options.reverse_merge!(:path => "test/test_config.rb", :after => "set :environment, :test\n")
24
+ options.reverse_merge!(:path => "test/test_config.rb", :after => /require.*?app.*?\n/)
25
25
  inject_into_file(options[:path], suite_text.gsub(/CLASS_NAME/, @class_name), :after => options[:after])
26
26
  end
27
27
 
@@ -4,10 +4,24 @@ module SinatraMore
4
4
  AR = <<-AR
5
5
  module ActiveRecordInitializer
6
6
  def self.registered(app)
7
- app.configure do
7
+ app.configure :development do
8
8
  ActiveRecord::Base.establish_connection(
9
9
  :adapter => 'sqlite3',
10
- :database => 'your_db_here'
10
+ :database => 'your_dev_db_here'
11
+ )
12
+ end
13
+
14
+ app.configure :production do
15
+ ActiveRecord::Base.establish_connection(
16
+ :adapter => 'sqlite3',
17
+ :database => 'your_production_db_here'
18
+ )
19
+ end
20
+
21
+ app.configure :test do
22
+ ActiveRecord::Base.establish_connection(
23
+ :adapter => 'sqlite3',
24
+ :database => 'your_test_db_here'
11
25
  )
12
26
  end
13
27
  end
@@ -4,9 +4,9 @@ module SinatraMore
4
4
  DM = <<-DM
5
5
  module DataMapperInitializer
6
6
  def self.registered(app)
7
- app.configure do
8
- DataMapper.setup(:default, 'your_db_here')
9
- end
7
+ app.configure(:development) { DataMapper.setup(:default, 'your_dev_db_here') }
8
+ app.configure(:production) { DataMapper.setup(:default, 'your_production_db_here') }
9
+ app.configure(:test) { DataMapper.setup(:default, 'your_test_db_here') }
10
10
  end
11
11
  end
12
12
  DM
@@ -6,10 +6,20 @@ class MongoDBConnectionFailure < RuntimeError; end
6
6
 
7
7
  module MongoDbInitializer
8
8
  def self.registered(app)
9
- MongoMapper.connection = Mongo::Connection.new('localhost')
10
- MongoMapper.database = 'your_db_here'
11
- rescue RuntimeError
12
- raise MongoDBConnectionFailure.new("mongodb cannot connect to db! Start the mongodb process and try again.")
9
+ app.configure :development do
10
+ MongoMapper.connection = Mongo::Connection.new('localhost')
11
+ MongoMapper.database = 'your_dev_db_here'
12
+ end
13
+
14
+ app.configure :production do
15
+ MongoMapper.connection = Mongo::Connection.new('localhost')
16
+ MongoMapper.database = 'your_production_db_here'
17
+ end
18
+
19
+ app.configure :test do
20
+ MongoMapper.connection = Mongo::Connection.new('localhost')
21
+ MongoMapper.database = 'your_test_db_here'
22
+ end
13
23
  end
14
24
  end
15
25
  MONGO
@@ -4,10 +4,10 @@ module SinatraMore
4
4
  SEQUEL = <<-SEQUEL
5
5
  module SequelInitializer
6
6
  def self.registered(app)
7
- app.configure do
8
- Sequel::Model.plugin(:schema)
9
- Sequel.connect('your_db_here')
10
- end
7
+ Sequel::Model.plugin(:schema)
8
+ app.configure(:development) { Sequel.connect('your_dev_db_here') }
9
+ app.configure(:production) { Sequel.connect('your_production_db_here') }
10
+ app.configure(:test) { Sequel.connect('your_test_db_here') }
11
11
  end
12
12
  end
13
13
  SEQUEL
@@ -6,7 +6,7 @@ module SinatraMore
6
6
  end
7
7
 
8
8
  def app
9
- CLASS_NAME
9
+ CLASS_NAME.tap { |app| app.set :environment, :test }
10
10
  end
11
11
  TEST
12
12
 
@@ -5,7 +5,7 @@ module SinatraMore
5
5
  include Rack::Test::Methods
6
6
 
7
7
  def app
8
- CLASS_NAME
8
+ CLASS_NAME.tap { |app| app.set :environment, :test }
9
9
  end
10
10
  end
11
11
  TEST
@@ -6,7 +6,7 @@ module SinatraMore
6
6
  end
7
7
 
8
8
  def app
9
- CLASS_NAME
9
+ CLASS_NAME.tap { |app| app.set :environment, :test }
10
10
  end
11
11
  TEST
12
12
 
@@ -5,7 +5,7 @@ module SinatraMore
5
5
  include Rack::Test::Methods
6
6
 
7
7
  def app
8
- CLASS_NAME
8
+ CLASS_NAME.tap { |app| app.set :environment, :test }
9
9
  end
10
10
  end
11
11
  TEST
@@ -5,7 +5,7 @@ module SinatraMore
5
5
  include Rack::Test::Methods
6
6
 
7
7
  def app
8
- CLASS_NAME
8
+ CLASS_NAME.tap { |app| app.set :environment, :test }
9
9
  end
10
10
  end
11
11
  TEST
data/sinatra_more.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra_more}
8
- s.version = "0.3.6"
8
+ s.version = "0.3.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nathan Esquenazi"]
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  "generators/base_app/app/.empty_directory",
32
32
  "generators/base_app/app/helpers/.empty_directory",
33
33
  "generators/base_app/app/helpers/view_helpers.rb",
34
+ "generators/base_app/app/mailers/.empty_directory",
34
35
  "generators/base_app/app/models/.empty_directory",
35
36
  "generators/base_app/app/routes/.empty_directory",
36
37
  "generators/base_app/app/views/.empty_directory",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_more
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi
@@ -124,6 +124,7 @@ files:
124
124
  - generators/base_app/app/.empty_directory
125
125
  - generators/base_app/app/helpers/.empty_directory
126
126
  - generators/base_app/app/helpers/view_helpers.rb
127
+ - generators/base_app/app/mailers/.empty_directory
127
128
  - generators/base_app/app/models/.empty_directory
128
129
  - generators/base_app/app/routes/.empty_directory
129
130
  - generators/base_app/app/views/.empty_directory