kilt-cms 0.5.4 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +2 -0
  3. data/Rakefile +5 -2
  4. data/lib/generators/kilt/backend_generator.rb +4 -0
  5. data/lib/generators/kilt/frontend_generator.rb +5 -0
  6. data/lib/generators/kilt/install_generator.rb +1 -2
  7. data/lib/generators/kilt/object_generator.rb +13 -4
  8. data/lib/kilt/form.rb +18 -20
  9. data/test/dummy/log/development.log +601 -0
  10. data/test/dummy/tmp/data/meta_request/141a0382-eb21-4007-a145-f3d3b88a36da.json +1 -0
  11. data/test/dummy/tmp/data/meta_request/2735353e-1614-442b-94fa-e28ccecf8886.json +1 -0
  12. data/test/dummy/tmp/data/meta_request/28a7e179-6ce9-4e17-8c63-4e472258908e.json +1 -0
  13. data/test/dummy/tmp/data/meta_request/42cff6d7-0c1c-4527-909c-1e46b44724ec.json +1 -0
  14. data/test/dummy/tmp/data/meta_request/4e293f69-94cd-4328-a3e8-9ad86b2c8492.json +1 -0
  15. data/test/dummy/tmp/data/meta_request/7ffbdd4b-4e00-4f6f-a041-8f35d5f2e462.json +1 -0
  16. data/test/dummy/tmp/data/meta_request/846828f4-ebbc-4c3b-a417-1cc72431c32c.json +1 -0
  17. data/test/dummy/tmp/data/meta_request/bfffaa0c-5f51-4b1b-8094-1f4b0af99b8f.json +1 -0
  18. data/test/dummy/tmp/data/meta_request/c6b70255-52cf-49dd-9294-180052de6af5.json +1 -0
  19. data/test/dummy/tmp/data/meta_request/d670d256-6c27-4b40-b36f-64d76aa6cd1b.json +1 -0
  20. data/test/kilt/form_spec.rb +86 -0
  21. data/test/minitest_helper.rb +9 -0
  22. metadata +40 -28
  23. data/test/dummy/spec/kilt_spec.rb +0 -31
  24. data/test/dummy/spec/spec_helper.rb +0 -12
  25. data/test/dummy/tmp/data/meta_request/029cf5a2-8c70-4191-9744-35c06f882f6d.json +0 -1
  26. data/test/dummy/tmp/data/meta_request/1417464d-92ad-41ad-a91c-3e314c175d9d.json +0 -1
  27. data/test/dummy/tmp/data/meta_request/6e8390f0-ab11-4c87-923d-f6b4ce90e1bb.json +0 -1
  28. data/test/dummy/tmp/data/meta_request/80c50224-eb0b-4fac-9d11-7574aaba03b6.json +0 -1
  29. data/test/dummy/tmp/data/meta_request/a501070f-b628-4480-8257-581d41fff6b6.json +0 -1
  30. data/test/dummy/tmp/data/meta_request/b8d0c65d-7362-43d7-8067-a4641e58e1ae.json +0 -1
  31. data/test/dummy/tmp/data/meta_request/d37eb71e-536b-4a82-9768-e9eaf8c8adf3.json +0 -1
  32. data/test/dummy/tmp/data/meta_request/dffb0061-d20f-4bd7-8265-256447287c41.json +0 -1
  33. data/test/dummy/tmp/data/meta_request/ee8867fc-03db-460d-9f57-389115bee3a8.json +0 -1
  34. data/test/dummy/tmp/data/meta_request/f3be321f-57f5-4968-9808-1b7b7112791d.json +0 -1
  35. data/test/dummy/tmp/pids/server.pid +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49a79f29e9a3c3bf3bfc386b22c802781063721b
4
- data.tar.gz: 01fa542a5d7d8b7be6dd05fe0672b7f86cb1a6d1
3
+ metadata.gz: 182615ac7dfd8939f59606984df9692196f7e5ca
4
+ data.tar.gz: d339b8bbbbbcda74c85fd1dd2ee72f98e3a22ef4
5
5
  SHA512:
