vizzuality-sequel-rails 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/.document +5 -0
  2. data/.gitignore +29 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +112 -0
  5. data/History.md +77 -0
  6. data/LICENSE +20 -0
  7. data/README.rdoc +102 -0
  8. data/Rakefile +9 -0
  9. data/autotest/discover.rb +1 -0
  10. data/lib/generators/sequel.rb +83 -0
  11. data/lib/generators/sequel/migration/migration_generator.rb +45 -0
  12. data/lib/generators/sequel/migration/templates/migration.rb +48 -0
  13. data/lib/generators/sequel/model/model_generator.rb +29 -0
  14. data/lib/generators/sequel/model/templates/migration.rb +16 -0
  15. data/lib/generators/sequel/model/templates/model.rb +6 -0
  16. data/lib/generators/sequel/observer/observer_generator.rb +19 -0
  17. data/lib/generators/sequel/observer/templates/observer.rb +7 -0
  18. data/lib/sequel-rails.rb +7 -0
  19. data/lib/sequel-rails/configuration.rb +63 -0
  20. data/lib/sequel-rails/migrations.rb +30 -0
  21. data/lib/sequel-rails/railtie.rb +93 -0
  22. data/lib/sequel-rails/railties/benchmarking_mixin.rb +23 -0
  23. data/lib/sequel-rails/railties/controller_runtime.rb +43 -0
  24. data/lib/sequel-rails/railties/database.rake +167 -0
  25. data/lib/sequel-rails/railties/i18n_support.rb +12 -0
  26. data/lib/sequel-rails/railties/log_subscriber.rb +31 -0
  27. data/lib/sequel-rails/runtime.rb +14 -0
  28. data/lib/sequel-rails/session_store.rb +82 -0
  29. data/lib/sequel-rails/setup.rb +27 -0
  30. data/lib/sequel-rails/storage.rb +222 -0
  31. data/lib/sequel-rails/version.rb +5 -0
  32. data/lib/sequel/plugins/rails_extensions.rb +35 -0
  33. data/spec/rcov.opts +6 -0
  34. data/spec/spec.opts +4 -0
  35. data/spec/spec_helper.rb +7 -0
  36. data/tasks/ci.rake +1 -0
  37. data/tasks/clean.rake +6 -0
  38. data/tasks/metrics.rake +37 -0
  39. data/tasks/spec.rake +30 -0
  40. data/tasks/yard.rake +9 -0
  41. data/tasks/yardstick.rake +20 -0
  42. data/vizzuality-sequel-rails.gemspec +29 -0
  43. metadata +208 -0
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,29 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ doc
20
+ pkg
21
+ tmp
22
+ log
23
+ .yardoc
24
+
25
+ ## PROJECT::SPECIFIC
26
+ vendor
27
+ .bundle
28
+ .rvmrc
29
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,112 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vizzuality-sequel-rails (0.3.4)
5
+ rails (~> 3.2.0)
6
+ sequel (~> 3.28)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ ZenTest (4.6.2)
12
+ actionmailer (3.2.7)
13
+ actionpack (= 3.2.7)
14
+ mail (~> 2.4.4)
15
+ actionpack (3.2.7)
16
+ activemodel (= 3.2.7)
17
+ activesupport (= 3.2.7)
18
+ builder (~> 3.0.0)
19
+ erubis (~> 2.7.0)
20
+ journey (~> 1.0.4)
21
+ rack (~> 1.4.0)
22
+ rack-cache (~> 1.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.1.3)
25
+ activemodel (3.2.7)
26
+ activesupport (= 3.2.7)
27
+ builder (~> 3.0.0)
28
+ activerecord (3.2.7)
29
+ activemodel (= 3.2.7)
30
+ activesupport (= 3.2.7)
31
+ arel (~> 3.0.2)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.2.7)
34
+ activemodel (= 3.2.7)
35
+ activesupport (= 3.2.7)
36
+ activesupport (3.2.7)
37
+ i18n (~> 0.6)
38
+ multi_json (~> 1.0)
39
+ arel (3.0.2)
40
+ autotest (4.4.6)
41
+ ZenTest (>= 4.4.1)
42
+ builder (3.0.0)
43
+ diff-lcs (1.1.3)
44
+ erubis (2.7.0)
45
+ hike (1.2.1)
46
+ i18n (0.6.0)
47
+ journey (1.0.4)
48
+ json (1.7.4)
49
+ mail (2.4.4)
50
+ i18n (>= 0.4.0)
51
+ mime-types (~> 1.16)
52
+ treetop (~> 1.4.8)
53
+ mime-types (1.19)
54
+ multi_json (1.3.6)
55
+ polyglot (0.3.3)
56
+ rack (1.4.1)
57
+ rack-cache (1.2)
58
+ rack (>= 0.4)
59
+ rack-ssl (1.3.2)
60
+ rack
61
+ rack-test (0.6.1)
62
+ rack (>= 1.0)
63
+ rails (3.2.7)
64
+ actionmailer (= 3.2.7)
65
+ actionpack (= 3.2.7)
66
+ activerecord (= 3.2.7)
67
+ activeresource (= 3.2.7)
68
+ activesupport (= 3.2.7)
69
+ bundler (~> 1.0)
70
+ railties (= 3.2.7)
71
+ railties (3.2.7)
72
+ actionpack (= 3.2.7)
73
+ activesupport (= 3.2.7)
74
+ rack-ssl (~> 1.3.2)
75
+ rake (>= 0.8.7)
76
+ rdoc (~> 3.4)
77
+ thor (>= 0.14.6, < 2.0)
78
+ rake (0.8.7)
79
+ rcov (0.9.11)
80
+ rdoc (3.12)
81
+ json (~> 1.4)
82
+ rspec (2.7.0)
83
+ rspec-core (~> 2.7.0)
84
+ rspec-expectations (~> 2.7.0)
85
+ rspec-mocks (~> 2.7.0)
86
+ rspec-core (2.7.1)
87
+ rspec-expectations (2.7.0)
88
+ diff-lcs (~> 1.1.2)
89
+ rspec-mocks (2.7.0)
90
+ sequel (3.38.0)
91
+ sprockets (2.1.3)
92
+ hike (~> 1.2)
93
+ rack (~> 1.0)
94
+ tilt (~> 1.1, != 1.3.0)
95
+ thor (0.15.4)
96
+ tilt (1.3.3)
97
+ treetop (1.4.10)
98
+ polyglot
99
+ polyglot (>= 0.3.1)
100
+ tzinfo (0.3.33)
101
+ yard (0.7.3)
102
+
103
+ PLATFORMS
104
+ ruby
105
+
106
+ DEPENDENCIES
107
+ autotest (~> 4.4.6)
108
+ rake (~> 0.8.7)
109
+ rcov (~> 0.9.11)
110
+ rspec (~> 2.7.0)
111
+ vizzuality-sequel-rails!
112
+ yard (~> 0.5)
@@ -0,0 +1,77 @@
1
+ 0.3.5 - dev
2
+ ===========
3
+
4
+ 0.3.4
5
+ =====
6
+
7
+ * Make `rake db:schema:dump` generate a schema file which contains foreign_keys
8
+ and uses db types instead of ruby equivalents. This ensure loading the schema
9
+ file will result in a correct db
10
+
11
+ * Map some Sequel specific exceptions to `ActiveRecord` equivalents, in
12
+ `config.action_dispatch.rescue_responses`. This allows controllers to behave
13
+ more like `ActiveRecord` when Sequel raises exceptions. (Joshua Hansen)
14
+
15
+ * New Sequel plugin added to all `Sequel::Model` which allows to use
16
+ `Sequel::Model#find!` which will raise an exception if record does not exists.
17
+ This method is an alias to `Sequel::Model#[]` method. (Joshua Hansen)
18
+
19
+ 0.3.3
20
+ =====
21
+
22
+ * Fix generators and use better model and migration template (Joshua Hansen)
23
+
24
+ 0.3.2
25
+ =====
26
+ * Ignore environments without `database` key (like ActiveRecord do it), to allow
27
+ shared configurations in `database.yml`.
28
+ * Fix db creation commands to let the `system` method escape the arguments
29
+ * Fix error when using `mysql2` gem
30
+
31
+ 0.3.1
32
+ =====
33
+ * Make `db:schema:dump` Rake task depends on Rails `environment` task (Gabor Ratky)
34
+
35
+ 0.3.0
36
+ =====
37
+ * Update dependency to Rails (~> 3.2.0)
38
+
39
+ 0.2.3
40
+ =====
41
+ * Set `PGPASSWORD` environment variable before trying to create DB using `createdb`
42
+
43
+ 0.2.2
44
+ =====
45
+ * Ensure Sequel is disconnected before trying to drop a db
46
+
47
+ 0.2.1
48
+ =====
49
+ * Make dependency on Sequel more open (~> 3.28)
50
+
51
+ 0.2.0
52
+ =====
53
+ * Fix deprecation warning for config.generators
54
+ * Update dependency to Rails 3.1.1
55
+ * Update dependency to Sequel 3.28.0
56
+ * Update dependency to RSpec 2.7.0
57
+
58
+ 0.1.4
59
+ =====
60
+ * Merged in changes to rake tasks and timestamp migrations
61
+
62
+ 0.1.3
63
+ =====
64
+ * update sequel dependency, configuration change
65
+
66
+ 0.1.2
67
+ =====
68
+ * fixed log_subscriber bug that 0.1.1 was -supposed- to fix.
69
+ * fixed controller_runtime bug
70
+
71
+ 0.1.1
72
+ =====
73
+ * bug fixes, no additional functionality
74
+
75
+ 0.1.0
76
+ =====
77
+ * initial release
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009-2010 The sequel-rails team
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,102 @@
1
+ = sequel-rails
2
+
3
+ This gem provides the railtie that allows {sequel}[http://github.com/jeremyevans/sequel] to hook into {rails3}[http://github.com/rails/rails] and thus behave like a rails framework component. Just like activerecord does in rails, {sequel-rails}[http://github.com/talentbox/sequel-rails] uses the railtie API to hook into rails. The two are actually hooked into rails almost identically.
4
+
5
+ The code for this gem was initially taken from the excellent {dm-rails}[http://github.com/datamapper/dm-rails] project.
6
+
7
+ This is a fork of {brasten}[https://github.com/brasten]'s {sequel-rails}[https://github.com/brasten/sequel-rails] that has been updated to support newer versions of rails.
8
+
9
+ == Using sequel-rails
10
+
11
+ Using sequel with rails3 requires a couple minor changes.
12
+
13
+ First, add the following to your Gemfile:
14
+
15
+ gem 'talentbox-sequel-rails'
16
+
17
+ ... be sure to run "bundle install" if needed!
18
+
19
+ Secondly, you'll need to require "sequel-rails/railtie" in your config/application.rb file, and not require activerecord. The top of your config/application.rb will probably look something like:
20
+
21
+ # require 'rails/all'
22
+
23
+ # Instead of 'rails/all', require these:
24
+ require "action_controller/railtie"
25
+ require "sequel-rails/railtie"
26
+ require "action_mailer/railtie"
27
+
28
+
29
+ After those changes, you should be good to go!
30
+
31
+
32
+ == Available sequel specific rake tasks
33
+
34
+ To get a list of all available rake tasks in your rails3 app, issue the usual
35
+
36
+ vendor/bin/rake -T
37
+
38
+ Once you do that, you will see the following rake tasks among others. These are the ones that sequel-rails added for us.
39
+
40
+ ...
41
+ vendor/bin/rake db:create # Create the database(s) defined in config/database.yml for the current Rails.env - also creates the test database(s) if Rails.env.development?
42
+ vendor/bin/rake db:create:all # Create all the local databases defined in config/database.yml
43
+ vendor/bin/rake db:drop # Drops the database(s) for the current Rails.env - also drops the test database(s) if Rails.env.development?
44
+ vendor/bin/rake db:drop:all # Drop all the local databases defined in config/database.yml
45
+ vendor/bin/rake db:migrate # Migrate the database to the latest version
46
+ vendor/bin/rake db:migrate:down[version] # Migrate down using migrations
47
+ vendor/bin/rake db:migrate:up[version] # Migrate up using migrations
48
+ vendor/bin/rake db:seed # Load the seed data from db/seeds.rb
49
+ vendor/bin/rake db:sessions:clear # Clear the sessions table for SequelStore
50
+ vendor/bin/rake db:sessions:create # Creates the sessions table for SequelStore
51
+ vendor/bin/rake db:setup # Create the database, load the schema, and initialize with the seed data
52
+ ...
53
+
54
+
55
+ == Current Issues
56
+
57
+ * There are bound to be a lot, but I'm not yet sure what they are
58
+
59
+ == TODO (not necessarily in that order)
60
+
61
+ * SPECS
62
+ * README changes
63
+ * Publish SQL issued by sequel to rails subscribers
64
+
65
+ == Credits
66
+
67
+ The {dm-rails}[http://github.com/datamapper/dm-rails] team wrote most of this code, I just sequel-ized it.
68
+
69
+
70
+
71
+ == Note on Patches/Pull Requests
72
+
73
+ * Fork the project.
74
+ * Make your feature addition or bug fix.
75
+ * Add tests for it. This is important so I don't break it in a
76
+ future version unintentionally.
77
+ * Commit, do not mess with rakefile, version, or history.
78
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
79
+ * Send me a pull request. Bonus points for topic branches.
80
+
81
+
82
+ == The sequel-rails team
83
+
84
+ {Original project}[https://github.com/brasten/sequel-rails]:
85
+
86
+ * Brasten Sager (brasten)
87
+
88
+ This fork:
89
+
90
+ * Jonathan Tron (JonathanTron)
91
+
92
+ == Contributors
93
+
94
+ Improvements has been made by those awesome contributors:
95
+
96
+ * Benjamin Atkin (benatkin)
97
+ * Gabor Ratky (rgabo)
98
+ * Joshua Hansen (binarypaladin)
99
+
100
+ == Copyright
101
+
102
+ Copyright (c) 2010 The sequel-rails team. See {LICENSE}[http://github.com/brasten/sequel-rails/blob/master/LICENSE] for details.
@@ -0,0 +1,9 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ Bundler::GemHelper.install_tasks
8
+
9
+ FileList['tasks/**/*.rake'].each { |task| import task }
@@ -0,0 +1 @@
1
+ Autotest.add_discovery { "rspec" }
@@ -0,0 +1,83 @@
1
+ require 'rails/generators/named_base'
2
+ require 'rails/generators/migration'
3
+ require 'rails/generators/active_model'
4
+
5
+ module Sequel
6
+ module Generators
7
+
8
+ class Base < ::Rails::Generators::NamedBase #:nodoc:
9
+
10
+ include ::Rails::Generators::Migration
11
+
12
+ def self.source_root
13
+ @_sequel_source_root ||=
14
+ File.expand_path("../#{base_name}/#{generator_name}/templates", __FILE__)
15
+ end
16
+
17
+ protected
18
+
19
+ # Sequel does not care if migrations have the same name as long as
20
+ # they have different ids.
21
+ #
22
+ def migration_exists?(dirname, file_name) #:nodoc:
23
+ false
24
+ end
25
+
26
+ # Implement the required interface for Rails::Generators::Migration.
27
+ #
28
+ def self.next_migration_number(dirname) #:nodoc:
29
+ next_migration_number = current_migration_number(dirname) + 1
30
+ [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
31
+ end
32
+
33
+ end
34
+
35
+ class ActiveModel < ::Rails::Generators::ActiveModel #:nodoc:
36
+ def self.all(klass)
37
+ "#{klass}.all"
38
+ end
39
+
40
+ def self.find(klass, params=nil)
41
+ "#{klass}.find!(#{params})"
42
+ end
43
+
44
+ def self.build(klass, params=nil)
45
+ if params
46
+ "#{klass}.new(#{params})"
47
+ else
48
+ "#{klass}.new"
49
+ end
50
+ end
51
+
52
+ def save
53
+ "#{name}.save"
54
+ end
55
+
56
+ def update_attributes(params=nil)
57
+ "#{name}.update(#{params})"
58
+ end
59
+
60
+ def errors
61
+ "#{name}.errors"
62
+ end
63
+
64
+ def destroy
65
+ "#{name}.destroy"
66
+ end
67
+ end
68
+
69
+ end
70
+ end
71
+
72
+ module Rails
73
+
74
+ module Generators
75
+ class GeneratedAttribute #:nodoc:
76
+ def type_class
77
+ return 'DateTime' if type.to_s == 'datetime'
78
+ return type.to_s.camelcase
79
+ end
80
+ end
81
+ end
82
+
83
+ end