active_metadata 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/README.md +4 -0
  2. data/Rakefile +31 -0
  3. data/app/assets/javascripts/active_metadata/application.js +15 -0
  4. data/app/assets/stylesheets/active_metadata/application.css +13 -0
  5. data/app/controllers/active_metadata/application_controller.rb +4 -0
  6. data/app/controllers/active_metadata/attachments_controller.rb +4 -6
  7. data/app/controllers/active_metadata/notes_controller.rb +7 -10
  8. data/app/controllers/active_metadata/stream_controller.rb +12 -0
  9. data/app/helpers/active_metadata/application_helper.rb +4 -0
  10. data/app/helpers/active_metadata/stream_helper.rb +14 -0
  11. data/app/models/active_metadata/attachment.rb +26 -0
  12. data/app/models/active_metadata/history.rb +4 -0
  13. data/app/models/active_metadata/note.rb +4 -0
  14. data/app/models/active_metadata/watcher.rb +6 -0
  15. data/app/views/active_metadata/attachments/_attachment.html.erb +7 -0
  16. data/app/views/active_metadata/attachments/index.html.erb +2 -10
  17. data/app/views/active_metadata/notes/_note.html.erb +7 -0
  18. data/app/views/active_metadata/notes/index.html.erb +1 -9
  19. data/app/views/active_metadata/stream/_element.html.erb +1 -0
  20. data/app/views/active_metadata/stream/index.html.erb +3 -0
  21. data/app/views/layouts/active_metadata/application.html.erb +11 -0
  22. data/config/active_metadata.yml +6 -0
  23. data/config/cucumber.yml +8 -0
  24. data/config/database.yml +4 -2
  25. data/config/routes.rb +25 -26
  26. data/db/migrate/02_active_metadata_migrations.rb +24 -24
  27. data/features/{watchlist/add_a_user_to_a_watcher.feature → add_a_user_to_a_watcher.feature} +0 -0
  28. data/features/support/env.rb +8 -0
  29. data/features/supports/file.txt +0 -1
  30. data/features/supports/updated_file.txt +0 -1
  31. data/features/{watchlist/trigger_alert_on_modify.feature → trigger_alert_on_modify.feature} +0 -0
  32. data/lib/active_metadata/base.rb +3 -1
  33. data/lib/active_metadata/engine.rb +11 -0
  34. data/lib/active_metadata/helpers.rb +15 -1
  35. data/lib/active_metadata/persistence/{active_record/attachment.rb → attachment.rb} +10 -10
  36. data/lib/active_metadata/persistence/{active_record/history.rb → history.rb} +4 -4
  37. data/lib/active_metadata/persistence/{active_record/note.rb → note.rb} +8 -8
  38. data/lib/active_metadata/persistence/persistence.rb +14 -4
  39. data/lib/active_metadata/persistence/{active_record/watcher.rb → watcher.rb} +5 -5
  40. data/lib/active_metadata/streamable.rb +25 -0
  41. data/lib/active_metadata/version.rb +1 -1
  42. data/lib/active_metadata.rb +3 -3
  43. data/lib/{rake/ci.rb → tasks/active_metadata_tasks.rake} +27 -6
  44. data/lib/tasks/cucumber.rake +65 -0
  45. data/spec/active_metadata_yml.rb +25 -0
  46. data/spec/controllers/active_metadata/attachments_controller_spec.rb +40 -0
  47. data/spec/controllers/active_metadata/notes_controller_spec.rb +41 -0
  48. data/spec/controllers/active_metadata/stream_controller_spec.rb +46 -0
  49. data/spec/dummy/README.rdoc +261 -0
  50. data/spec/dummy/Rakefile +7 -0
  51. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  52. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  53. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  54. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  55. data/{config/application.rb → spec/dummy/app/mailers/.gitkeep} +0 -0
  56. data/spec/dummy/app/models/.gitkeep +0 -0
  57. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  58. data/spec/dummy/config/application.rb +56 -0
  59. data/spec/dummy/config/boot.rb +10 -0
  60. data/spec/dummy/config/database.yml +25 -0
  61. data/spec/dummy/config/environment.rb +5 -0
  62. data/spec/dummy/config/environments/development.rb +37 -0
  63. data/spec/dummy/config/environments/production.rb +67 -0
  64. data/spec/dummy/config/environments/test.rb +37 -0
  65. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  66. data/spec/dummy/config/initializers/inflections.rb +15 -0
  67. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  68. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  69. data/spec/dummy/config/initializers/session_store.rb +8 -0
  70. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  71. data/spec/dummy/config/locales/en.yml +5 -0
  72. data/spec/dummy/config/routes.rb +4 -0
  73. data/spec/dummy/config.ru +4 -0
  74. data/spec/dummy/db/development.sqlite3 +0 -0
  75. data/spec/dummy/db/schema.rb +106 -0
  76. data/spec/dummy/db/test.sqlite3 +0 -0
  77. data/spec/dummy/lib/assets/.gitkeep +0 -0
  78. data/spec/dummy/log/.gitkeep +0 -0
  79. data/spec/dummy/public/404.html +26 -0
  80. data/spec/dummy/public/422.html +26 -0
  81. data/spec/dummy/public/500.html +25 -0
  82. data/spec/dummy/public/favicon.ico +0 -0
  83. data/spec/dummy/script/rails +6 -0
  84. data/spec/helpers/active_metadata/stream_helpers_spec.rb +23 -0
  85. data/spec/routing/active_metadata/stream_controller_routing_spec.rb +17 -0
  86. data/spec/spec_helper.rb +18 -31
  87. data/spec/streamable_spec.rb +120 -0
  88. data/spec/support/document.rb +0 -1
  89. data/spec/support/pdf_test_1.pdf +0 -0
  90. data/spec/support/section.rb +0 -1
  91. data/spec/support/user.rb +0 -2
  92. data/spec/views/active_metadata/stream/index.html.erb_spec.rb +5 -0
  93. metadata +165 -73
  94. data/app/helpers/application_helper.rb +0 -2
  95. data/config/initializers/inflections.rb +0 -7
  96. data/config/mongoid.yml +0 -28
  97. data/db/test.sqlite3 +0 -0
  98. data/features/supports/initializer.rb +0 -1
  99. data/lib/active_metadata/persistence/active_record.rb +0 -26
  100. data/lib/application_controller.rb +0 -28
  101. data/lib/application_helper.rb +0 -7
  102. data/lib/engine.rb +0 -29
  103. data/lib/model/active_record/attachment.rb +0 -22
  104. data/lib/model/active_record/history.rb +0 -2
  105. data/lib/model/active_record/note.rb +0 -2
  106. data/lib/model/active_record/watcher.rb +0 -4
  107. data/lib/rails/railties/tasks.rake +0 -16
  108. data/lib/rake/active_record_tasks.rb +0 -77
  109. data/lib/templates/active_metadata.yml +0 -17
  110. data/lib/templates/active_metadata_migrations +0 -71
  111. data/lib/templates/mongoid.yml +0 -20
  112. data/spec/benchmark_spec.rb +0 -35
  113. data/spec/controllers/metadata_controller_spec.rb +0 -14
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ ## Rake
2
+ I task di rake vengono invocati via il namespace app.
3
+
4
+ rake app:ci
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'ActiveMetadata'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ module ActiveMetadata
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -1,10 +1,8 @@
1
1
  module ActiveMetadata
