kilt-cms 0.9.13 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +3 -5
  3. data/app/controllers/kilt/kilt_controller.rb +1 -1
  4. data/app/views/kilt/form/{boolean.html.erb → _boolean.html.erb} +0 -0
  5. data/app/views/kilt/form/{datetime.html.erb → _datetime.html.erb} +0 -0
  6. data/app/views/kilt/form/{file.html.erb → _file.html.erb} +1 -1
  7. data/app/views/kilt/form/{html.html.erb → _html.html.erb} +0 -0
  8. data/app/views/kilt/form/{image.html.erb → _image.html.erb} +1 -1
  9. data/app/views/kilt/form/{longtext.html.erb → _longtext.html.erb} +0 -0
  10. data/app/views/kilt/form/{number.html.erb → _number.html.erb} +0 -0
  11. data/app/views/kilt/form/{select_one.html.erb → _select_one.html.erb} +0 -0
  12. data/app/views/kilt/form/{text.html.erb → _text.html.erb} +0 -0
  13. data/app/views/kilt/form/{vimeo.html.erb → _vimeo.html.erb} +0 -0
  14. data/app/views/kilt/form/{youtube.html.erb → _youtube.html.erb} +0 -0
  15. data/app/views/kilt/kilt/_form.html.erb +12 -10
  16. data/app/views/kilt/kilt/edit.html.erb +1 -1
  17. data/app/views/kilt/kilt/index.html.erb +3 -2
  18. data/app/views/kilt/kilt/list.html.erb +6 -9
  19. data/app/views/kilt/kilt/new.html.erb +1 -1
  20. data/app/views/layouts/kilt/cms/_menu.html.erb +2 -6
  21. data/lib/generators/kilt/backend_generator.rb +28 -6
  22. data/lib/generators/kilt/templates/backend/create_kilt_objects.rb +13 -0
  23. data/lib/generators/kilt/templates/backend/creds.yml.example +10 -5
  24. data/lib/generators/kilt/templates/backend/creds.yml.rethinkdb.example +22 -0
  25. data/lib/kilt.rb +34 -54
  26. data/lib/kilt/base.rb +3 -2
  27. data/lib/kilt/db/active_record.rb +50 -0
  28. data/lib/kilt/db/rethink_db.rb +108 -0
  29. data/lib/kilt/form.rb +7 -5
  30. data/lib/kilt/formatting.rb +39 -0
  31. data/lib/kilt/object.rb +32 -31
  32. data/lib/kilt/utils.rb +32 -39
  33. data/lib/kilt_object.rb +3 -0
  34. data/test/dummy/config/application.rb +1 -1
  35. data/test/dummy/config/database.yml +5 -0
  36. data/test/dummy/config/initializers/kilt.rb +1 -1
  37. data/test/dummy/config/kilt/config.yml +4 -13
  38. data/test/dummy/config/kilt/creds.yml +16 -11
  39. data/test/dummy/config/kilt/creds.yml.rethinkdb.example +22 -0
  40. data/test/dummy/config/routes.rb +1 -1
  41. data/test/dummy/db/migrate/20140519110428_create_kilt_objects.rb +13 -0
  42. data/test/dummy/db/schema.rb +29 -0
  43. data/test/dummy/log/development.log +551 -0
  44. data/test/dummy/public/uploads/image/timbo.jpg +0 -0
  45. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  46. data/test/dummy/tmp/cache/assets/development/sprockets/18837248cb3274df9b7c6b0a5dcd56a5 +0 -0
  47. data/test/dummy/tmp/cache/assets/development/sprockets/20dffc9385ea740ceca470ee4e4b2197 +0 -0
  48. data/test/dummy/tmp/cache/assets/development/sprockets/23733156ea27da67211ba7ff763d76f0 +0 -0
  49. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  50. data/test/dummy/tmp/cache/assets/development/sprockets/3148655edeef1c319d57d0f9570acfd5 +0 -0
  51. data/test/dummy/tmp/cache/assets/development/sprockets/32ab48c63ad3bb6ddc1f419e51adb5db +0 -0
  52. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  53. data/test/dummy/tmp/cache/assets/development/sprockets/36715e644093cfcb33ac795f3c9d66fe +0 -0
  54. data/test/dummy/tmp/cache/assets/development/sprockets/36f9a7f6f43adb582ac6eec43b58eb30 +0 -0
  55. data/test/dummy/tmp/cache/assets/development/sprockets/3d8ca1585ee95c5efb388645d66cf377 +0 -0
  56. data/test/dummy/tmp/cache/assets/development/sprockets/413be9c73d25c7febe933f4619da7cf8 +0 -0
  57. data/test/dummy/tmp/cache/assets/development/sprockets/4a935342c0113b534ad7622234965544 +0 -0
  58. data/test/dummy/tmp/cache/assets/development/sprockets/4b5c4a1edd3823a6a6c39e06b6eb230a +0 -0
  59. data/test/dummy/tmp/cache/assets/development/sprockets/4c5736bf0bd429296d1a32930364897e +0 -0
  60. data/test/dummy/tmp/cache/assets/development/sprockets/4f26158b7a804a3e3c47ce0ceff2798c +0 -0
  61. data/test/dummy/tmp/cache/assets/development/sprockets/542fc810f9cd36e7bed9a3e5e9670995 +0 -0
  62. data/test/dummy/tmp/cache/assets/development/sprockets/56f1e7d57d31bf3315e1e33732d57faa +0 -0
  63. data/test/dummy/tmp/cache/assets/development/sprockets/5bea4c2d87ec725262213ed51575b485 +0 -0
  64. data/test/dummy/tmp/cache/assets/development/sprockets/6b6e86e81f5e8f80bb2b3d1e8f7ed7f3 +0 -0
  65. data/test/dummy/tmp/cache/assets/development/sprockets/6c2ddc22c04321c269de383e37cb519b +0 -0
  66. data/test/dummy/tmp/cache/assets/development/sprockets/7035e5c60f5da3b7fc12c472677483d0 +0 -0
  67. data/test/dummy/tmp/cache/assets/development/sprockets/704c682957c2beb38a1927ddb66cc557 +0 -0
  68. data/test/dummy/tmp/cache/assets/development/sprockets/74b6c3e00222b8bf31b0ecf50fcb0d38 +0 -0
  69. data/test/dummy/tmp/cache/assets/development/sprockets/91021bdb7ebb3d4f6fdf4e49909d4c07 +0 -0
  70. data/test/dummy/tmp/cache/assets/development/sprockets/914095efd3b33401a7f29f9fb05d72d6 +0 -0
  71. data/test/dummy/tmp/cache/assets/development/sprockets/9dd98bca318fb820a8451cafce020588 +0 -0
  72. data/test/dummy/tmp/cache/assets/development/sprockets/9f2c00a36b5b8c713a797b508c778a65 +0 -0
  73. data/test/dummy/tmp/cache/assets/development/sprockets/a88ab4e49bb7203b8e0586c38efdd2b0 +0 -0
  74. data/test/dummy/tmp/cache/assets/development/sprockets/acfc15d25fde8b933b06c91324755751 +0 -0
  75. data/test/dummy/tmp/cache/assets/development/sprockets/c0671678b70011547b80da0669d031cc +0 -0
  76. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  77. data/test/dummy/tmp/cache/assets/development/sprockets/d6973c1d43f8ca41b98a6b640fda2616 +0 -0
  78. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  79. data/test/dummy/tmp/cache/assets/development/sprockets/dc676330961fd22be77c48cb77ec065f +0 -0
  80. data/test/dummy/tmp/cache/assets/development/sprockets/ddc29f2c13cd99d017fd526b61dcb951 +0 -0
  81. data/test/dummy/tmp/cache/assets/development/sprockets/de45247cb814cafe20e9e46c79e470fe +0 -0
  82. data/test/dummy/tmp/cache/assets/development/sprockets/df0b7c3ac590a286561806e813c2974f +0 -0
  83. data/test/dummy/tmp/cache/assets/development/sprockets/dfa8b85e3c1273b7e69839e4e607c3e1 +0 -0
  84. data/test/dummy/tmp/cache/assets/development/sprockets/e22d705d0c889ec4837f183a9beec0f3 +0 -0
  85. data/test/dummy/tmp/cache/assets/development/sprockets/e3a4ad3549e1e57d03698a36daeff406 +0 -0
  86. data/test/dummy/tmp/cache/assets/development/sprockets/ef7c8ce46dfc9e9087ce84dbdfdd0011 +0 -0
  87. data/test/dummy/tmp/cache/assets/development/sprockets/f4b5dd06a6113950c0f481cbc5a31a66 +0 -0
  88. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  89. data/test/dummy/tmp/data/meta_request/1c3d4a4b-d7e1-4126-8bfc-572acbc2f675.json +1 -0
  90. data/test/dummy/tmp/data/meta_request/449ff78e-30d2-4cc5-bbb7-3397d04a4c46.json +1 -0
  91. data/test/dummy/tmp/data/meta_request/5974cfb9-99bd-4d5c-a4e1-6e352ecd2dd8.json +1 -0
  92. data/test/dummy/tmp/data/meta_request/960de12b-b1c5-4d44-937b-e3d8c00d682c.json +1 -0
  93. data/test/dummy/tmp/data/meta_request/9df9ad77-1b70-4fb7-ad18-f31f28c60c6c.json +1 -0
  94. data/test/dummy/tmp/data/meta_request/a5374758-4e16-487a-ab11-9a69a1abed2e.json +1 -0
  95. data/test/dummy/tmp/data/meta_request/a65d97b2-df1f-445e-99d5-615c4db5c4e1.json +1 -0
  96. data/test/dummy/tmp/data/meta_request/b3693c6f-23cd-4afe-ae82-38078eaa643a.json +1 -0
  97. data/test/dummy/tmp/data/meta_request/daa1c80a-bad3-4bc1-8f67-d586979cbedc.json +1 -0
  98. data/test/dummy/tmp/data/meta_request/e2e7621f-08e5-46dd-83c2-b87eb6d5fd45.json +1 -0
  99. data/test/empty.sqlite3 +0 -0
  100. data/test/generators/kilt/backend_generator_spec.rb +70 -0
  101. data/test/kilt/form_spec.rb +40 -51
  102. data/test/kilt/formatting_spec.rb +66 -0
  103. data/test/kilt/object_spec.rb +204 -0
  104. data/test/kilt/utils_spec.rb +147 -0
  105. data/test/kilt_object_spec.rb +12 -0
  106. data/test/kilt_spec.rb +422 -0
  107. data/test/minitest_helper.rb +58 -0
  108. metadata +164 -66
  109. data/test/dummy/tmp/data/meta_request/191f094a-5e87-4654-bc80-5acb51d3f903.json +0 -1
  110. data/test/dummy/tmp/data/meta_request/1eb9499d-2e84-47df-ac0a-da308031aa3a.json +0 -1
  111. data/test/dummy/tmp/data/meta_request/300cabd2-6e51-4b1b-ab55-a072049c2a0f.json +0 -1
  112. data/test/dummy/tmp/data/meta_request/3ec7ea74-e7a7-4f4d-9434-e08edfc12b8a.json +0 -1
  113. data/test/dummy/tmp/data/meta_request/5bb81411-321e-4cba-9ffa-87fcd8105ef4.json +0 -1
  114. data/test/dummy/tmp/data/meta_request/9d6e10c1-5b14-4199-852e-9f1e97132b8f.json +0 -1
  115. data/test/dummy/tmp/data/meta_request/a6403ed9-21f1-4a00-9725-4a1c544214f6.json +0 -1
  116. data/test/dummy/tmp/data/meta_request/b4487e0b-0a08-40a3-a364-e715e6765631.json +0 -1
  117. data/test/dummy/tmp/data/meta_request/d399f913-d3a5-4de3-b012-848377a702fc.json +0 -1
  118. data/test/dummy/tmp/data/meta_request/dcf95267-1855-4062-85c8-e880f8d62443.json +0 -1