6
- metadata.gz: 3f411ce88e367f9a7282f6dfd78a631bfd74924b4da161cee1f6b32933786a95946a9724939908250a6d1c4170501f9c272162d1e6d4d6d7fab608c276bfbc21
7
- data.tar.gz: 6656f1f3ba90aceaf53f42bdb808e818c51dff37db693378245466eef3a521045bd88bceffbcb38dc7ad687f01322fe095ff4a06147a0ff68551179b27e5c5df
6
+ metadata.gz: 0005192a6b816f44e64be37e4de43415472e17b7bbf4d80f105b5e39472912f9bec596d7b94b340cb5393a5a16a8d1dfd9359961d42af67d7b456b8b031fdf02
7
+ data.tar.gz: b7a1557a1547e8ae60cea978210a041a047d4134b933a0f9b67bf2d1d8d6bfbcb1501e17a64a03fff638d5cd2b7c5376a26bc0fcb567886954378f5d937b4051
data/README.rdoc CHANGED
@@ -1,3 +1,5 @@
1
+ {<img src="https://travis-ci.org/AsheAvenue/Kilt.png?branch=master" alt="Build Status" />}[https://travis-ci.org/AsheAvenue/Kilt]
2
+
1
3
  - Create a new Rails project without a database:
2
4
 
3
5
  $ rails new Blah -O
data/Rakefile CHANGED
@@ -1,7 +1,10 @@
1
1
  require 'rake/testtask'
2
2
 
3
+ task :default => [:test]
4
+
3
5
  Rake::TestTask.new(:test) do |t|
6
+ ENV['RAILS_ENV'] = 'test'
4
7
  t.libs << 'test'
5
- t.test_files = FileList['test/**/*_test.rb']
8
+ t.test_files = FileList['test/**/*_test.rb', 'test/**/*_spec.rb']
6
9
  t.verbose = true
7
- end
10
+ end
@@ -1,18 +1,22 @@
1
1
  module Kilt
2
2
  module Generators
3
3
  class BackendGenerator < Rails::Generators::Base
4
+
4
5
  desc "Generates the Kilt backend"
5
6
 
6
7
  source_root File.expand_path("../templates/backend", __FILE__)
7
8
 
8
9
  def generate
10
+
9
11
  #if using git, add creds config to .gitignore
10
12
  append_file Rails.root.join('.gitignore'), '/config/kilt/creds.yml' if File.exists? Rails.root.join('.gitignore')
13
+
11
14
  #copy files, templates for app-specific naming, inject engine mount to routes
12
15
  template 'config.yml.erb', Rails.root.join('config', 'kilt', 'config.yml')
13
16
  copy_file 'creds.yml.example', Rails.root.join('config', 'kilt', 'creds.yml.example')
14
17
  copy_file 'kilt.rb', Rails.root.join('config', 'initializers', 'kilt.rb')
15
18
  inject_into_file Rails.root.join('config', 'routes.rb'), "\n\tmount Kilt::Engine => '/admin', as: 'kilt_engine'\n", :after => "#{Rails.application.class.parent_name.camelize}::Application.routes.draw do\n"
19
+
16
20
  end
17
21
  end
18
22
  end
@@ -1,22 +1,27 @@
1
1
  module Kilt
2
2
  module Generators
3
3
  class FrontendGenerator < Rails::Generators::Base
4
+
4
5
  desc "Generates a bootstrap for the host application"
5
6
 
6
7
  source_root File.expand_path("../templates/frontend",__FILE__)
7
8
 
8
9
  def generate
10
+
9
11
  #copy files, templates for app-specific naming, inject index action into routes
10
12
  template 'home_controller.rb.erb', Rails.root.join('app', 'controllers', "#{file_name}_controller.rb")
11
13
  copy_file 'application.html.erb', Rails.root.join('app','views','layouts','application.html.erb')
12
14
  copy_file 'index.html.erb', Rails.root.join('app', 'views', "#{file_name}", 'index.html.erb')
13
15
  inject_into_file Rails.root.join('config','routes.rb'),"\n\tget '/' => '#{file_name}#index'\n", :after => "mount Kilt::Engine => '/admin', as: 'kilt_engine'\n"
16
+
14
17
  #handle assets, sans named files
15
18
  directory 'assets/images', Rails.root.join('app','assets','images')
16
19
  directory 'assets/javascripts', Rails.root.join('app','assets','javascripts')
17
20
  directory 'assets/stylesheets', Rails.root.join('app','assets','stylesheets')
21
+
18
22
  #handle named files
19
23
  template 'dummy.js.erb', Rails.root.join('app','assets','javascripts',"#{file_name}.js")
24
+
20
25
  end
21
26
 
22
27
  private
@@ -3,9 +3,8 @@ module Kilt
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
 
5
5
  def install
6
- #run all kilt generators
6
+ # Default to the backend generator
7
7
  generate "kilt:backend"
8
- generate "kilt:frontend"
9
8
  end
10
9
 
11
10
  end
@@ -1,19 +1,28 @@
1
1
  module Kilt
2
2
  module Generators
3
3
  class ObjectGenerator < Rails::Generators::Base
4
+
4
5
  desc "adds objects and their properties to the configuration file"
6
+
7
+ # The object name and field name/type definitions
5
8
  argument :object_name, :type => :string, :required => true, :desc => "required"
6
9
  argument :fields, :type => :array, :required => true, :desc => "required field_name:field_type"
7
10
 
8
11
  def generate
9
12
  if !Kilt.config.objects || !Kilt.config.objects[self.object_name.singularize.underscore]
10
- out = "\n\s\s#{self.object_name.singularize.underscore}:"
11
- out = "#{out}\n\s\s\s\sfields:"
13
+
14
+ # Build the object entry
15
+ lines = []
16
+ lines << "\n\s\s#{self.object_name.singularize.underscore}:"
17
+ lines << "\n\s\s\s\sfields:"
12
18
  self.fields.each do |field|
13
19
  field = field.gsub(':',': ')
14
- out = "#{out}\n\s\s\s\s\s\s#{field.downcase}"
20
+ lines << "\n\s\s\s\s\s\s#{field.downcase}"
15
21
  end
16
- append_to_file Rails.root.join('config', 'kilt', 'config.yml'), out
22
+
23
+ # Write the object entry to the kilt config
24
+ append_to_file Rails.root.join('config', 'kilt', 'config.yml'), lines.join('')
25
+
17
26
  else
18
27
  puts "The #{self.object_name} object already exists"
19
28
  end
data/lib/kilt/form.rb CHANGED
@@ -1,28 +1,26 @@
1
1
  module Kilt
2
2
  module Form
3
3
 
4
- TEMPLATES_DIR = "#{Kilt::Engine.root}/app/views/kilt/form"
4
+ TEMPLATES_DIR = if ENV['RAILS_ENV'] == 'test'
5
+ '/'
6
+ else
7
+ "#{Kilt::Engine.root}/app/views/kilt/form"
8
+ end
5
9
 
6
10
  def self.method_missing(method, *args)
7
- begin
8
-
9
- # Get the method name
10
- name = method.to_s
11
-
12
- # Get the object type and field name
13
- object = args[0]
14
- field_name = args[1]
15
- index = args[2]
16
-
17
- # Render the corresponding form field, or fall back to the default if we have an issue
18
- begin
19
- ActionView::Base.new(TEMPLATES_DIR).render(:file => "#{name}.html.erb", :locals => {:object => object, :field_name => field_name, :index => index})
20
- rescue
21
- ActionView::Base.new(TEMPLATES_DIR).render(:file => "_default.html.erb", :locals => {:object => object, :field_name => field_name, :index => index})
22
- end
23
-
24
- end
11
+ locals = { object: args[0], field_name: args[1], index: args[2] }
12
+ render_view method, locals
13
+ rescue
14
+ render_view '_default', locals
15
+ end
16
+
17
+ private
18
+
19
+ def self.render_view name, locals
20
+ data = { file: "#{name.to_s}.html.erb",
21
+ locals: locals }
22
+ ActionView::Base.new(TEMPLATES_DIR).render data
25
23
  end
26
24
 
27
25
  end
28
- end
26
+ end