2
2
  class AttachmentsController < ApplicationController
3
3
 
4
- unloadable
5
-
6
4
  def index
7
- @document = eval(params[:model_name]).find params[:model_id]
5
+ @document = params[:model_name].to_class.find(params[:model_id])
8
6
  @attachments = @document.attachments_for params[:field_name]
9
7
  respond_to do |format|
10
8
  format.html { render :layout => false}
@@ -13,7 +11,7 @@ module ActiveMetadata
13
11
  end
14
12
 
15
13
  def create
16
- @document = eval(params[:model_name]).find params[:model_id]
14
+ @document = params[:model_name].to_class.find(params[:model_id])
17
15
  @document.save_attachment_for(params[:field_name], params[:file])
18
16
 
19
17
  #todo: if errors send back the correct answer
@@ -23,7 +21,7 @@ module ActiveMetadata
23
21
  end
24
22
 
25
23
  def update
26
- @document = eval(params[:model_name]).find params[:model_id]
24
+ @document = params[:model_name].to_class.find(params[:model_id])
27
25
  @document.update_attachment(params[:id],params[:file])
28
26
 
29
27
  #todo: if errors send back the correct answer
@@ -33,7 +31,7 @@ module ActiveMetadata
33
31
  end
34
32
 
35
33
  def destroy
