sinatra-activerecord 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d2fbc07c0f9935460a455c4d0185a42f4ad58f2
4
- data.tar.gz: 3ecba535d8d83ac4bf2abcd4a2c2c30dff1c32a2
3
+ metadata.gz: c737e07b8e8d9daddeff819892c5ad278036564b
4
+ data.tar.gz: 797f41088003b92ec1d44edfbcb57b2a9df18132
5
5
  SHA512:
6
- metadata.gz: a92aaadbcedd03058ae6d7362bf20601ccb3082f73350375fa014aa693bdd762d3207124cc43d35cddba31c423f9e7507036a29e4c6afd8a61d518434f871bee
7
- data.tar.gz: 05d38c9ead41262cd6a851688d9b3c0223fdf7c1c73c6d9a5fe481d2c0c6dca0c6afc81902415c9c221fc1da5390c8d065e1dca56c02428a4169f9771b643581
6
+ metadata.gz: a6a58243dc89f9e5faa22a5272950bc5cf007d29a5abbbacc70fc0ec5b93aa88ecf381cbb148984067802a9141fbe78ae5f06b4d1df7a3ce33b8ee5eef351e99
7
+ data.tar.gz: deca75897d21f51defb9f1ca72b610b201f2239972c6fd69b1f84792ee75229cf873ae6b617421828bf9db9fae33651806998285c54fe6cea36c2229383e9634
data/README.md CHANGED
@@ -4,12 +4,6 @@ Extends [Sinatra](http://www.sinatrarb.com/) with extension methods and Rake
4
4
  tasks for dealing with an SQL database using the
5
5
  [ActiveRecord ORM](https://github.com/rails/rails/tree/master/activerecord).
6
6
 
7
- ## ActiveRecord 4.1
8
-
9
- For ActiveRecord 4.1 use sinatra-activerecord `2.0.0.rc2`. I recommend upgrading
10
- even if you don't use ActiveRecord 4.1, because it includes *all* the Rake tasks
11
- that ActiveRecord has.
12
-
13
7
  ## Setup
14
8
 
15
9
  Put it in your `Gemfile`, along with the adapter of your database. For
@@ -28,11 +22,13 @@ connection:
28
22
  # app.rb
29
23
  require "sinatra/activerecord"
30
24
 
31
- set :database, "sqlite3:///foo.sqlite3"
25
+ set :database, {adapter: "sqlite3", database: "foo.sqlite3"}
26
+ # or set :database_file, "path/to/database.yml"
32
27
  ```
33
28
 
34
- Alternatively, you can set the database with a hash or a YAML file. Take a look at
35
- [this wiki](https://github.com/janko-m/sinatra-activerecord/wiki/Alternative-database-setup).
29
+ If you have a `config/database.yml`, it will automatically be loaded, no need
30
+ to specify it. Also, in production, the `$DATABASE_URL` environment variable
31
+ will automatically be read as the database (if you haven't specified otherwise).
36
32
 
37
33
  Note that in **modular** Sinatra applications you will need to first register
38
34
  the extension:
@@ -55,17 +51,19 @@ In the Terminal test that it works:
55
51
 
56
52
  ```sh
57
53
  $ rake -T
58
- rake db:create # create the database from config/database.yml from the current Sinatra env
59
- rake db:create_migration # create an ActiveRecord migration
60
- rake db:drop # drops the data from config/database.yml from the current Sinatra env
61
- rake db:migrate # migrate the database (use version with VERSION=n)
62
- rake db:migrate:reset # drops and creates the database and then runs the migrations
63
- rake db:reset # drops and creates the database
64
- rake db:rollback # roll back the migration (use steps with STEP=n)
65
- rake db:schema:dump # dump schema into file
66
- rake db:schema:load # load schema into database
67
- rake db:seed # load the seed data from db/seeds.rb
68
- rake db:setup # create the database and load the schema
54
+ rake db:create # Create the database from DATABASE_URL or config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config)
55
+ rake db:create_migration # Create a migration (parameters: NAME, VERSION)
56
+ rake db:drop # Drops the database using DATABASE_URL or the current Rails.env (use db:drop:all to drop all databases)
57
+ rake db:fixtures:load # Load fixtures into the current environment's database
58
+ rake db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false)
59
+ rake db:migrate:status # Display status of migrations
60
+ rake db:rollback # Rolls the schema back to the previous version (specify steps w/ STEP=n)
61
+ rake db:schema:dump # Create a db/schema.rb file that can be portably used against any DB supported by AR
62
+ rake db:schema:load # Load a schema.rb file into the database
63
+ rake db:seed # Load the seed data from db/seeds.rb
64
+ rake db:setup # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)
65
+ rake db:structure:dump # Dump the database structure to db/structure.sql
66
+ rake db:version # Retrieves the current schema version number
69
67
  ```
70
68
 
71
69
  And that's it, you're all set :)
@@ -18,7 +18,7 @@ module Sinatra
18
18
  def self.registered(app)
19
19
  app.set :database, ENV['DATABASE_URL'] if ENV['DATABASE_URL']
20
20
  app.set :database_file, "#{Dir.pwd}/config/database.yml" if File.exists?("#{Dir.pwd}/config/database.yml")
21
- ActiveRecord::Base.logger = Logger.new(STDOUT)
21
+ ActiveRecord::Base.logger = Logger.new(STDOUT) unless defined?(Rake)
22
22
 
23
23
  app.helpers ActiveRecordHelper
24
24
 
@@ -15,5 +15,6 @@ ActiveRecord::Tasks::DatabaseTasks.tap do |config|
15
15
  config.database_configuration = ActiveRecord::Base.configurations
16
16
  end
17
17
 
18
+ Rake::Task["db:load_config"].clear
18
19
  Rake::Task.define_task("db:environment")
19
20
  Rake::Task["db:test:deprecated"].clear if Rake::Task.task_defined?("db:test:deprecated")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany