locomotive_plugins 1.0.0.beta4 → 1.0.0.beta5
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/CHANGELOG +3 -1
- data/README.md +40 -15
- data/lib/locomotive/plugin.rb +36 -72
- data/lib/locomotive/plugin/class_tracker.rb +54 -0
- data/lib/locomotive/plugin/config_ui.rb +11 -4
- data/lib/locomotive/plugin/liquid.rb +94 -35
- data/lib/locomotive/plugin/liquid/context_helpers.rb +47 -0
- data/lib/locomotive/plugin/liquid/drop_extension.rb +36 -0
- data/lib/locomotive/plugin/liquid/prefixed_filter_module.rb +22 -15
- data/lib/locomotive/plugin/liquid/tag_subclass_methods.rb +16 -14
- data/lib/locomotive_plugins.rb +0 -36
- data/lib/version.rb +1 -1
- data/spec/lib/locomotive/plugin/class_tracker_spec.rb +48 -0
- data/spec/lib/locomotive/plugin/liquid/context_helpers_spec.rb +75 -0
- data/spec/lib/locomotive/plugin/liquid_spec.rb +70 -77
- data/spec/lib/locomotive/plugin_spec.rb +8 -10
- data/spec/support/plugins/my_plugin.rb +18 -3
- metadata +7 -9
- data/lib/locomotive/plugin/db_model.rb +0 -10
- data/lib/locomotive/plugin/db_model_container.rb +0 -18
- data/lib/locomotive/plugin/db_models.rb +0 -111
- data/spec/lib/locomotive/plugin/db_models_spec.rb +0 -206
- data/spec/lib/locomotive_plugins_spec.rb +0 -29
- data/spec/support/plugins/plugin_with_db_model.rb +0 -19
- data/spec/support/plugins/plugin_with_db_model_relationships.rb +0 -22
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe LocomotivePlugins do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
LocomotivePlugins.clear_registered_plugins
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should register plugins under a given id' do
|
11
|
-
LocomotivePlugins.register_plugin(Locomotive::MyPlugin, 'my_amazing_plugin')
|
12
|
-
registered = LocomotivePlugins.registered_plugins
|
13
|
-
registered.count.should == 1
|
14
|
-
registered['my_amazing_plugin'].should == Locomotive::MyPlugin
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should register plugins under the default id' do
|
18
|
-
default_id = LocomotivePlugins.default_id(Locomotive::MyPlugin)
|
19
|
-
LocomotivePlugins.register_plugin(Locomotive::MyPlugin)
|
20
|
-
registered = LocomotivePlugins.registered_plugins
|
21
|
-
registered.count.should == 1
|
22
|
-
registered[default_id].should == Locomotive::MyPlugin
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should use the underscorized class name without any modules as the default id' do
|
26
|
-
LocomotivePlugins.default_id(Locomotive::MyPlugin).should == 'my_plugin'
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
|
2
|
-
module Locomotive
|
3
|
-
class PluginWithDBModel
|
4
|
-
include Locomotive::Plugin
|
5
|
-
|
6
|
-
class VisitCount < Locomotive::Plugin::DBModel
|
7
|
-
field :count, default: 0
|
8
|
-
end
|
9
|
-
|
10
|
-
class Item < Locomotive::Plugin::DBModel
|
11
|
-
field :name
|
12
|
-
validates_presence_of :name
|
13
|
-
end
|
14
|
-
|
15
|
-
has_one :visit_count, VisitCount
|
16
|
-
has_many :items, Item
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
|
2
|
-
module Locomotive
|
3
|
-
class PluginWithDBModelRelationships
|
4
|
-
include Locomotive::Plugin
|
5
|
-
|
6
|
-
class Teacher < Locomotive::Plugin::DBModel
|
7
|
-
field :name
|
8
|
-
has_many :students,
|
9
|
-
class_name: 'Locomotive::PluginWithDBModelRelationships::Student'
|
10
|
-
end
|
11
|
-
|
12
|
-
class Student < Locomotive::Plugin::DBModel
|
13
|
-
field :name
|
14
|
-
belongs_to :teacher,
|
15
|
-
class_name: 'Locomotive::PluginWithDBModelRelationships::Teacher'
|
16
|
-
end
|
17
|
-
|
18
|
-
has_many :teachers, Teacher
|
19
|
-
has_many :students, Student
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|