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.
- data/README.md +4 -0
- data/Rakefile +31 -0
- data/app/assets/javascripts/active_metadata/application.js +15 -0
- data/app/assets/stylesheets/active_metadata/application.css +13 -0
- data/app/controllers/active_metadata/application_controller.rb +4 -0
- data/app/controllers/active_metadata/attachments_controller.rb +4 -6
- data/app/controllers/active_metadata/notes_controller.rb +7 -10
- data/app/controllers/active_metadata/stream_controller.rb +12 -0
- data/app/helpers/active_metadata/application_helper.rb +4 -0
- data/app/helpers/active_metadata/stream_helper.rb +14 -0
- data/app/models/active_metadata/attachment.rb +26 -0
- data/app/models/active_metadata/history.rb +4 -0
- data/app/models/active_metadata/note.rb +4 -0
- data/app/models/active_metadata/watcher.rb +6 -0
- data/app/views/active_metadata/attachments/_attachment.html.erb +7 -0
- data/app/views/active_metadata/attachments/index.html.erb +2 -10
- data/app/views/active_metadata/notes/_note.html.erb +7 -0
- data/app/views/active_metadata/notes/index.html.erb +1 -9
- data/app/views/active_metadata/stream/_element.html.erb +1 -0
- data/app/views/active_metadata/stream/index.html.erb +3 -0
- data/app/views/layouts/active_metadata/application.html.erb +11 -0
- data/config/active_metadata.yml +6 -0
- data/config/cucumber.yml +8 -0
- data/config/database.yml +4 -2
- data/config/routes.rb +25 -26
- data/db/migrate/02_active_metadata_migrations.rb +24 -24
- data/features/{watchlist/add_a_user_to_a_watcher.feature → add_a_user_to_a_watcher.feature} +0 -0
- data/features/support/env.rb +8 -0
- data/features/supports/file.txt +0 -1
- data/features/supports/updated_file.txt +0 -1
- data/features/{watchlist/trigger_alert_on_modify.feature → trigger_alert_on_modify.feature} +0 -0
- data/lib/active_metadata/base.rb +3 -1
- data/lib/active_metadata/engine.rb +11 -0
- data/lib/active_metadata/helpers.rb +15 -1
- data/lib/active_metadata/persistence/{active_record/attachment.rb → attachment.rb} +10 -10
- data/lib/active_metadata/persistence/{active_record/history.rb → history.rb} +4 -4
- data/lib/active_metadata/persistence/{active_record/note.rb → note.rb} +8 -8
- data/lib/active_metadata/persistence/persistence.rb +14 -4
- data/lib/active_metadata/persistence/{active_record/watcher.rb → watcher.rb} +5 -5
- data/lib/active_metadata/streamable.rb +25 -0
- data/lib/active_metadata/version.rb +1 -1
- data/lib/active_metadata.rb +3 -3
- data/lib/{rake/ci.rb → tasks/active_metadata_tasks.rake} +27 -6
- data/lib/tasks/cucumber.rake +65 -0
- data/spec/active_metadata_yml.rb +25 -0
- data/spec/controllers/active_metadata/attachments_controller_spec.rb +40 -0
- data/spec/controllers/active_metadata/notes_controller_spec.rb +41 -0
- data/spec/controllers/active_metadata/stream_controller_spec.rb +46 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/{config/application.rb → spec/dummy/app/mailers/.gitkeep} +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +56 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +106 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/helpers/active_metadata/stream_helpers_spec.rb +23 -0
- data/spec/routing/active_metadata/stream_controller_routing_spec.rb +17 -0
- data/spec/spec_helper.rb +18 -31
- data/spec/streamable_spec.rb +120 -0
- data/spec/support/document.rb +0 -1
- data/spec/support/pdf_test_1.pdf +0 -0
- data/spec/support/section.rb +0 -1
- data/spec/support/user.rb +0 -2
- data/spec/views/active_metadata/stream/index.html.erb_spec.rb +5 -0
- metadata +165 -73
- data/app/helpers/application_helper.rb +0 -2
- data/config/initializers/inflections.rb +0 -7
- data/config/mongoid.yml +0 -28
- data/db/test.sqlite3 +0 -0
- data/features/supports/initializer.rb +0 -1
- data/lib/active_metadata/persistence/active_record.rb +0 -26
- data/lib/application_controller.rb +0 -28
- data/lib/application_helper.rb +0 -7
- data/lib/engine.rb +0 -29
- data/lib/model/active_record/attachment.rb +0 -22
- data/lib/model/active_record/history.rb +0 -2
- data/lib/model/active_record/note.rb +0 -2
- data/lib/model/active_record/watcher.rb +0 -4
- data/lib/rails/railties/tasks.rake +0 -16
- data/lib/rake/active_record_tasks.rb +0 -77
- data/lib/templates/active_metadata.yml +0 -17
- data/lib/templates/active_metadata_migrations +0 -71
- data/lib/templates/mongoid.yml +0 -20
- data/spec/benchmark_spec.rb +0 -35
- data/spec/controllers/metadata_controller_spec.rb +0 -14
data/README.md
ADDED
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
|
+
*/
|
@@ -1,10 +1,8 @@
|
|
1
1
|
module ActiveMetadata
|
2
2
|
class AttachmentsController < ApplicationController
|
3
3
|
|
4
|
-
unloadable
|
5
|
-
|
6
4
|
def index
|
7
|
-
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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,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,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
|
-
|
3
|
-
|
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
|
-
|
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 %>
|
data/config/active_metadata.yml
CHANGED
@@ -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
|
data/config/cucumber.yml
ADDED
@@ -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
data/config/routes.rb
CHANGED
@@ -1,36 +1,35 @@
|
|
1
|
-
|
1
|
+
ActiveMetadata::Engine.routes.draw do
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
match ':model_name/:model_id/:field_name/notes' => 'notes#index', :via => :get, :as => "
|
8
|
-
match ':model_name/:model_id/:field_name/notes' => 'notes#create', :via => :post, :as => "
|
9
|
-
match ':model_name/:model_id/:field_name/notes/:id' => 'notes#destroy', :via => :delete, :as => "
|
10
|
-
match ':model_name/:model_id/:field_name/notes/:id/edit' => 'notes#edit', :via => :get, :as => "
|
11
|
-
match ':model_name/:model_id/:field_name/notes/:id' => 'notes#update', :via => :put, :as => "
|
12
|
-
match ':model_name/:model_id/:field_name/notes/:id' => 'notes#show', :via => :get, :as => "
|
13
|
-
match ':model_name/:model_id/:field_name/notes/starred' => 'notes#starred', :via => :get, :as => "
|
14
|
-
match ':model_name/:model_id/:field_name/notes/:id/star' => 'notes#star', :via => :put, :as => "
|
15
|
-
match ':model_name/:model_id/:field_name/notes/:id/unstar' => 'notes#unstar', :via => :put, :as => "
|
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 => "
|
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 => "
|
22
|
-
match ':model_name/:model_id/:field_name/attachments' => 'attachments#create', :via => :post, :as => "
|
23
|
-
match ':model_name/:model_id/:field_name/attachments/:id' => 'attachments#destroy', :via => :delete, :as => "
|
24
|
-
match ':model_name/:model_id/:field_name/attachments/:id' => 'attachments#update', :via => :put, :as => "
|
25
|
-
match ':model_name/:model_id/:field_name/attachments/starred' => 'attachments#starred', :via => :get, :as => "
|
26
|
-
match ':model_name/:model_id/:field_name/attachments/:id/star' => 'attachments#star', :via => :put, :as => "
|
27
|
-
match ':model_name/:model_id/:field_name/attachments/:id/unstar' => 'attachments#unstar', :via => :put, :as => "
|
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 => "
|
31
|
-
post ':model_name/:model_id/:field_name/watchers/:user_id' => 'watchers#create'
|
32
|
-
delete ':model_name/:model_id/:field_name/watchers/:user_id' => 'watchers#destroy'
|
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 :
|
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 :
|
16
|
-
add_index :
|
17
|
-
add_index :
|
18
|
-
add_index :
|
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 :
|
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 :
|
30
|
-
add_index :
|
31
|
-
add_index :
|
32
|
-
add_index :
|
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 :
|
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 :
|
50
|
-
add_index :
|
51
|
-
add_index :
|
52
|
-
add_index :
|
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 :
|
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 :
|
63
|
-
add_index :
|
64
|
-
add_index :
|
65
|
-
add_index :
|
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 :
|
71
|
-
drop_table :
|
72
|
-
|
73
|
-
|
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
|
File without changes
|
@@ -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 }
|
data/features/supports/file.txt
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
my test
|
@@ -1 +0,0 @@
|
|
1
|
-
my updated test
|
File without changes
|
data/lib/active_metadata/base.rb
CHANGED
@@ -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
|
|
@@ -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
|