36
- @document = eval(params[:model_name]).find params[:model_id]
34
+ @document = params[:model_name].to_class.find(params[:model_id])
37
35
  @document.delete_attachment(params[:id])
38
36
 
39
37
  #todo: if errors send back the correct answer
@@ -1,30 +1,27 @@
1
1
  module ActiveMetadata
2
2
  class NotesController < ApplicationController
3
3
 
4
- unloadable
5
-
6
4
  def index
7
- @document = eval(params[:model_name]).find params[:model_id]
8
- @notes = @document.notes_for params[:field_name]
5
+ @document = params[:model_name].to_class.find(params[:model_id])
6
+ @notes = @document.notes_for params[:field_name]
9
7
  respond_to do |format|
10
8
  format.html { render :layout => false}
11
9
  format.xml { render :xml => @notes }
12
- format.xls { send_data @notes.to_xls_data(:columns => [:note,:created_at], :headers => [:nota,'inserita']), :filename => 'notes.xls' }
13
10
  end
14
11
  end
15
12
 
16
13
  def edit
17
- @document = eval(params[:model_name]).find params[:model_id]
14
+ @document = params[:model_name].to_class.find(params[:model_id])
18
15
  @note = @document.note_for params[:field_name],params[:id]
19
16
  end
20
17
 
21
18
  def show
22
- @document = eval(params[:model_name]).find params[:model_id]
19
+ @document = params[:model_name].to_class.find(params[:model_id])
23
20
  @note = @document.note_for params[:field_name],params[:id]
24
21
  end
25
22
 
26
23
  def create
27
- @document = eval(params[:model_name]).find params[:model_id]
24
+ @document = params[:model_name].to_class.find(params[:model_id])
28
25
  @document.create_note_for(params[:field_name], params[:note])
29
26
  respond_to do |format|
30
27
  # TODO redirect to edit
@@ -33,7 +30,7 @@ module ActiveMetadata
33
30
  end
34
31
 
35
32
  def update
36
- @document = eval(params[:model_name]).find params[:model_id]
33
+ @document = params[:model_name].to_class.find(params[:model_id])
37
34
  @note = @document.note_for params[:field_name],params[:id]
38
35
 
39
36
  respond_to do |format|
@@ -48,7 +45,7 @@ module ActiveMetadata
48
45
  end
49
46
 
50
47
  def destroy
51
- @document = eval(params[:model_name]).find params[:model_id]
48
+ @document = params[:model_name].to_class.find(params[:model_id])
52
49
  @document.delete_note(params[:id])
53
50
  respond_to do |format|
54
51
  # TODO redirect to index
@@ -0,0 +1,12 @@
1
+ module ActiveMetadata
2
+ class StreamController < ApplicationController
3
+
4
+ layout false
5
+
6
+ def index
7
+ @document = params[:model_name].to_class.find(params[:model_id])
8
+ @stream = @document.stream_for params[:field_name]
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ module ActiveMetadata
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ module ActiveMetadata
2
+ module StreamHelper
3
+
4
+ def stream_partial_path element
5
+ class_name_downcase = clean_class_name element.class.to_s.downcase
6
+ "active_metadata/#{class_name_downcase.pluralize}/#{class_name_downcase}"
7
+ end
8
+
9
+ def clean_class_name name
10
+ name.split('::').last || nil
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ module ActiveMetadata
2
+
3
+ class Attachment < ActiveRecord::Base
4
+
5
+ include ::Paperclip
6
+ include ::Paperclip::Glue
7
+
8
+ has_attached_file :attach,
9
+ :path => "#{ActiveMetadata::CONFIG['attachment_base_path']}/:document_class/:document_id/:label/:id/:basename.:extension",
10
+ :url => "#{ActiveMetadata::CONFIG['attachment_base_url']}/:document_class/:document_id/:label/:id/"
11
+
12
+ Paperclip.interpolates :document_id do |attachment, style|
13
+ attachment.instance.document_id
14
+ end
15
+
16
+ Paperclip.interpolates :label do |attachment, style|
17
+ attachment.instance.label
18
+ end
19
+
20
+ Paperclip.interpolates :document_class do |attachment, style|
21
+ attachment.instance.document_class
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,4 @@
1
+ module ActiveMetadata
2
+ class History < ActiveRecord::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ActiveMetadata
2
+ class Note < ActiveRecord::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module ActiveMetadata
2
+ class Watcher < ActiveRecord::Base
3
+ attr_reader :notifier
4
+
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ <li>
2
+ <%= link_to "File: #{attachment.attach.original_filename}", attachment.attach.url %><br/>
3
+ <%= "Path: #{attachment.attach.path}"%>
4
+ <%= "Size: #{attachment.attach.size}"%>
5
+ <%= "Updated at: #{attachment.attach.instance_read(:updated_at)}"%> <br/>
6
+ <%= link_to "Elimina", active_metadata_destroy_attachment_path(@document.class,@document.id,attachment.label,attachment.id), :method => :delete, :remote => true %>
7
+ </li>
@@ -1,11 +1,3 @@
1
1
  <ul>
