hobo_fields 1.3.0.pre31 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0.pre31
1
+ 1.3.0
data/hobo_fields.gemspec CHANGED
@@ -11,7 +11,6 @@ Gem::Specification.new do |s|
11
11
  s.summary = 'Rich field types and migration generator for Rails'
12
12
  s.description = 'Rich field types and migration generator for Rails'
13
13
 
14
- s.add_runtime_dependency('rails', [">= 3.0.0"])
15
14
  s.add_runtime_dependency('hobo_support', ["= #{version}"])
16
15
  s.add_development_dependency('rubydoctest', [">= 0"])
17
16
  s.add_development_dependency('redcloth', [">= 0"]) # for testing rich types
@@ -130,7 +130,7 @@ module Generators
130
130
  all_models = table_model_classes
131
131
  hobo_models = all_models.select { |m| m.try.include_in_migration && m.name.underscore.not_in?(ignore_model_names) }
132
132
  non_hobo_models = all_models - hobo_models
133
- db_tables = connection.tables - Migrator.ignore_tables.*.to_s - non_hobo_models.*.table_name
133
+ db_tables = connection.tables - Migrator.ignore_tables.*.to_s - non_hobo_models.reject { |t| t.try.hobo_shim? }.*.table_name
134
134
  [hobo_models, db_tables]
135
135
  end
136
136
 
@@ -391,6 +391,8 @@ module Generators
391
391
  def drop_index(table, name)
392
392
  # see https://hobo.lighthouseapp.com/projects/8324/tickets/566
393
393
  # for why the rescue exists
394
+ max_length = connection.index_name_length
395
+ name = name[0,max_length] if name.length > max_length
394
396
  "remove_index :#{table}, :name => :#{name} rescue ActiveRecord::StatementInvalid"
395
397
  end
396
398
 
@@ -28,7 +28,17 @@ module HoboFields
28
28
  def to_add_statement(new_table_name)
29
29
  r = "add_index :#{new_table_name}, #{fields.*.to_sym.inspect}"
30
30
  r += ", :unique => true" if unique
31
- r += ", :name => '#{name}'" unless default_name?
31
+ if default_name?
32
+ check_name = @model.connection.index_name(self.table, :column => self.fields)
33
+ else
34
+ check_name = name
35
+ end
36
+ if check_name.length > @model.connection.index_name_length
37
+ r += ", :name => '#{name[0,@model.connection.index_name_length]}'"
38
+ $stderr.puts("WARNING: index name #{check_name} too long, trimming")
39
+ else
40
+ r += ", :name => '#{name}'" unless default_name?
41
+ end
32
42
  r
33
43
  end
34
44
 
@@ -170,7 +170,11 @@ module HoboFields
170
170
 
171
171
  def self.add_index_for_field(name, args, options)
172
172
  to_name = options.delete(:index)
173
- return unless to_name
173
+ unless to_name
174
+ # passing :unique => true doesn't do anything without an index
175
+ Rails.logger.error('ERROR: passing :unique => true without :index => true does nothing. Use :unique instead.') if options[:unique]
176
+ return
177
+ end
174
178
  index_opts = {}
175
179
  index_opts[:unique] = :unique.in?(args) || options.delete(:unique)
176
180
  # support :index => true declaration
@@ -6,7 +6,7 @@ module HoboFields
6
6
  COLUMN_TYPE = :text
7
7
 
8
8
  def to_html(xmldoctype = true)
9
- ERB::Util.html_escape(self).gsub("\n", "<br#{xmldoctype ? ' /' : ''}>\n")
9
+ ERB::Util.html_escape(self).gsub("\n", "<br#{xmldoctype ? ' /' : ''}>\n").html_safe
10
10
  end
11
11
 
12
12
  HoboFields.register_type(:text, self)
data/lib/hobo_fields.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'hobo_support'
2
2
 
3
3
  ActiveSupport::Dependencies.autoload_paths |= [ File.dirname(__FILE__) ]
4
+ ActiveSupport::Dependencies.autoload_once_paths |= [ File.dirname(__FILE__) ]
4
5
 
5
6
  module Hobo
6
7
  # Empty class to represent the boolean type.
@@ -10,6 +11,8 @@ end
10
11
  module HoboFields
11
12
 
12
13
  VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).strip
14
+ @@root = Pathname.new File.expand_path('../..', __FILE__)
15
+ def self.root; @@root; end
13
16
 
14
17
  extend self
15
18
 
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobo_fields
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 1.3.0.pre31
4
+ prerelease:
5
+ version: 1.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tom Locke
@@ -10,64 +10,53 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-29 00:00:00 -04:00
13
+ date: 2011-11-14 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: rails
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: 3.0.0
25
- type: :runtime
26
- version_requirements: *id001
27
16
  - !ruby/object:Gem::Dependency
28
17
  name: hobo_support
29
18
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
19
+ requirement: &id001 !ruby/object:Gem::Requirement
31
20
  none: false
32
21
  requirements:
33
22
  - - "="
34
23
  - !ruby/object:Gem::Version
35
- version: 1.3.0.pre31
24
+ version: 1.3.0
36
25
  type: :runtime
37
- version_requirements: *id002
26
+ version_requirements: *id001
38
27
  - !ruby/object:Gem::Dependency
39
28
  name: rubydoctest
40
29
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
30
+ requirement: &id002 !ruby/object:Gem::Requirement
42
31
  none: false
43
32
  requirements:
44
33
  - - ">="
45
34
  - !ruby/object:Gem::Version
46
35
  version: "0"
47
36
  type: :development
48
- version_requirements: *id003
37
+ version_requirements: *id002
49
38
  - !ruby/object:Gem::Dependency
50
39
  name: redcloth
51
40
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
41
+ requirement: &id003 !ruby/object:Gem::Requirement
53
42
  none: false
54
43
  requirements:
55
44
  - - ">="
56
45
  - !ruby/object:Gem::Version
57
46
  version: "0"
58
47
  type: :development
59
- version_requirements: *id004
48
+ version_requirements: *id003
60
49
  - !ruby/object:Gem::Dependency
61
50
  name: bluecloth
62
51
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
52
+ requirement: &id004 !ruby/object:Gem::Requirement
64
53
  none: false
65
54
  requirements:
66
55
  - - ">="
67
56
  - !ruby/object:Gem::Version
68
57
  version: "0"
69
58
  type: :development
70
- version_requirements: *id005
59
+ version_requirements: *id004
71
60
  description: Rich field types and migration generator for Rails
72
61
  email: tom@tomlocke.com
73
62
  executables:
@@ -143,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
132
  requirements: []
144
133
 
145
134
  rubyforge_project: hobo
146
- rubygems_version: 1.5.0
135
+ rubygems_version: 1.6.2
147
136
  signing_key:
148
137
  specification_version: 3
149
138
  summary: Rich field types and migration generator for Rails