event_calendar_engine 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. data/Gemfile +23 -0
  2. data/Gemfile.lock +161 -0
  3. data/README +1 -0
  4. data/Rakefile +39 -0
  5. data/VERSION +1 -0
  6. data/app/controllers/application_controller.rb +4 -0
  7. data/app/controllers/attendees_controller.rb +53 -0
  8. data/app/controllers/event_calendar/application_controller.rb +5 -0
  9. data/app/controllers/event_revisions_controller.rb +26 -0
  10. data/app/controllers/events_controller.rb +129 -0
  11. data/app/helpers/event_calendar/application_helper.rb +118 -0
  12. data/app/helpers/events_helper.rb +2 -0
  13. data/app/models/attendee.rb +6 -0
  14. data/app/models/deletable_instance_methods.rb +7 -0
  15. data/app/models/event.rb +124 -0
  16. data/app/models/event_revision.rb +9 -0
  17. data/app/models/participant.rb +23 -0
  18. data/app/models/participator.rb +20 -0
  19. data/app/views/attendees/index.html.erb +14 -0
  20. data/app/views/attendees/new.html.erb +13 -0
  21. data/app/views/event-calendar-shared/_flash.html.erb +7 -0
  22. data/app/views/event-calendar-shared/_main_menu.html.erb +3 -0
  23. data/app/views/event-calendar-shared/_navigation.html.erb +15 -0
  24. data/app/views/event_revisions/index.html.erb +31 -0
  25. data/app/views/event_revisions/show.html.erb +5 -0
  26. data/app/views/events/_browse_event_revisions.html.erb +19 -0
  27. data/app/views/events/_event.html.erb +10 -0
  28. data/app/views/events/_event_details.html.erb +26 -0
  29. data/app/views/events/_form.html.erb +36 -0
  30. data/app/views/events/attendees.html.erb +29 -0
  31. data/app/views/events/edit.html.erb +3 -0
  32. data/app/views/events/index.html.erb +41 -0
  33. data/app/views/events/new.html.erb +3 -0
  34. data/app/views/events/search.html.erb +11 -0
  35. data/app/views/events/show.html.erb +30 -0
  36. data/app/views/layouts/application.html.erb +49 -0
  37. data/config/application.rb +42 -0
  38. data/config/blueprint_settings.yml +10 -0
  39. data/config/boot.rb +13 -0
  40. data/config/cucumber.yml +8 -0
  41. data/config/database.example.yml +22 -0
  42. data/config/environment.rb +5 -0
  43. data/config/environments/development.rb +26 -0
  44. data/config/environments/production.rb +49 -0
  45. data/config/environments/test.rb +38 -0
  46. data/config/initializers/backtrace_silencers.rb +7 -0
  47. data/config/initializers/formtastic.rb +55 -0
  48. data/config/initializers/inflections.rb +10 -0
  49. data/config/initializers/mime_types.rb +5 -0
  50. data/config/initializers/secret_token.rb +9 -0
  51. data/config/initializers/session_store.rb +10 -0
  52. data/config/locales/en.yml +5 -0
  53. data/config/routes.rb +67 -0
  54. data/db/migrate/20101011142543_create_events.rb +19 -0
  55. data/db/migrate/20101011172027_create_attendees.rb +16 -0
  56. data/db/migrate/20101011200048_make_events_revisable.rb +25 -0
  57. data/db/schema.rb +45 -0
  58. data/db/seeds.rb +7 -0
  59. data/lib/event_calendar.rb +3 -0
  60. data/lib/event_calendar/engine.rb +25 -0
  61. data/lib/generators/event_calendar/install/USAGE +5 -0
  62. data/lib/generators/event_calendar/install/install_generator.rb +19 -0
  63. data/lib/generators/event_calendar/install/templates/event_calendar.rake +169 -0
  64. data/lib/tasks/blueprint.rake +25 -0
  65. data/lib/tasks/cucumber.rake +53 -0
  66. data/public/404.html +26 -0
  67. data/public/422.html +26 -0
  68. data/public/500.html +26 -0
  69. data/public/favicon.ico +0 -0
  70. data/public/images/rails.png +0 -0
  71. data/public/javascripts/event_calendar.js +62 -0
  72. data/public/javascripts/event_calendar_behaviors.js +131 -0
  73. data/public/javascripts/fullcalendar.js +3965 -0
  74. data/public/javascripts/jquery-ui-1.7.2.custom.min.js +298 -0
  75. data/public/javascripts/jquery.clonePosition.js +27 -0
  76. data/public/javascripts/jquery.js +154 -0
  77. data/public/javascripts/jquery.qtip-1.0.0-rc3.js +2149 -0
  78. data/public/javascripts/jquery.string.1.0-min.js +6 -0
  79. data/public/javascripts/jquery.tablesorter.min.js +2 -0
  80. data/public/javascripts/lowpro.jquery.js +224 -0
  81. data/public/javascripts/rails.js +132 -0
  82. data/public/robots.txt +5 -0
  83. data/public/stylesheets/blueprint/grid.css +280 -0
  84. data/public/stylesheets/blueprint/icons/cross.png +0 -0
  85. data/public/stylesheets/blueprint/icons/doc.png +0 -0
  86. data/public/stylesheets/blueprint/icons/email.png +0 -0
  87. data/public/stylesheets/blueprint/icons/external.png +0 -0
  88. data/public/stylesheets/blueprint/icons/feed.png +0 -0
  89. data/public/stylesheets/blueprint/icons/im.png +0 -0
  90. data/public/stylesheets/blueprint/icons/key.png +0 -0
  91. data/public/stylesheets/blueprint/icons/pdf.png +0 -0
  92. data/public/stylesheets/blueprint/icons/tick.png +0 -0
  93. data/public/stylesheets/blueprint/icons/visited.png +0 -0
  94. data/public/stylesheets/blueprint/icons/xls.png +0 -0
  95. data/public/stylesheets/blueprint/ie.css +36 -0
  96. data/public/stylesheets/blueprint/plugins/buttons/icons/cross.png +0 -0
  97. data/public/stylesheets/blueprint/plugins/buttons/icons/key.png +0 -0
  98. data/public/stylesheets/blueprint/plugins/buttons/icons/tick.png +0 -0
  99. data/public/stylesheets/blueprint/plugins/buttons/readme.txt +32 -0
  100. data/public/stylesheets/blueprint/plugins/buttons/screen.css +97 -0
  101. data/public/stylesheets/blueprint/plugins/fancy-type/readme.txt +14 -0
  102. data/public/stylesheets/blueprint/plugins/fancy-type/screen.css +71 -0
  103. data/public/stylesheets/blueprint/plugins/link-icons/icons/doc.png +0 -0
  104. data/public/stylesheets/blueprint/plugins/link-icons/icons/email.png +0 -0
  105. data/public/stylesheets/blueprint/plugins/link-icons/icons/external.png +0 -0
  106. data/public/stylesheets/blueprint/plugins/link-icons/icons/feed.png +0 -0
  107. data/public/stylesheets/blueprint/plugins/link-icons/icons/im.png +0 -0
  108. data/public/stylesheets/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  109. data/public/stylesheets/blueprint/plugins/link-icons/icons/visited.png +0 -0
  110. data/public/stylesheets/blueprint/plugins/link-icons/icons/xls.png +0 -0
  111. data/public/stylesheets/blueprint/plugins/link-icons/readme.txt +18 -0
  112. data/public/stylesheets/blueprint/plugins/link-icons/screen.css +40 -0
  113. data/public/stylesheets/blueprint/plugins/rtl/readme.txt +10 -0
  114. data/public/stylesheets/blueprint/plugins/rtl/screen.css +110 -0
  115. data/public/stylesheets/blueprint/plugins/silksprite/sprite.css +1 -0
  116. data/public/stylesheets/blueprint/plugins/silksprite/sprites.png +0 -0
  117. data/public/stylesheets/blueprint/print.css +29 -0
  118. data/public/stylesheets/blueprint/readme.txt +12 -0
  119. data/public/stylesheets/blueprint/screen.css +429 -0
  120. data/public/stylesheets/error_messages.css +65 -0
  121. data/public/stylesheets/formtastic.css +131 -0
  122. data/public/stylesheets/formtastic_changes.css +14 -0
  123. data/public/stylesheets/fullcalendar.css +574 -0
  124. data/public/stylesheets/fullcalendar_changes.css +0 -0
  125. data/public/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  126. data/public/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  127. data/public/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  128. data/public/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  129. data/public/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  130. data/public/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  131. data/public/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  132. data/public/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  133. data/public/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
  134. data/public/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  135. data/public/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
  136. data/public/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
  137. data/public/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  138. data/public/stylesheets/smoothness/jquery-ui-1.7.2.custom.css +406 -0
  139. data/public/stylesheets/tablesorter/blue/asc.gif +0 -0
  140. data/public/stylesheets/tablesorter/blue/bg.gif +0 -0
  141. data/public/stylesheets/tablesorter/blue/desc.gif +0 -0
  142. data/public/stylesheets/tablesorter/blue/style.css +39 -0
  143. data/public/stylesheets/text_and_colors.css +49 -0
  144. data/spec/controllers/attendees_controller_spec.rb +27 -0
  145. data/spec/controllers/event_revisions_controller_spec.rb +86 -0
  146. data/spec/controllers/events_controller_spec.rb +168 -0
  147. data/spec/fixtures/event_calendar_events.yml +8 -0
  148. data/spec/models/deletable_instance_methods_spec.rb +61 -0
  149. data/spec/models/event_revision_spec.rb +36 -0
  150. data/spec/models/event_spec.rb +139 -0
  151. data/spec/spec_helper.rb +27 -0
  152. data/spec/spec_helpers/mocks.rb +6 -0
  153. data/vendor/plugins/searchable_by/MIT-LICENSE +20 -0
  154. data/vendor/plugins/searchable_by/README +55 -0
  155. data/vendor/plugins/searchable_by/Rakefile +23 -0
  156. data/vendor/plugins/searchable_by/init.rb +2 -0
  157. data/vendor/plugins/searchable_by/install.rb +1 -0
  158. data/vendor/plugins/searchable_by/lib/searchable_by.rb +137 -0
  159. data/vendor/plugins/searchable_by/tasks/searchable_by_tasks.rake +4 -0
  160. data/vendor/plugins/searchable_by/test/boot.rb +21 -0
  161. data/vendor/plugins/searchable_by/test/database.yml +22 -0
  162. data/vendor/plugins/searchable_by/test/fixtures/companies.yml +10 -0
  163. data/vendor/plugins/searchable_by/test/fixtures/company.rb +5 -0
  164. data/vendor/plugins/searchable_by/test/fixtures/employee.rb +5 -0
  165. data/vendor/plugins/searchable_by/test/fixtures/employees.yml +28 -0
  166. data/vendor/plugins/searchable_by/test/fixtures/schema.rb +18 -0
  167. data/vendor/plugins/searchable_by/test/helper.rb +12 -0
  168. data/vendor/plugins/searchable_by/test/lib/activerecord_test_case.rb +43 -0
  169. data/vendor/plugins/searchable_by/test/lib/activerecord_test_connector.rb +75 -0
  170. data/vendor/plugins/searchable_by/test/lib/load_fixtures.rb +9 -0
  171. data/vendor/plugins/searchable_by/test/searchable_by_test.rb +73 -0
  172. data/vendor/plugins/searchable_by/uninstall.rb +1 -0
  173. metadata +606 -0
