motr-cargo 0.0.1

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.
data/Gemfile ADDED
@@ -0,0 +1,30 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails", "~> 3.0"
4
+ gem "capybara", ">= 0.4.0"
5
+ gem "sqlite3-ruby"
6
+ gem "rspec-rails"
7
+ gem "mocha","0.9.12"
8
+ gem 'mongoid-rspec'
9
+
10
+ group :mongoid do
11
+ gem 'mongo', '~> 1.3'
12
+ gem 'bson_ext', '~> 1.3'
13
+ gem 'mongoid', '~> 2.0'
14
+ end
15
+
16
+ gem "motr", :path => '../motr'
17
+ #gem "motr", '0.0.6'
18
+
19
+ group :test do
20
+ gem 'guard-rspec'
21
+ gem 'growl'
22
+ gem 'fabrication'
23
+ gem 'ffaker'
24
+ #gem 'spork', '~> 0.9.0.rc', :require => false
25
+ end
26
+
27
+
28
+ # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
29
+ # gem 'ruby-debug'
30
+ # gem 'ruby-debug19'
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 Kurb Media LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1 @@
1
+ = Motr-Cargo
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'bundler'
10
+ Bundler.setup
11
+ Bundler::GemHelper.install_tasks
12
+
13
+
14
+ require 'rake'
15
+ require 'rake/rdoctask'
16
+
17
+ require 'rake/testtask'
18
+
19
+ Rake::TestTask.new(:test) do |t|
20
+ t.libs << 'lib'
21
+ t.libs << 'test'
22
+ t.pattern = 'test/**/*_test.rb'
23
+ t.verbose = false
24
+ end
25
+
26
+ task :default => :test
27
+
28
+ Rake::RDocTask.new(:rdoc) do |rdoc|
29
+ rdoc.rdoc_dir = 'rdoc'
30
+ rdoc.title = 'motr-cargo'
31
+ rdoc.options << '--line-numbers' << '--inline-source'
32
+ rdoc.rdoc_files.include('README.rdoc')
33
+ rdoc.rdoc_files.include('lib/**/*.rb')
34
+ end
@@ -0,0 +1,33 @@
1
+ module Motr
2
+ module Cargo::Context
3
+
4
+ module Mongoid
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ mod_opts = cargo_mod_options
9
+
10
+ field :name, :type => String
11
+ field :body, :type => String
12
+ field :meta, :type => Hash
13
+
14
+ cname = self.name.to_s.pluralize.underscore
15
+ packs = [mod_opts[:for]].flatten.compact
16
+ if packs.empty?
17
+ raise Motr::Errors::InvalidOptions.new("Missing :for option when defining a Motr::Cargo context")
18
+ end
19
+ # Define relationships on each cargo object
20
+ #
21
+ packs.flatten.compact.each do |cargo|
22
+ send(:embedded_in, :"#{cargo.to_s}")
23
+ cargo.to_s.classify.constantize.class_eval do
24
+ send(:embeds_many, :"#{cname}")
25
+ end
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ module Motr
2
+ module Cargo::Package
3
+
4
+ module Mongoid
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ field :title, :type => String
9
+ field :post_date, :type => Time
10
+ field :published, :type => Boolean
11
+ field :uid, :type => Integer
12
+
13
+ before_save :generate_cargo_uid
14
+ end
15
+
16
+ def generate_cargo_uid
17
+ return true unless self.uid.nil?
18
+ self.uid = self.class.max(:uid).to_i + 1
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,54 @@
1
+ module Motr
2
+ module Mods
3
+ ##
4
+ # Cargo is the base mod for implementing content like behavior on a model. A model with "cargo" represents the core
5
+ # post/page/body object in which content is created/published. Cargo contains multiple "contexts" which define the fields/attributes
6
+ # that ultimately merge to create the final content to be delivered.
7
+ #
8
+ # A context defines a "field" that belongs within a cargo object. Each "package" can contain one or many contexts, which when combined,
9
+ # in the user-defined order, make up the full body of content to be delivered.
10
+ #
11
+ # For example, given a "Post" model, modded_with cargo, that post may have a "heading" context, and a "body" context.
12
+ # When combined into final, deliverable content, the result is a heading (h1, h2, h3 etc) and a body. Taking a blog as an example, this allows
13
+ # each piece of a post to be defined as individual contexts, giving developers full control over output and format... and relying less on the
14
+ # implementations of "wysiwyg" editors. (to be fair... it isn't the editor's fault).
15
+ #
16
+ # When using the provided controllers, this also allows each individual aspect of a page to be edited as a standalone item.
17
+ #
18
+ # Applying the cargo mod automatically creates the following fields
19
+ # title:String
20
+ # post_date:Time
21
+ # published:Boolean
22
+ # uid:Integer => Mongoid models only... this creates an auto-incrementing sql style id for each post
23
+ #
24
+ # Applying a context automatically defines the following fields
25
+ # name:String => The name of the context (ie "heading", "body"). This is optional and is really only for display
26
+ # body:String => The actual body (content) of the context (ie the heading title or html body copy)
27
+ # meta:Hash => Allows storage of various metadata
28
+ # type:String => STI functionality. When creating different context types for an object, inheritance should be used. (this really only applies to ActiveRecord... as Mongoid handles this automatically)
29
+ #
30
+ # Provide an :as option to define this model as a context. By default calling modded_with :cargo defines a "package" or "post" object.
31
+ # Using :as with :context defines the model as a context. Defining a context requires the :for option
32
+ #
33
+ # Pass a :for option when creating a context. The :for option is passed representing the model/models that this context is for.
34
+ # These models should be modded_with :cargo
35
+ #
36
+ module Cargo
37
+ extend Motr::Modding
38
+
39
+ options(:for, :as)
40
+
41
+ configure(:mongoid) do
42
+ mod_opts = cargo_mod_options
43
+ unless mod_opts.key?(:as) && mod_opts[:as].to_s.match(/context/i)
44
+ self.send(:include, Motr::Cargo::Package::Mongoid)
45
+ else
46
+ puts 'called context'
47
+ self.send(:include, Motr::Cargo::Context::Mongoid)
48
+ end
49
+ end
50
+
51
+ end # end module
52
+
53
+ end
54
+ end
data/lib/motr-cargo.rb ADDED
@@ -0,0 +1,19 @@
1
+ require 'motr'
2
+ require 'motr/modding'
3
+
4
+ module Motr
5
+ module Cargo
6
+ VERSION = '0.0.1'
7
+
8
+ module Package
9
+ autoload :Mongoid, 'motr/cargo/package/mongoid'
10
+ end
11
+
12
+ module Context
13
+ autoload :Mongoid, 'motr/cargo/context/mongoid'
14
+ end
15
+
16
+ end
17
+ end
18
+
19
+ Motr.add_mod(:cargo, :autoload => true)
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motr-cargo
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Brent Kirby
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-20 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: mocha
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - "="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.9.12
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - "="
33
+ - !ruby/object:Gem::Version
34
+ version: 0.4.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: fabrication
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.5
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: ffaker
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: "1.5"
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: mongoid
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: "2.0"
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: mongo
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: "1.3"
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: bson_ext
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: "1.3"
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: activemodel
95
+ requirement: &id008 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ~>
99
+ - !ruby/object:Gem::Version
100
+ version: "3.0"
101
+ type: :runtime
102
+ prerelease: false
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: rails
106
+ requirement: &id009 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ version: "3.0"
112
+ type: :runtime
113
+ prerelease: false
114
+ version_requirements: *id009
115
+ - !ruby/object:Gem::Dependency
116
+ name: nokogiri
117
+ requirement: &id010 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ~>
121
+ - !ruby/object:Gem::Version
122
+ version: "1.4"
123
+ type: :runtime
124
+ prerelease: false
125
+ version_requirements: *id010
126
+ - !ruby/object:Gem::Dependency
127
+ name: motr
128
+ requirement: &id011 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: 0.0.7
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: *id011
137
+ description: motr-cargo is a collection of Motr mods that add functionality for managing and delivering user managed/generated content
138
+ email:
139
+ - dev@kurbmedia.com
140
+ executables: []
141
+
142
+ extensions: []
143
+
144
+ extra_rdoc_files: []
145
+
146
+ files:
147
+ - lib/motr/cargo/context/mongoid.rb
148
+ - lib/motr/cargo/package/mongoid.rb
149
+ - lib/motr/mods/cargo.rb
150
+ - lib/motr-cargo.rb
151
+ - MIT-LICENSE
152
+ - Rakefile
153
+ - Gemfile
154
+ - README.rdoc
155
+ has_rdoc: true
156
+ homepage: http://github.com/kurbmedia/motr-cargo
157
+ licenses: []
158
+
159
+ post_install_message:
160
+ rdoc_options: []
161
+
162
+ require_paths:
163
+ - lib
164
+ required_ruby_version: !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ hash: -1531469132394986629
170
+ segments:
171
+ - 0
172
+ version: "0"
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
174
+ none: false
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ hash: -1531469132394986629
179
+ segments:
180
+ - 0
181
+ version: "0"
182
+ requirements: []
183
+
184
+ rubyforge_project: motr-cargo
185
+ rubygems_version: 1.6.2
186
+ signing_key:
187
+ specification_version: 3
188
+ summary: motr-cargo is a mod for the Motr engine that manages content delivery
189
+ test_files: []
190
+