@@ -0,0 +1,50 @@
1
+ module Kilt
2
+
3
+ module DB
4
+
5
+ class ActiveRecord
6
+
7
+ def find(slug)
8
+ object = KiltObject.where(slug: slug).first
9
+ object ? object.data : nil
10
+ end
11
+
12
+ def find_all_by_type type
13
+ KiltObject.where(object_type: "#{type.singularize.to_s}")
14
+ .map { |x| x.data }
15
+ end
16
+
17
+ def create(object)
18
+ KiltObject.create!(unique_id: object['unique_id'],
19
+ slug: object['slug'],
20
+ object_type: object['type'],
21
+ data: object.values)
22
+ true
23
+ rescue
24
+ false
25
+ end
26
+
27
+ def update(current)
28
+ object = KiltObject.where(unique_id: current['unique_id']).first
29
+ return false unless object
30
+ object.slug = current['slug']
31
+ object.data = current.values
32
+ object.save
33
+ end
34
+
35
+ def delete(slug)
36
+ object = KiltObject.where(slug: slug).first
37
+ object.delete if object
38
+ true
39
+ rescue
40
+ false
41
+ end
42
+
43
+ def setup!
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,108 @@
1
+ module Kilt
2
+
3
+ module DB
4
+
5
+ class RethinkDb
6
+
7
+ def initialize(options)
8
+ @options = options
9
+ end
10
+
11
+ def find(slug)
12
+ results = execute { slug_query(slug).limit(1) }
13
+ return nil unless results
14
+ results = results.to_a
15
+ return nil if results.first.is_a? Array
16
+ results.first
17
+ end
18
+
19
+ def find_all_by_type type
20
+ execute { type_query(type) }.to_a
21
+ end
22
+
23
+ def create(object)
24
+ result = execute { objects_table.insert(object.values) }
25
+ result['errors'] == 0
26
+ end
27
+
28
+ def update(object)
29
+ result = execute do
30
+ unique_id_query(object['unique_id']).update(object.values)
31
+ end
32
+ result['errors'] == 0
33
+ end
34
+
35
+ def delete(slug)
36
+ result = execute { slug_query(slug).delete() }
37
+ result['errors'] == 0
38
+ end
39
+
40
+ def delete_all
41
+ execute do
42
+ @r.db(Kilt.config.test.db.db).table('objects').delete()
43
+ end
44
+ end
45
+
46
+ # Make a db call
47
+ def execute(&block)
48
+ setup_the_database
49
+ block.call.run(@connection)
50
+ end
51
+
52
+ def setup!
53
+ if @options[:host] && @options[:port]
54
+ begin
55
+ # See if the db exists and create it otherwise
56
+ dbs = execute { @r.db_list }.to_a
57
+ if !dbs.to_a.include? @options[:db]
58
+ execute { @r.db_create(@options[:db]) }
59
+ end
60
+
61
+ # See if the table exists and create it otherwise
62
+ tables = execute { @r.db(@options[:db]).table_list }.to_a
63
+ if !tables.to_a.include? "objects"
64
+ execute { @r.db(@options[:db]).table_create("objects", :primary_key => "unique_id") }
65
+ end
66
+ rescue
67
+ raise Kilt::CantSetupDatabaseError
68
+ end
69
+ else
70
+ raise Kilt::NoDatabaseConfigError
71
+ end
72
+ end
73
+
74
+ private
75
+
76
+ def setup_the_database
77
+ unless @r && @connection
78
+ begin
79
+ @r = RethinkDB::RQL.new
80
+ @connection = @r.connect(:host => @options[:host], :port => @options[:port], :db => @options[:db])
81
+ rescue
82
+ raise Kilt::CantConnectToDatabaseError
83
+ end
84
+ end
85
+ end
86
+
87
+ def objects_table
88
+ setup_the_database
89
+ @r.table('objects')
90
+ end
91
+
92
+ def slug_query(slug)
93
+ objects_table.filter( { 'slug' => "#{slug}" } )
94
+ end
95
+
96
+ def type_query(type)
97
+ objects_table.filter( {'type' => "#{type.singularize.to_s}" } )
98
+ end
99
+
100
+ def unique_id_query(unique_id)
101
+ objects_table.filter( { 'unique_id' => "#{unique_id}" } )
102
+ end
103
+
104
+ end
105
+
106
+ end
107
+
108
+ end
data/lib/kilt/form.rb CHANGED
@@ -8,10 +8,14 @@ module Kilt
8
8
  end