2
- <% @attachments.each do |item| %>
3
- <li>
4
- <%= link_to "File: #{item.attach.original_filename}", item.attach.url %><br/>
5
- <%= "Path: #{item.attach.path}"%>
6
- <%= "Size: #{item.attach.size}"%>
7
- <%= "Updated at: #{item.attach.instance_read(:updated_at)}"%> <br/>
8
- <%= link_to "Elimina", active_metadata_destroy_attachment_path(@document.class,@document.id,item.label,item.id), :method => :delete, :remote => true %>
9
- </li>
10
- <% end %>
11
- </ul>
2
+ <%= render :partial => "attachment", :collection => @attachments %>
3
+ </ul>
@@ -0,0 +1,7 @@
1
+ <li>
2
+ <b><%= note.note %></b><br/>
3
+ <%= "Inserita da: #{note.created_by}<br/>" unless note.created_by.nil? %>
4
+ Il: <%= note.created_at.strftime("%m/%d/%Y at %I:%M:%S") %> <br/>
5
+ <%= link_to "Edit", active_metadata_edit_note_path(@document.class,@document.id,note.label,note.id) %>
6
+ <%= link_to "Destroy", active_metadata_destroy_note_path(@document.class,@document.id,note.label,note.id), :method => :delete, :remote => true %>
7
+ </li>
@@ -1,11 +1,3 @@
1
1
  <ul>
2
- <% @notes.each do |note| %>
3
- <li>
4
- <b><%= note.note %></b><br/>
5
- <%= "Inserita da: #{note.created_by}<br/>" unless note.created_by.nil? %>
6
- Il: <%= note.created_at.strftime("%m/%d/%Y at %I:%M:%S") %> <br/>
7
- <%= link_to "Edit", active_metadata_edit_note_path(@document.class,@document.id,note.label,note.id) %>
8
- <%= link_to "Destroy", active_metadata_destroy_note_path(@document.class,@document.id,note.label,note.id), :method => :delete, :remote => true %>
9
- </li>
10
- <% end %>
2
+ <%= render :partial => "note", :collection => @notes %>
11
3
  </ul>
@@ -0,0 +1 @@
1
+ <%= render stream_partial_path(element), clean_class_name(element.class.to_s.downcase).to_sym => element %>
@@ -0,0 +1,3 @@
1
+ <ul>
2
+ <%= render :partial => 'element', :collection => @stream %>
3
+ </ul>
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>ActiveMetadata</title>
5
+ </head>
6
+ <body>
7
+
8
+ <%= yield %>
9
+
10
+ </body>
11
+ </html>
@@ -5,6 +5,9 @@ development:
5
5
  - 'updated_at'
6
6
  attachment_base_path: "public/system/metadata_attachments"
7
7
  attachment_base_url: "/system/metadata_attachments"
8
+ streamables:
9
+ - :note
10
+ - :attachment
8
11
 
9
12
  test:
10
13
  history_skip_fields:
@@ -13,3 +16,6 @@ test:
13
16
  - 'updated_at'
14
17
  attachment_base_path: "public/system/metadata_attachments"
15
18
  attachment_base_url: "/system/metadata_attachments"