@@ -0,0 +1,38 @@
1
+ EventCalendar::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+
36
+ # require all spec_helpers/*
37
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec','spec_helpers','**','*.rb'))].each {|f| require f}
38
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,55 @@
1
+ # Set the default text field size when input is a string. Default is 50.
2
+ # Formtastic::SemanticFormBuilder.default_text_field_size = 50
3
+
4
+ # Set the default text area height when input is a text. Default is 20.
5
+ # Formtastic::SemanticFormBuilder.default_text_area_height = 5
6
+
7
+ # Should all fields be considered "required" by default?
8
+ # Rails 2 only, ignored by Rails 3 because it will never fall back to this default.
9
+ # Defaults to true.
10
+ # Formtastic::SemanticFormBuilder.all_fields_required_by_default = true
11
+
12
+ # Should select fields have a blank option/prompt by default?
13
+ # Defaults to true.
14
+ # Formtastic::SemanticFormBuilder.include_blank_for_select_by_default = true
15
+
16
+ # Set the string that will be appended to the labels/fieldsets which are required
17
+ # It accepts string or procs and the default is a localized version of
18
+ # '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
19
+ # in your locale, it will replace the abbr title properly. But if you don't want to use
20
+ # abbr tag, you can simply give a string as below
21
+ # Formtastic::SemanticFormBuilder.required_string = "(required)"
22
+
23
+ # Set the string that will be appended to the labels/fieldsets which are optional
24
+ # Defaults to an empty string ("") and also accepts procs (see required_string above)
25
+ # Formtastic::SemanticFormBuilder.optional_string = "(optional)"
26
+
27
+ # Set the way inline errors will be displayed.
28
+ # Defaults to :sentence, valid options are :sentence, :list and :none
29
+ # Formtastic::SemanticFormBuilder.inline_errors = :sentence
30
+
31
+ # Set the method to call on label text to transform or format it for human-friendly
32
+ # reading when formtastic is used without object. Defaults to :humanize.
33
+ # Formtastic::SemanticFormBuilder.label_str_method = :humanize
34
+
35
+ # Set the array of methods to try calling on parent objects in :select and :radio inputs
36
+ # for the text inside each @<option>@ tag or alongside each radio @<input>@. The first method
37
+ # that is found on the object will be used.
38
+ # Defaults to ["to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
39
+ # Formtastic::SemanticFormBuilder.collection_label_methods = [
40
+ # "to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
41
+
42
+ # Formtastic by default renders inside li tags the input, hints and then
43
+ # errors messages. Sometimes you want the hints to be rendered first than
44
+ # the input, in the following order: hints, input and errors. You can
45
+ # customize it doing just as below:
46
+ # Formtastic::SemanticFormBuilder.inline_order = [:input, :hints, :errors]
47
+
48
+ # Specifies if labels/hints for input fields automatically be looked up using I18n.
49
+ # Default value: false. Overridden for specific fields by setting value to true,
50
+ # i.e. :label => true, or :hint => true (or opposite depending on initialized value)
51
+ # Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false
52
+
53
+ # You can add custom inputs or override parts of Formtastic by subclassing SemanticFormBuilder and
54
+ # specifying that class here. Defaults to SemanticFormBuilder.
55
+ # Formtastic::SemanticFormHelper.builder = MyCustomBuilder
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,9 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ if defined?(EventCalendar::Application)
8
+ EventCalendar::Application.config.secret_token = '495e5075c990834c82f6826524af9f786bfc8a0555c8272237ad6de534155509676bd0602c331c263f4d75ce7f69a336fb3569e789c30b5fd9269ceb25be50f5'
9
+ end
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ if defined?(EventCalendar::Application)
4
+ EventCalendar::Application.config.session_store :cookie_store, :key => '_event-calendar_session'
5
+ end
6
+
7
+ # Use the database for sessions instead of the cookie-based default,
8
+ # which shouldn't be used to store highly confidential information
9
+ # (create the session table with "rake db:sessions:create")
10
+ # EventCalendar::Application.config.session_store :active_record_store
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
data/config/routes.rb ADDED
@@ -0,0 +1,67 @@
1
+ Rails.application.routes.draw do
2
+ root :to => "events#index"
3
+ resources :events do
4
+ resources :attendees
5
+ end
6
+ resources :event_revisions do
7
+ member do
8
+ post :restore
9
+ end
10
+ end
11
+ # The priority is based upon order of creation:
12
+ # first created -> highest priority.
13
+
14
+ # Sample of regular route:
15
+ # match 'products/:id' => 'catalog#view'
16
+ # Keep in mind you can assign values other than :controller and :action
17
+
18
+ # Sample of named route:
19
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
20
+ # This route can be invoked with purchase_url(:id => product.id)
21
+
22
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
23
+ # resources :products
24
+
25
+ # Sample resource route with options:
26
+ # resources :products do
27
+ # member do
28
+ # get 'short'
29
+ # post 'toggle'
30
+ # end
31
+ #
32
+ # collection do
33
+ # get 'sold'
34
+ # end
35
+ # end
36
+
37
+ # Sample resource route with sub-resources:
38
+ # resources :products do
39
+ # resources :comments, :sales
40
+ # resource :seller
41
+ # end
42
+
43
+ # Sample resource route with more complex sub-resources
44
+ # resources :products do
45
+ # resources :comments
46
+ # resources :sales do
47
+ # get 'recent', :on => :collection
48
+ # end
49
+ # end
50
+
51
+ # Sample resource route within a namespace:
52
+ # namespace :admin do
53
+ # # Directs /admin/products/* to Admin::ProductsController
54
+ # # (app/controllers/admin/products_controller.rb)
55
+ # resources :products
56
+ # end
57
+
58
+ # You can have the root of your site routed with "root"
59
+ # just remember to delete public/index.html.
60
+ # root :to => "welcome#index"
61
+
62
+ # See how all your routes lay out with "rake routes"
63
+
64
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
65
+ # Note: This route will make all actions in every controller accessible via GET requests.
66
+ # match ':controller(/:action(/:id(.:format)))'
67
+ end
@@ -0,0 +1,19 @@
1
+ class CreateEvents < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :event_calendar_events do |t|
4
+ t.string :name
5
+ t.string :event_type
6
+ t.date :start_on
7
+ t.date :end_on
8
+ t.text :location
9
+ t.text :description
10
+ t.text :notes
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+
16
+ def self.down
17
+ drop_table :event_calendar_events
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ class CreateAttendees < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :event_calendar_attendees do |t|
4
+ t.integer :event_id
5
+ t.integer :participant_id
6
+ t.string :participant_type
7
+ t.string :role
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :event_calendar_attendees
15
+ end
16
+ end
@@ -0,0 +1,25 @@
1
+ class MakeEventsRevisable < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :event_calendar_events, :revisable_original_id, :integer
4
+ add_column :event_calendar_events, :revisable_branched_from_id, :integer
5
+ add_column :event_calendar_events, :revisable_number, :integer, :default => 0
6
+ add_column :event_calendar_events, :revisable_name, :string
7
+ add_column :event_calendar_events, :revisable_type, :string
8
+ add_column :event_calendar_events, :revisable_current_at, :datetime
9
+ add_column :event_calendar_events, :revisable_revised_at, :datetime
10
+ add_column :event_calendar_events, :revisable_deleted_at, :datetime
11
+ add_column :event_calendar_events, :revisable_is_current, :boolean, :default => true
12
+ end
13
+
14
+ def self.down
15
+ remove_column :event_calendar_events, :revisable_original_id
16
+ remove_column :event_calendar_events, :revisable_branched_from_id
17
+ remove_column :event_calendar_events, :revisable_number
18
+ remove_column :event_calendar_events, :revisable_name
19
+ remove_column :event_calendar_events, :revisable_type
20
+ remove_column :event_calendar_events, :revisable_current_at
21
+ remove_column :event_calendar_events, :revisable_revised_at
22
+ remove_column :event_calendar_events, :revisable_deleted_at
23
+ remove_column :event_calendar_events, :revisable_is_current
24
+ end
25
+ end
data/db/schema.rb ADDED
@@ -0,0 +1,45 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20101011200048) do
14
+
15
+ create_table "event_calendar_attendees", :force => true do |t|
16
+ t.integer "event_id"
17
+ t.integer "participant_id"
18
+ t.string "participant_type"
19
+ t.string "role"
20
+ t.datetime "created_at"
21
+ t.datetime "updated_at"
22
+ end
23
+
24
+ create_table "event_calendar_events", :force => true do |t|
25
+ t.string "name"
26
+ t.string "event_type"
27
+ t.date "start_on"
28
+ t.date "end_on"
29
+ t.text "location"
30
+ t.text "description"
31
+ t.text "notes"
32
+ t.datetime "created_at"
33
+ t.datetime "updated_at"
34
+ t.integer "revisable_original_id"
35
+ t.integer "revisable_branched_from_id"
36
+ t.integer "revisable_number", :default => 0
37
+ t.string "revisable_name"
38
+ t.string "revisable_type"
39
+ t.datetime "revisable_current_at"
40
+ t.datetime "revisable_revised_at"
41
+ t.datetime "revisable_deleted_at"
42
+ t.boolean "revisable_is_current", :default => true
43
+ end
44
+
45
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Mayor.create(:name => 'Daley', :city => cities.first)
@@ -0,0 +1,3 @@
1
+ module EventCalendar
2
+ require "event_calendar/engine" if defined?(Rails)
3
+ end
@@ -0,0 +1,25 @@
1
+ require "event_calendar"
2
+ require "rails"
3
+
4
+ module EventCalendar
5
+ class Engine < Rails::Engine
6
+ ASSET_PREFIX = "event_calendar"
7
+ ENGINEER_VERSION = "0.2.3"
8
+
9
+ initializer "event_calendar.require_dependencies" do
10
+ require 'bundler'
11
+ gemfile = Bundler::Definition.build(root.join('Gemfile'), root.join('Gemfile.lock'), {})
12
+ specs = gemfile.dependencies.select do |d|
13
+ d.name != 'engineer' and (d.groups & [:default, :production]).any?
14
+ end
15
+
16
+ specs.collect { |s| s.autorequire || [s.name] }.flatten.each do |r|
17
+ require r
18
+ end
19
+ end
20
+
21
+ initializer "event_calendar.asset_path" do |app|
22
+ app.config.middleware.use ::ActionDispatch::Static, "#{root}/public"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Install event_calendar
3
+
4
+ Example:
5
+ rails generate event_calendar:install
@@ -0,0 +1,19 @@
1
+ module EventCalendar
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ def self.source_root
6
+ @source_root ||= File.expand_path('../templates', __FILE__)
7
+ end
8
+
9
+ def install_rake_tasks
10
+ directory '.', File.join("lib", "tasks")
11
+ end
12
+
13
+ def rake_engine_install
14
+ rake "event_calendar:install"
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,169 @@
1
+ if defined? EventCalendar::Engine
2
+ namespace "event_calendar" do
3
+
4
+ # Migrate after schema in case there is no engine schema: at least we'll get the migrations.
5
+ task :install => %w{assets db:schema db:migrate db:migrate:seed}
6
+
7
+ desc "Import event_calendar's assets and new db migrations"
8
+ task :update => %w{assets db:migrate}
9
+
10
+ namespace :db do #
11
+
12
+ def host_migration(new_migration_name, &block)
13
+ require 'rails/generators/active_record'
14
+ db_migrate = File.join Rails.root, *%w{db migrate}
15
+ mkdir_p db_migrate unless File.exists? db_migrate
16
+
17
+ # TODO Kill after https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4412
18
+ sleep 1 # wait for timestamp to change.
19
+
20
+ migration_number = ActiveRecord::Generators::Base.next_migration_number(db_migrate)
21
+ new_migration = File.join db_migrate, "#{migration_number}_#{new_migration_name}.rb"
22
+ tmp_migration = File.join Dir::tmpdir, "#{migration_number}_#{new_migration_name}.rb"
23
+
24
+ File.open(tmp_migration, "w") do |f|
25
+ f << block.call
26
+ end
27
+
28
+ cp tmp_migration, new_migration
29
+ end
30
+
31
+ def import_migration(original_file, new_migration_name, &block)
32
+ host_migration new_migration_name do
33
+ block.call File.read original_file
34
+ end
35
+ end
36
+
37
+ desc "Import event_calendar's new db migrations"
38
+ task :migrate do
39
+ require 'rails/generators/active_record'
40
+ db_migrate = File.join Rails.root, *%w{db migrate}
41
+
42
+ # Consider the set of engine migrations, in chronological order.
43
+ migrations = Dir[File.join EventCalendar::Engine.root, *%w{db migrate [0-9]*_*.rb}]
44
+ migrations.sort!
45
+
46
+ # See if the host already has a schema migration.
47
+ last_migration_in_schema = migrations.reverse.detect do |migration|
48
+ name = File.basename(migration).match(/\d+_(.*)\.rb/)[1]
49
+ Dir[File.join(db_migrate, "[0-9]*_event_calendar_schema_after_#{name}.rb")].any?
50
+ end
51
+
52
+ # If so, do not import any migrations implied by the schema
53
+ # (recall slice! *removes* the indicated range, leaving the rest.)
54
+ migrations.slice! 0..migrations.index(last_migration_in_schema) if last_migration_in_schema
55
+
56
+ # Of the remainder
57
+ migrations.each do |old_migration|
58
+ old_name = File.basename(old_migration).match(/\d+_(.*)\.rb/)[1]
59
+ new_name = "event_calendar_#{old_name}"
60
+
61
+ # Skip this single migration if we already have it
62
+ next if Dir[File.join(db_migrate, "[0-9]*_#{new_name}.rb")].any?
63
+
64
+ import_migration old_migration, new_name do |migration_source|
65
+ migration_source.gsub "class #{old_name.camelize}", "class #{new_name.camelize}"
66
+ end
67
+ end
68
+ end
69
+
70
+ desc "Import event_calendar's schema as a db migration"
71
+ task :schema do
72
+ schema = File.join EventCalendar::Engine.root, *%w{db schema.rb}
73
+ if File.exist? schema
74
+ migrations = Dir[File.join EventCalendar::Engine.root, *%w{db migrate [0-9]*_*.rb}]
75
+ latest_migration = migrations.sort.last
76
+
77
+ migration_name = if latest_migration
78
+ latest_migration_name = File.basename(latest_migration).match(/^\d+_(.+)\.rb$/)[1]
79
+ "event_calendar_schema_after_#{latest_migration_name}"
80
+ else
81
+ "event_calendar_schema"
82
+ end
83
+
84
+ import_migration schema, migration_name do |schema_source|
85
+ # Strip schema declaration
86
+ schema_source.gsub! /\A.*^ActiveRecord::Schema.define\(:version => \d+\) do/m, ''
87
+ schema_source.strip!.gsub!(/^end\Z/m, '').strip!
88
+
89
+ # Indent everything 2 and strip trailing white space
90
+ schema_source.gsub!(/^/, ' ').gsub!(/[\t ]+$/, '')
91
+
92
+ # Wrap with migration class declaration
93
+ <<-EOF
94
+ class #{migration_name.camelize} < ActiveRecord::Migration
95
+ def self.up
96
+ #{schema_source}
97
+ end
98
+ end
99
+ EOF
100
+ end
101
+ end
102
+ end
103
+
104
+ task "migrate:seed" do
105
+ migration_name = "event_calendar_seed"
106
+ if File.exist? File.join(EventCalendar::Engine.root, 'db', 'seeds.rb')
107
+ host_migration migration_name do
108
+ <<-EOF
109
+ class #{migration_name.camelize} < ActiveRecord::Migration
110
+ def self.up
111
+ load File.join(EventCalendar::Engine.root, 'db', 'seeds.rb')
112
+ end
113
+ end
114
+ EOF
115
+ end
116
+ end
117
+ end
118
+
119
+ desc "Load event_calendar's seed data"
120
+ task :seed => :environment do
121
+ seed_file = File.join(EventCalendar::Engine.root, 'db', 'seeds.rb')
122
+ load(seed_file) if File.exist?(seed_file)
123
+ end
124
+
125
+ end
126
+
127
+ desc "Link (or copy) event_calendar's static assets"
128
+ task :assets, [:copy] => :environment do |t, args|
129
+ engine_asset_path = File.join(
130
+ Rails.application.paths.public.to_a.first,
131
+ EventCalendar::Engine::ASSET_PREFIX)
132
+
133
+ rm_rf engine_asset_path
134
+ host_asset_path = EventCalendar::Engine.paths.public.to_a.first
135
+
136
+ link = lambda do
137
+ begin
138
+ ln_s host_asset_path, engine_asset_path
139
+ true
140
+ rescue NotImplementedError
141
+ false
142
+ end
143
+ end
144
+
145
+ copy = lambda { cp_r host_asset_path, engine_asset_path }
146
+
147
+ not args[:copy] and link.call or copy.call
148
+ end
149
+
150
+ end
151
+
152
+ namespace :engines do
153
+
154
+ desc "Load seed data from all engines"
155
+ task "db:seed" => "event_calendar:db:seed"
156
+
157
+ desc "Import new migrations from all engines"
158
+ task "db:migrate" => "event_calendar:db:migrate"
159
+
160
+ desc "Link (or copy) static assets from all engines"
161
+ task :assets, [:copy] => "event_calendar:assets"
162
+
163
+ desc "Import assets and new db migrations from all engines"
164
+ task :update => "event_calendar:update"
165
+
166
+ end
167
+
168
+ task "db:seed" => "engines:db:seed"
169
+ end