9
9
 
10
10
  def self.method_missing(method, *args)
11
- locals = { object: args[0], field_name: args[1], index: args[2], options: args[3] }
11
+ locals = { object: args[0], field_name: args[1], index: args[2], options: args[4], view: args[3] }
12
12
  render_view method, locals
13
13
  rescue
14
- render_view '_default', locals
14
+ render_view 'default', locals
15
+ end
16
+
17
+ def self.render_field(view, data)
18
+ Kilt::Form.prep_field(data[:value], data[:object], data[:key], data[:index], view)
15
19
  end
16
20
 
17
21
  def self.prep_field(method, *args)
@@ -38,9 +42,7 @@ module Kilt
38
42
  private
39
43
 
40
44
  def self.render_view name, locals
41
- data = { :file => "#{name.to_s}.html.erb",
42
- :locals => locals }
43
- ActionView::Base.new(TEMPLATES_DIR).render data
45
+ locals[:view].send(:render, { partial: "kilt/form/#{name}", locals: locals } )
44
46
  end
45
47
 
46
48
  end
@@ -0,0 +1,39 @@
1
+ module Kilt
2
+
3
+ module Formatting
4
+
5
+ def self.singular_name_of object
6
+ simple_name_of(object)
7
+ .split('_')
8
+ .map { |x| x.capitalize }
9
+ .join(' ')
10
+ end
11
+
12
+ def self.plural_name_of object
13
+ singular_name_of(object).pluralize
14
+ end
15
+
16
+ class << self
17
+
18
+ private
19
+
20
+ def simple_name_of object
21
+ type = if object.is_a? Symbol
22
+ object.to_s
23
+ elsif object.is_a? String
24
+ object
25
+ else
26
+ object.type.to_s
27
+ end
28
+
29
+ name_of_type_in_config(type) || type
30
+ end
31
+
32
+ def name_of_type_in_config type
33
+ kilt_type = Kilt.send(type)
34
+ return nil unless kilt_type
35
+ kilt_type['name']
36
+ end
37
+ end
38
+ end
39
+ end
data/lib/kilt/object.rb CHANGED
@@ -4,41 +4,21 @@ module Kilt
4
4
 