19
+ streamables:
20
+ - :note
21
+ - :attachment
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
data/config/database.yml CHANGED
@@ -4,8 +4,10 @@ development:
4
4
  pool: 5
5
5
  timeout: 5000
6
6
 
7
- test:
7
+ test: &test
8
8
  adapter: sqlite3
9
9
  database: db/test.sqlite3
10
10
  pool: 5
11
- timeout: 5000
11
+ timeout: 5000
12
+ cucumber:
13
+ <<: *test
data/config/routes.rb CHANGED
@@ -1,36 +1,35 @@
1
- Rails.application.routes.draw do
1
+ ActiveMetadata::Engine.routes.draw do
2
2
 
3
- mount_at = ActiveMetadata::Engine.config.mount_at
4
-
5
- namespace "active_metadata" do
6
- #note
7
- match ':model_name/:model_id/:field_name/notes' => 'notes#index', :via => :get, :as => "notes", :path_prefix => mount_at
8
- match ':model_name/:model_id/:field_name/notes' => 'notes#create', :via => :post, :as => "create_note", :path_prefix => mount_at
9
- match ':model_name/:model_id/:field_name/notes/:id' => 'notes#destroy', :via => :delete, :as => "destroy_note", :path_prefix => mount_at
10
- match ':model_name/:model_id/:field_name/notes/:id/edit' => 'notes#edit', :via => :get, :as => "edit_note", :path_prefix => mount_at
11
- match ':model_name/:model_id/:field_name/notes/:id' => 'notes#update', :via => :put, :as => "update_note", :path_prefix => mount_at
12
- match ':model_name/:model_id/:field_name/notes/:id' => 'notes#show', :via => :get, :as => "show_note", :path_prefix => mount_at
13
- match ':model_name/:model_id/:field_name/notes/starred' => 'notes#starred', :via => :get, :as => "starred_notes", :path_prefix => mount_at
14
- match ':model_name/:model_id/:field_name/notes/:id/star' => 'notes#star', :via => :put, :as => "star_note", :path_prefix => mount_at
15
- match ':model_name/:model_id/:field_name/notes/:id/unstar' => 'notes#unstar', :via => :put, :as => "unstar_note", :path_prefix => mount_at
3
+ #stream
4
+ get ":model_name/:model_id/:field_name/stream" => 'stream#index', :as => 'active_metadata_stream'
5
+
6
+ #notes
7
+ match ':model_name/:model_id/:field_name/notes' => 'notes#index', :via => :get, :as => "active_metadata_notes"
8
+ match ':model_name/:model_id/:field_name/notes' => 'notes#create', :via => :post, :as => "active_metadata_create_note"
9
+ match ':model_name/:model_id/:field_name/notes/:id' => 'notes#destroy', :via => :delete, :as => "active_metadata_destroy_note"
10
+ match ':model_name/:model_id/:field_name/notes/:id/edit' => 'notes#edit', :via => :get, :as => "active_metadata_edit_note"
11
+ match ':model_name/:model_id/:field_name/notes/:id' => 'notes#update', :via => :put, :as => "active_metadata_update_note"
12
+ match ':model_name/:model_id/:field_name/notes/:id' => 'notes#show', :via => :get, :as => "active_metadata_show_note"
13
+ match ':model_name/:model_id/:field_name/notes/starred' => 'notes#starred', :via => :get, :as => "active_metadata_starred_notes"
14
+ match ':model_name/:model_id/:field_name/notes/:id/star' => 'notes#star', :via => :put, :as => "active_metadata_star_note"
15
+ match ':model_name/:model_id/:field_name/notes/:id/unstar' => 'notes#unstar', :via => :put, :as => "active_metadata_unstar_note"
16
16
 
17
17
  #history
18
- match ':model_name/:model_id/:field_name/histories' => 'histories#index', :via => :get, :as => "histories", :path_prefix => mount_at
18
+ match ':model_name/:model_id/:field_name/histories' => 'histories#index', :via => :get, :as => "active_metadata_histories"
19
19
 
20
20
  #attachments
