talentbox-sequel-rails 0.3.2 → 0.3.3
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/Gemfile.lock +4 -4
- data/History.md +29 -12
- data/README.rdoc +8 -0
- data/lib/generators/sequel.rb +1 -1
- data/lib/generators/sequel/migration/migration_generator.rb +21 -6
- data/lib/generators/sequel/migration/templates/migration.rb +41 -9
- data/lib/generators/sequel/model/model_generator.rb +6 -0
- data/lib/generators/sequel/model/templates/migration.rb +16 -0
- data/lib/generators/sequel/model/templates/model.rb +4 -1
- data/lib/sequel-rails/version.rb +1 -1
- metadata +19 -18
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
talentbox-sequel-rails (0.3.
|
4
|
+
talentbox-sequel-rails (0.3.3)
|
5
5
|
rails (~> 3.2.0)
|
6
6
|
sequel (~> 3.28)
|
7
7
|
|
@@ -45,13 +45,13 @@ GEM
|
|
45
45
|
hike (1.2.1)
|
46
46
|
i18n (0.6.0)
|
47
47
|
journey (1.0.3)
|
48
|
-
json (1.
|
48
|
+
json (1.7.3)
|
49
49
|
mail (2.4.4)
|
50
50
|
i18n (>= 0.4.0)
|
51
51
|
mime-types (~> 1.16)
|
52
52
|
treetop (~> 1.4.8)
|
53
53
|
mime-types (1.18)
|
54
|
-
multi_json (1.3.
|
54
|
+
multi_json (1.3.5)
|
55
55
|
polyglot (0.3.3)
|
56
56
|
rack (1.4.1)
|
57
57
|
rack-cache (1.2)
|
@@ -88,7 +88,7 @@ GEM
|
|
88
88
|
diff-lcs (~> 1.1.2)
|
89
89
|
rspec-mocks (2.7.0)
|
90
90
|
sequel (3.34.1)
|
91
|
-
sprockets (2.1.
|
91
|
+
sprockets (2.1.3)
|
92
92
|
hike (~> 1.2)
|
93
93
|
rack (~> 1.0)
|
94
94
|
tilt (~> 1.1, != 1.3.0)
|
data/History.md
CHANGED
@@ -1,42 +1,59 @@
|
|
1
|
-
|
1
|
+
0.3.3
|
2
|
+
=====
|
3
|
+
|
4
|
+
* Fix generators and use better model and migration template (Joshua Hansen)
|
5
|
+
|
6
|
+
0.3.2
|
7
|
+
=====
|
2
8
|
* Ignore environments without `database` key (like ActiveRecord do it), to allow
|
3
9
|
shared configurations in `database.yml`.
|
4
10
|
* Fix db creation commands to let the `system` method escape the arguments
|
5
11
|
* Fix error when using `mysql2` gem
|
6
12
|
|
7
|
-
|
13
|
+
0.3.1
|
14
|
+
=====
|
8
15
|
* Make `db:schema:dump` Rake task depends on Rails `environment` task (Gabor Ratky)
|
9
16
|
|
10
|
-
|
17
|
+
0.3.0
|
18
|
+
=====
|
11
19
|
* Update dependency to Rails (~> 3.2.0)
|
12
20
|
|
13
|
-
|
21
|
+
0.2.3
|
22
|
+
=====
|
14
23
|
* Set `PGPASSWORD` environment variable before trying to create DB using `createdb`
|
15
24
|
|
16
|
-
|
25
|
+
0.2.2
|
26
|
+
=====
|
17
27
|
* Ensure Sequel is disconnected before trying to drop a db
|
18
28
|
|
19
|
-
|
29
|
+
0.2.1
|
30
|
+
=====
|
20
31
|
* Make dependency on Sequel more open (~> 3.28)
|
21
32
|
|
22
|
-
|
33
|
+
0.2.0
|
34
|
+
=====
|
23
35
|
* Fix deprecation warning for config.generators
|
24
36
|
* Update dependency to Rails 3.1.1
|
25
37
|
* Update dependency to Sequel 3.28.0
|
26
38
|
* Update dependency to RSpec 2.7.0
|
27
39
|
|
28
|
-
|
40
|
+
0.1.4
|
41
|
+
=====
|
29
42
|
* Merged in changes to rake tasks and timestamp migrations
|
30
43
|
|
31
|
-
|
44
|
+
0.1.3
|
45
|
+
=====
|
32
46
|
* update sequel dependency, configuration change
|
33
47
|
|
34
|
-
|
48
|
+
0.1.2
|
49
|
+
=====
|
35
50
|
* fixed log_subscriber bug that 0.1.1 was -supposed- to fix.
|
36
51
|
* fixed controller_runtime bug
|
37
52
|
|
38
|
-
|
53
|
+
0.1.1
|
54
|
+
=====
|
39
55
|
* bug fixes, no additional functionality
|
40
56
|
|
41
|
-
|
57
|
+
0.1.0
|
58
|
+
=====
|
42
59
|
* initial release
|
data/README.rdoc
CHANGED
@@ -89,6 +89,14 @@ This fork:
|
|
89
89
|
|
90
90
|
* Jonathan Tron (JonathanTron)
|
91
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
|
+
|
92
100
|
== Copyright
|
93
101
|
|
94
102
|
Copyright (c) 2010 The sequel-rails team. See {LICENSE}[http://github.com/brasten/sequel-rails/blob/master/LICENSE] for details.
|
data/lib/generators/sequel.rb
CHANGED
@@ -13,14 +13,29 @@ module Sequel
|
|
13
13
|
migration_template "migration.rb", "db/migrate/#{file_name}.rb"
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
attr_reader :migration_action
|
16
|
+
attr_reader :migration_action, :table_action, :column_action, :use_change
|
19
17
|
|
18
|
+
protected
|
20
19
|
def set_local_assigns!
|
21
|
-
if file_name =~ /^(
|
22
|
-
@
|
23
|
-
@table_name
|
20
|
+
if file_name =~ /^(create|drop)_(.*)$/
|
21
|
+
@table_action = $1
|
22
|
+
@table_name = $2.pluralize
|
23
|
+
@column_action = 'add'
|
24
|
+
@use_change = @table_action == 'create' ? true : false
|
25
|
+
elsif file_name =~ /^(add|drop|remove)_.*_(?:to|from)_(.*)/
|
26
|
+
@table_action = 'alter'
|
27
|
+
@table_name = $2.pluralize
|
28
|
+
@column_action = $1 == 'add' ? 'add' : 'drop'
|
29
|
+
@use_change = @column_action == 'add' ? true : false
|
30
|
+
else
|
31
|
+
@table_action = 'alter'
|
32
|
+
if file_name =~ /^(alter)_(.*)/
|
33
|
+
@table_name = $2.pluralize
|
34
|
+
else
|
35
|
+
@table_name = file_name.pluralize
|
36
|
+
end
|
37
|
+
@use_change = false
|
38
|
+
@column_action = 'add'
|
24
39
|
end
|
25
40
|
end
|
26
41
|
|
@@ -1,16 +1,48 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
Sequel.migration do
|
2
|
+
<%- if use_change -%>
|
3
|
+
change do
|
4
|
+
<%= table_action %>_table :<%= table_name %> do
|
5
|
+
<%- if table_action == 'create' -%>
|
5
6
|
primary_key :id
|
6
|
-
|
7
|
+
<%- end -%>
|
8
|
+
<%- attributes.each do |attribute| -%>
|
9
|
+
<%- if table_action == 'create' -%>
|
7
10
|
<%= attribute.type_class %> :<%= attribute.name %>
|
8
|
-
|
11
|
+
<%- else -%>
|
12
|
+
<%= column_action %>_column :<%= attribute.name %><% if column_action == 'add' %>, <%= attribute.type_class %><% end %>
|
13
|
+
<%- end -%>
|
14
|
+
<%- end -%>
|
9
15
|
end
|
10
16
|
end
|
11
|
-
|
12
|
-
|
17
|
+
<%- else -%>
|
18
|
+
up do
|
19
|
+
<%- if table_action == 'drop' -%>
|
13
20
|
drop_table :<%= table_name %>
|
21
|
+
<%- else -%>
|
22
|
+
<%= table_action %>_table :<%= table_name %> do
|
23
|
+
<%- attributes.each do |attribute| -%>
|
24
|
+
<%- if table_action == 'create' -%>
|
25
|
+
<%= attribute.type_class %> :<%= attribute.name %>
|
26
|
+
<%- else -%>
|
27
|
+
<%= column_action %>_column :<%= attribute.name %><% if column_action == 'add' %>, <%= attribute.type_class %><% end %>
|
28
|
+
<%- end -%>
|
29
|
+
<%- end -%>
|
30
|
+
end
|
31
|
+
<%- end -%>
|
32
|
+
end
|
33
|
+
|
34
|
+
down do
|
35
|
+
<%- alter_table_action = (table_action == 'drop') ? 'create' : table_action -%>
|
36
|
+
<%- alter_column_action = (column_action == 'add') ? 'drop' : 'add' -%>
|
37
|
+
<%= alter_table_action %>_table :<%= table_name %> do
|
38
|
+
<%- attributes.each do |attribute| -%>
|
39
|
+
<%- if alter_table_action == 'create' -%>
|
40
|
+
<%= attribute.type_class %> :<%= attribute.name %>
|
41
|
+
<%- else -%>
|
42
|
+
<%= alter_column_action %>_column :<%= attribute.name %><% if alter_column_action == 'add' %>, <%= attribute.type_class %><% end %>
|
43
|
+
<%- end -%>
|
44
|
+
<%- end -%>
|
45
|
+
end
|
14
46
|
end
|
15
|
-
|
47
|
+
<%- end -%>
|
16
48
|
end
|
@@ -8,9 +8,15 @@ module Sequel
|
|
8
8
|
|
9
9
|
check_class_collision
|
10
10
|
|
11
|
+
class_option :migration, :type => :boolean
|
11
12
|
class_option :timestamps, :type => :boolean
|
12
13
|
class_option :parent, :type => :string, :desc => "The parent class for the generated model"
|
13
14
|
|
15
|
+
def create_migration_file
|
16
|
+
return unless options[:migration]
|
17
|
+
migration_template "migration.rb", "db/migrate/create_#{table_name}.rb"
|
18
|
+
end
|
19
|
+
|
14
20
|
def create_model_file
|
15
21
|
template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
|
16
22
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
change do
|
3
|
+
|
4
|
+
create_table :<%= table_name %> do
|
5
|
+
primary_key :id
|
6
|
+
<%- if options[:timestamps] -%>
|
7
|
+
DateTime :created_at
|
8
|
+
DateTime :updated_at
|
9
|
+
<%- end -%>
|
10
|
+
<%- attributes.each do |attribute| -%>
|
11
|
+
<%= attribute.type_class %> :<%= attribute.name %>
|
12
|
+
<%- end -%>
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/sequel-rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: talentbox-sequel-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-06-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sequel
|
17
|
-
requirement: &
|
17
|
+
requirement: &2162139960 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '3.28'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2162139960
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rails
|
28
|
-
requirement: &
|
28
|
+
requirement: &2162137040 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 3.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2162137040
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rake
|
39
|
-
requirement: &
|
39
|
+
requirement: &2162133700 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 0.8.7
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2162133700
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: yard
|
50
|
-
requirement: &
|
50
|
+
requirement: &2162129900 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0.5'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2162129900
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: rspec
|
61
|
-
requirement: &
|
61
|
+
requirement: &2162126940 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 2.7.0
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2162126940
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: autotest
|
72
|
-
requirement: &
|
72
|
+
requirement: &2162122940 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 4.4.6
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2162122940
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rcov
|
83
|
-
requirement: &
|
83
|
+
requirement: &2162120160 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ~>
|
@@ -88,7 +88,7 @@ dependencies:
|
|
88
88
|
version: 0.9.11
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2162120160
|
92
92
|
description: Integrate Sequel with Rails 3
|
93
93
|
email:
|
94
94
|
- brasten@gmail.com
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/generators/sequel/migration/migration_generator.rb
|
113
113
|
- lib/generators/sequel/migration/templates/migration.rb
|
114
114
|
- lib/generators/sequel/model/model_generator.rb
|
115
|
+
- lib/generators/sequel/model/templates/migration.rb
|
115
116
|
- lib/generators/sequel/model/templates/model.rb
|
116
117
|
- lib/generators/sequel/observer/observer_generator.rb
|
117
118
|
- lib/generators/sequel/observer/templates/observer.rb
|
@@ -154,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
155
|
version: '0'
|
155
156
|
segments:
|
156
157
|
- 0
|
157
|
-
hash:
|
158
|
+
hash: 1061361385848004113
|
158
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
160
|
none: false
|
160
161
|
requirements:
|
@@ -163,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
164
|
version: '0'
|
164
165
|
segments:
|
165
166
|
- 0
|
166
|
-
hash:
|
167
|
+
hash: 1061361385848004113
|
167
168
|
requirements: []
|
168
169
|
rubyforge_project:
|
169
170
|
rubygems_version: 1.8.15
|