5
5
  def initialize(type, values = {})
6
6
  @type = type
7
- @values = values
8
-
7
+ initialize_values values
9
8
  assemble_fields
10
9
  end
11
10
 
12
11
  def fill(params)
13
- puts params
14
- # Take the params passed in and match them up to the fields
15
- @fields.each do |key, value|
16
- if params[key] || params["#{key}-hidden"]
17
- field_type = value.downcase
18
- if ['file', 'image'].include? field_type
19
- if params["#{key}-hidden"] && params["#{key}-hidden"] == 'clear' && !params[key]
20
- @values[key.to_s] = ''
21
- elsif params[key]
22
- @values[key.to_s] = Kilt::Upload.send(field_type, params[key])
23
- end
24
- else
25
- @values[key.to_s] = params[key]
26
- end
27
- end
28
- end
29
-
30
- # Add some extra fields
31
- if !@slug
32
- @values['slug'] = Utils.slugify(@values['name'])
12
+ fields_that_should_be_set_given(params).each do |field, field_type|
13
+ self[field] = the_value_for field, field_type, params
33
14
  end
34
-
35
- @values['type'] = @type
36
-
37
15
  end
38
16
 
39
17
  def [](key)
40
18
  # Return the values of the object as a hash
41
- @values[key.to_s].html_safe if @values[key.to_s]
19
+ value = @values[key.to_s]
20
+ return nil unless value
21
+ value.respond_to?(:html_safe) ? value.html_safe : value
42
22
  end