21
- match ':model_name/:model_id/:field_name/attachments' => 'attachments#index', :via => :get, :as => "attachments", :path_prefix => mount_at
22
- match ':model_name/:model_id/:field_name/attachments' => 'attachments#create', :via => :post, :as => "create_attachment", :path_prefix => mount_at
23
- match ':model_name/:model_id/:field_name/attachments/:id' => 'attachments#destroy', :via => :delete, :as => "destroy_attachment", :path_prefix => mount_at
24
- match ':model_name/:model_id/:field_name/attachments/:id' => 'attachments#update', :via => :put, :as => "update_attachment", :path_prefix => mount_at
25
- match ':model_name/:model_id/:field_name/attachments/starred' => 'attachments#starred', :via => :get, :as => "starred_attachments", :path_prefix => mount_at
26
- match ':model_name/:model_id/:field_name/attachments/:id/star' => 'attachments#star', :via => :put, :as => "star_attachments", :path_prefix => mount_at
27
- match ':model_name/:model_id/:field_name/attachments/:id/unstar' => 'attachments#unstar', :via => :put, :as => "unstar_attachments", :path_prefix => mount_at
21
+ match ':model_name/:model_id/:field_name/attachments' => 'attachments#index', :via => :get, :as => "active_metadata_attachments"
22
+ match ':model_name/:model_id/:field_name/attachments' => 'attachments#create', :via => :post, :as => "active_metadata_create_attachment"
23
+ match ':model_name/:model_id/:field_name/attachments/:id' => 'attachments#destroy', :via => :delete, :as => "active_metadata_destroy_attachment"
24
+ match ':model_name/:model_id/:field_name/attachments/:id' => 'attachments#update', :via => :put, :as => "active_metadata_update_attachment"
25
+ match ':model_name/:model_id/:field_name/attachments/starred' => 'attachments#starred', :via => :get, :as => "active_metadata_starred_attachments"
26
+ match ':model_name/:model_id/:field_name/attachments/:id/star' => 'attachments#star', :via => :put, :as => "active_metadata_star_attachments"
27
+ match ':model_name/:model_id/:field_name/attachments/:id/unstar' => 'attachments#unstar', :via => :put, :as => "active_metadata_unstar_attachments"
28
28
 
29
29
  #alerts
30
- get ':model_name/:model_id/:field_name/watchers' => 'watchers#index', :as => "watchers", :path_prefix => mount_at
31
- post ':model_name/:model_id/:field_name/watchers/:user_id' => 'watchers#create',:as => "set_watcher", :path_prefix => mount_at
32
- delete ':model_name/:model_id/:field_name/watchers/:user_id' => 'watchers#destroy',:as => "unset_watcher", :path_prefix => mount_at
30
+ get ':model_name/:model_id/:field_name/watchers' => 'watchers#index', :as => "active_metadata_watchers"
31
+ post ':model_name/:model_id/:field_name/watchers/:user_id' => 'watchers#create', :as => "active_metadata_set_watcher"
32
+ delete ':model_name/:model_id/:field_name/watchers/:user_id' => 'watchers#destroy', :as => "active_metadata_unset_watcher"
33
33
  # TODO missing routes to notice of a read message
34
- end
35
34
 
36
35
  end
@@ -1,7 +1,7 @@
1
1
  class ActiveMetadataMigrations < ActiveRecord::Migration
2
2
  def self.up
3
3
 
4
- create_table :notes do |t|
4
+ create_table :active_metadata_notes do |t|
5
5
  t.text :note
6
6
  t.string :label
7
7
  t.string :document_class
@@ -12,12 +12,12 @@ class ActiveMetadataMigrations < ActiveRecord::Migration
12
12
  t.timestamps
13
13
  end
14
14
 
15
- add_index :notes, :document_id
16
- add_index :notes, :label
17
- add_index :notes, :updated_at
18
- add_index :notes, :document_class
15
+ add_index :active_metadata_notes, :document_id
16
+ add_index :active_metadata_notes, :label
17
+ add_index :active_metadata_notes, :updated_at
18
+ add_index :active_metadata_notes, :document_class
19
19
 
20
- create_table :histories do |t|
20
+ create_table :active_metadata_histories do |t|
21
21
  t.text :value
22
22
  t.string :label
23
23
  t.string :document_class
@@ -26,12 +26,12 @@ class ActiveMetadataMigrations < ActiveRecord::Migration
26
26
  t.timestamps
27
27
  end
28
28
 