43
23
 
44
24
  def []=(key, value)
@@ -56,11 +36,32 @@ module Kilt
56
36
  private
57
37
 
58
38
  def assemble_fields
59
- # Get the fields from the config, and add the name field
60
- @fields = Kilt.send(@type).fields.map { |key, value| [key, value] }
61
- if !Kilt.send(@type).fields.to_h.has_key? :name
62
- @fields.insert(0, ['name', 'text'])
39
+ @fields = Kilt.send(@type).fields.to_h
40
+ @fields['name'] = 'text' unless @fields[:name]
41
+ end
42
+
43
+ def the_value_for(key, field_type, params)
44
+ if params["#{key}-hidden"] == 'clear' && !params[key]
45
+ ''
46
+ elsif ['file', 'image'].include? field_type
47
+ Kilt::Upload.send field_type, params[key]
48
+ else
49
+ params[key]
63
50
  end
64
51
  end
52
+
53
+ def fields_that_should_be_set_given params
54
+ @fields.map { |k, v| [k, v.downcase] }
55
+ .select { |k, v| params[k] || (params["#{k}-hidden"].to_s != '') }
56
+ end
57
+
58
+ def initialize_values values
59
+ @values = values
60
+
61
+ @values.keys
62
+ .select { |x| x.is_a? Symbol }
63
+ .each { |k| @values[k.to_s] = @values[k] }
64
+ end
65
+
65
66
  end
66
- end
67
+ end
data/lib/kilt/utils.rb CHANGED
@@ -1,46 +1,33 @@
1
1
  module Kilt
2
2
  class Utils
3
3
 
4
- # Set up the database
5
4
  def self.setup_db
6
- if Kilt.config.db.host && Kilt.config.db.port
7
- begin
8
- db = r.connect(:host => Kilt.config.db.host, :port => Kilt.config.db.port).repl
9
- rescue
10
- raise Kilt::CantConnectToDatabaseError
11
- end
12
-
13
- begin
14
-
15
- # See if the db exists and create it otherwise
16
- dbs = r.db_list.run
17
- if !dbs.to_a.include? Kilt.config.db.db
18
- r.db_create(Kilt.config.db.db).run
19
- end
20
-
21
- # See if the table exists and create it otherwise
22
- tables = r.db(Kilt.config.db.db).table_list.run
23
- if !tables.to_a.include? "objects"
24
- r.db(Kilt.config.db.db).table_create("objects", :primary_key => "unique_id").run
25
- end
26
-
27
- rescue
28
- raise Kilt::CantSetupDatabaseError
29
- ensure
30
- db.close
31
- end
32
-
33
- else
34
- raise Kilt::NoDatabaseConfigError
5
+ return unless current_db_config
6
+ if db_type = current_db_config[:type]
7
+ use_db(db_type.to_sym)
35
8
  end
9
+ database.setup!
10
+ end
11
+
12
+ def self.use_db db_type
13
+ return if @db_type == db_type
14
+ @db_type = db_type
15
+ @database = nil
36
16
  end
37
17
 
38
- # Make a db call
39
- def self.db(&block)
40
- db = r.connect(:host => Kilt.config.db.host, :port => Kilt.config.db.port).repl
41
- results = block.call()
42
- db.close
43
- results
18
+ def self.database
19
+ @database ||= if @db_type == :active_record
20
+ Kilt::DB::ActiveRecord.new
21
+ else
22
+ Kilt::DB::RethinkDb.new current_db_config
23
+ end
24
+ end
25
+
26
+ def self.current_db_config
27
+ current_environment = (ENV['RAILS_ENV'].to_s == '' ? 'development' : ENV['RAILS_ENV']).to_sym
28
+ Kilt.config[current_environment][:db]
29
+ rescue
30
+ Kilt.config[:db]
44
31
  end
45
32
 
46
33
  # Ensure we have local storage dirs
@@ -89,7 +76,7 @@ module Kilt
89
76
  ret.gsub! /\s*&\s*/, " and "
90
77
 
91
78
  #replace all non alphanumeric, underscore or periods with dash
92
- ret.gsub! /\s*[^A-Za-z0-9\.\_]\s*/, '-'
79
+ ret.gsub! /\s*[^A-Za-z0-9]\s*/, '-'
93
80
 
94
81
  #convert double dash to single
95
82
  ret.gsub! /-+/, "-"
@@ -107,11 +94,17 @@ module Kilt
107
94
  ret.gsub! /_/, " "
108
95
  ret.capitalize
109
96
  end
97
+
98
+ def self.config_is_valid?
99
+ Kilt.config.empty? == false && current_db_config
100
+ #!(Kilt.config.empty? || !Kilt.config.db)
101
+ #!Kilt.config.empty? && Kilt.config.db
102
+ end
110
103
 
111
104
  # Print a list of objects, functions, etc.
112
105
  def self.tips
113
106
  lines = []
114
- if !Kilt.config.empty? && Kilt.config.db
107
+ if config_is_valid?
115
108
  lines << ''
116
109
 
117
110
  # Store the first type so we can use it down below
@@ -163,4 +156,4 @@ module Kilt
163
156
  end
164
157
 
165
158
  end
166
- end
159
+ end
@@ -0,0 +1,3 @@
1
+ class KiltObject < ActiveRecord::Base
2
+ serialize :data, Hash
3
+ end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  # Pick the frameworks you want:
4
- # require "active_record/railtie"
4
+ require "active_record/railtie"
5
5
  require "action_controller/railtie"
6
6
  require "sprockets/railtie"
7
7
  require "rails/test_unit/railtie"
@@ -0,0 +1,5 @@
1
+ development:
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ database: kilttest
5
+ host: 127.0.0.1
@@ -11,4 +11,4 @@ Settings.reload!
11
11
  Kilt.config = Settings
12
12
 
13
13
  # Ensure we have a database set up
14
- Kilt::Utils.setup_db
14
+ Kilt::Utils.setup_db