29
- add_index :histories, :document_id
30
- add_index :histories, :label
31
- add_index :histories, :created_at
32
- add_index :histories, :document_class
29
+ add_index :active_metadata_histories, :document_id
30
+ add_index :active_metadata_histories, :label
31
+ add_index :active_metadata_histories, :created_at
32
+ add_index :active_metadata_histories, :document_class
33
33
 
34
- create_table :attachments do |t|
34
+ create_table :active_metadata_attachments do |t|
35
35
  t.string :label
36
36
  t.integer :document_id
37
37
  t.string :document_class
@@ -46,12 +46,12 @@ class ActiveMetadataMigrations < ActiveRecord::Migration
46
46
  t.timestamps
47
47
  end
48
48
 
49
- add_index :attachments, :document_id
50
- add_index :attachments, :label
51
- add_index :attachments, :attach_updated_at
52
- add_index :attachments, :document_class
49
+ add_index :active_metadata_attachments, :document_id
50
+ add_index :active_metadata_attachments, :label
51
+ add_index :active_metadata_attachments, :attach_updated_at
52
+ add_index :active_metadata_attachments, :document_class
53
53
 
54
- create_table :watchers do |t|
54
+ create_table :active_metadata_watchers do |t|
55
55
  t.integer :owner_id
56
56
  t.string :label
57
57
  t.string :document_class
@@ -59,18 +59,18 @@ class ActiveMetadataMigrations < ActiveRecord::Migration
59
59
  t.timestamps
60
60
  end
61
61
 
62
- add_index :watchers, :document_id
63
- add_index :watchers, :label
64
- add_index :watchers, :owner_id
65
- add_index :watchers, :created_at
62
+ add_index :active_metadata_watchers, :document_id
63
+ add_index :active_metadata_watchers, :label
64
+ add_index :active_metadata_watchers, :owner_id
65
+ add_index :active_metadata_watchers, :created_at
66
66
 
67
67
  end
68
68
 
69
69
  def self.down
70
- drop_table :notes
71
- drop_table :histories
72
- drop_table :attachments
73
- drop_table :watchers
70
+ drop_table :active_metadata_notes
71
+ drop_table :active_metadata_histories
72
+ drop_table :active_metadata_attachments
73
+ drop_table :active_metadata_watchers
74
74
  end
75
75
 
76
76
  end
@@ -0,0 +1,8 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+ require File.expand_path("../../../spec/dummy/config/environment.rb", __FILE__)
3
+ ENV["RAILS_ROOT"] ||= File.dirname(__FILE__) + "../../../spec/dummy"
4
+
5
+ require 'cucumber/rails'
6
+
7
+ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../../')
8
+ Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
@@ -1 +0,0 @@
1
- my test
@@ -1 +0,0 @@
1
- my updated test
@@ -6,9 +6,10 @@ module ActiveMetadata
6
6
  ## Define ModelMethods
7
7
  module Base
8
8
 
9
+ require 'active_metadata/helpers'
10
+ require 'active_metadata/streamable'
9
11
  require 'paperclip'
10
12
  require 'active_metadata/persistence/persistence'
11
- require 'active_metadata/helpers'
12
13
 
13
14
  def self.included(klass)
14
15
  klass.class_eval do
@@ -28,6 +29,7 @@ module ActiveMetadata
28
29
 
29
30
  include ActiveMetadata::Base::InstanceMethods
30
31
  include ActiveMetadata::Persistence
32
+ include ActiveMetadata::Streamable
31
33
 
32
34
  end
33
35
 
@@ -0,0 +1,11 @@
1
+ module ActiveMetadata
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace ActiveMetadata
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec
7
+ g.integration_tool :rspec
8
+ end
9
+
10
+ end
11
+ end
@@ -6,4 +6,18 @@ module ActiveMetadata::Helpers
6
6
  raise ArgumentError.new("invalid value for Boolean: \"#{str}\"")
7
7
  end
8
8
 
9
- end
9
+ end
10
+
11
+ class String
12
+ # transform a symbol/string into a class
13
+ def to_class
14
+ self.to_s.camelize.constantize
15
+ end
16
+ end
17
+
18
+ class Symbol
19
+ # transform a symbol/string into a class
20
+ def to_class
21
+ self.to_s.to_class
22
+ end
23
+ end