bit_player 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/bit_player/navigator.rb +6 -4
  3. data/db/migrate/20140620182756_convert_slides_slideshows_to_bit_core.rb +33 -0
  4. data/db/migrate/20140620222851_convert_tools_modules_presenters_to_bit_core.rb +46 -0
  5. data/lib/bit_player/version.rb +1 -1
  6. data/lib/bit_player.rb +3 -0
  7. data/spec/dummy/db/migrate/20140620222614_create_bit_core_tools.bit_core.rb +29 -0
  8. data/spec/dummy/db/migrate/20140620222615_create_bit_core_content_modules.bit_core.rb +41 -0
  9. data/spec/dummy/db/migrate/20140620222616_create_bit_core_content_providers.bit_core.rb +43 -0
  10. data/spec/dummy/db/migrate/20140620222617_create_bit_core_slideshows.bit_core.rb +10 -0
  11. data/spec/dummy/db/migrate/20140620222618_create_bit_core_slides.bit_core.rb +44 -0
  12. data/spec/dummy/db/migrate/20140620222619_add_options_to_slides.bit_core.rb +6 -0
  13. data/spec/dummy/db/migrate/20140620222620_add_config_fields_to_providers.bit_core.rb +10 -0
  14. data/spec/dummy/db/schema.rb +35 -36
  15. data/spec/dummy/log/development.log +279 -0
  16. data/spec/dummy/log/test.log +2231 -1644
  17. data/spec/fixtures/bit_player/content_providers.yml +0 -2
  18. data/spec/models/bit_player/navigator_spec.rb +2 -1
  19. metadata +32 -22
  20. data/app/models/bit_player/content_module.rb +0 -36
  21. data/app/models/bit_player/content_provider.rb +0 -63
  22. data/app/models/bit_player/content_providers/null.rb +0 -26
  23. data/app/models/bit_player/content_providers/slideshow_provider.rb +0 -32
  24. data/app/models/bit_player/slide.rb +0 -48
  25. data/app/models/bit_player/slideshow.rb +0 -19
  26. data/app/models/bit_player/tool.rb +0 -23
  27. data/app/models/bit_player/video_slide.rb +0 -6
  28. data/db/migrate/20140402225703_change_module_context_to_tool.rb +0 -30
  29. data/db/migrate/20140619200219_add_config_fields_to_providers.rb +0 -9
  30. data/spec/fixtures/bit_player/slides.yml +0 -17
  31. data/spec/fixtures/bit_player/slideshows.yml +0 -2
  32. data/spec/models/bit_player/content_module_spec.rb +0 -20
  33. data/spec/models/bit_player/content_provider_spec.rb +0 -46
  34. data/spec/models/bit_player/slide_spec.rb +0 -38
@@ -2,10 +2,8 @@ home_landing_slideshow:
2
2
  content_module: home_landing
3
3
  position: 1
4
4
  type: BitPlayer::ContentProviders::SlideshowProvider
5
- #source_content: home_intro (BitPlayer::Slideshow)
6
5
 
7
6
  home_module_2_slideshow:
8
7
  content_module: home_module_2
9
8
  position: 1
10
9
  type: BitPlayer::ContentProviders::SlideshowProvider
11
- #source_content: home_intro (BitPlayer::Slideshow)
@@ -1,4 +1,5 @@
1
1
  require "spec_helper"
2
+ require "bit_core"
2
3
 
3
4
  describe BitPlayer::Navigator do
4
5
  let(:status) do
@@ -16,7 +17,7 @@ describe BitPlayer::Navigator do
16
17
  let(:nav) { BitPlayer::Navigator.new(participant) }
17
18
 
18
19
  before do
19
- expect(BitPlayer::Tool).to receive(:find_by_title)
20
+ expect(BitCore::Tool).to receive(:find_by_title)
20
21
  .and_return(double("tool", id: 1))
21
22
  end
22
23
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bit_player
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Carty-Fickes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-19 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bit_core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: pg
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -93,18 +107,10 @@ files:
93
107
  - app/assets/javascripts/bit_player/application.js
94
108
  - app/assets/stylesheets/bit_player/application.css
95
109
  - app/controllers/bit_player/application_controller.rb
96
- - app/models/bit_player/content_module.rb
97
- - app/models/bit_player/content_provider.rb
98
110
  - app/models/bit_player/content_providers/form_view_provider.rb
99
- - app/models/bit_player/content_providers/null.rb
100
- - app/models/bit_player/content_providers/slideshow_provider.rb
101
111
  - app/models/bit_player/content_providers/view_provider.rb
102
112
  - app/models/bit_player/navigator.rb
103
113
  - app/models/bit_player/participant_status.rb
104
- - app/models/bit_player/slide.rb
105
- - app/models/bit_player/slideshow.rb
106
- - app/models/bit_player/tool.rb
107
- - app/models/bit_player/video_slide.rb
108
114
  - app/views/layouts/bit_player/application.html.erb
109
115
  - config/routes.rb
110
116
  - db/migrate/20140305200438_create_bit_player_content_modules.rb
@@ -113,8 +119,8 @@ files:
113
119
  - db/migrate/20140305232706_create_bit_player_slideshows.rb
114
120
  - db/migrate/20140305234327_create_bit_player_slides.rb
115
121
  - db/migrate/20140402224913_create_bit_player_tools.rb
116
- - db/migrate/20140402225703_change_module_context_to_tool.rb
117
- - db/migrate/20140619200219_add_config_fields_to_providers.rb
122
+ - db/migrate/20140620182756_convert_slides_slideshows_to_bit_core.rb
123
+ - db/migrate/20140620222851_convert_tools_modules_presenters_to_bit_core.rb
118
124
  - lib/bit_player.rb
119
125
  - lib/bit_player/engine.rb
120
126
  - lib/bit_player/version.rb
@@ -145,6 +151,13 @@ files:
145
151
  - spec/dummy/config/initializers/wrap_parameters.rb
146
152
  - spec/dummy/config/locales/en.yml
147
153
  - spec/dummy/config/routes.rb
154
+ - spec/dummy/db/migrate/20140620222614_create_bit_core_tools.bit_core.rb
155
+ - spec/dummy/db/migrate/20140620222615_create_bit_core_content_modules.bit_core.rb
156
+ - spec/dummy/db/migrate/20140620222616_create_bit_core_content_providers.bit_core.rb
157
+ - spec/dummy/db/migrate/20140620222617_create_bit_core_slideshows.bit_core.rb
158
+ - spec/dummy/db/migrate/20140620222618_create_bit_core_slides.bit_core.rb
159
+ - spec/dummy/db/migrate/20140620222619_add_options_to_slides.bit_core.rb
160
+ - spec/dummy/db/migrate/20140620222620_add_config_fields_to_providers.bit_core.rb
148
161
  - spec/dummy/db/schema.rb
149
162
  - spec/dummy/log/development.log
150
163
  - spec/dummy/log/test.log
@@ -154,14 +167,9 @@ files:
154
167
  - spec/dummy/public/favicon.ico
155
168
  - spec/fixtures/bit_player/content_modules.yml
156
169
  - spec/fixtures/bit_player/content_providers.yml
157
- - spec/fixtures/bit_player/slides.yml
158
- - spec/fixtures/bit_player/slideshows.yml
159
170
  - spec/fixtures/bit_player/tools.yml
160
- - spec/models/bit_player/content_module_spec.rb
161
- - spec/models/bit_player/content_provider_spec.rb
162
171
  - spec/models/bit_player/content_providers/view_provider_spec.rb
163
172
  - spec/models/bit_player/navigator_spec.rb
164
- - spec/models/bit_player/slide_spec.rb
165
173
  - spec/spec_helper.rb
166
174
  homepage: https://github.com/nupmmarkbegale/bit_player
167
175
  licenses: []
@@ -212,6 +220,13 @@ test_files:
212
220
  - spec/dummy/config/locales/en.yml
213
221
  - spec/dummy/config/routes.rb
214
222
  - spec/dummy/config.ru
223
+ - spec/dummy/db/migrate/20140620222614_create_bit_core_tools.bit_core.rb
224
+ - spec/dummy/db/migrate/20140620222615_create_bit_core_content_modules.bit_core.rb
225
+ - spec/dummy/db/migrate/20140620222616_create_bit_core_content_providers.bit_core.rb
226
+ - spec/dummy/db/migrate/20140620222617_create_bit_core_slideshows.bit_core.rb
227
+ - spec/dummy/db/migrate/20140620222618_create_bit_core_slides.bit_core.rb
228
+ - spec/dummy/db/migrate/20140620222619_add_options_to_slides.bit_core.rb
229
+ - spec/dummy/db/migrate/20140620222620_add_config_fields_to_providers.bit_core.rb
215
230
  - spec/dummy/db/schema.rb
216
231
  - spec/dummy/log/development.log
217
232
  - spec/dummy/log/test.log
@@ -223,12 +238,7 @@ test_files:
223
238
  - spec/dummy/README.rdoc
224
239
  - spec/fixtures/bit_player/content_modules.yml
225
240
  - spec/fixtures/bit_player/content_providers.yml
226
- - spec/fixtures/bit_player/slides.yml
227
- - spec/fixtures/bit_player/slideshows.yml
228
241
  - spec/fixtures/bit_player/tools.yml
229
- - spec/models/bit_player/content_module_spec.rb
230
- - spec/models/bit_player/content_provider_spec.rb
231
242
  - spec/models/bit_player/content_providers/view_provider_spec.rb
232
243
  - spec/models/bit_player/navigator_spec.rb
233
- - spec/models/bit_player/slide_spec.rb
234
244
  - spec/spec_helper.rb
@@ -1,36 +0,0 @@
1
- module BitPlayer
2
- # A logical unit of content, possibly containing mixed provider types.
3
- class ContentModule < ActiveRecord::Base
4
- belongs_to :tool,
5
- class_name: "BitPlayer::Tool",
6
- foreign_key: :bit_player_tool_id
7
- has_many :content_providers,
8
- class_name: "BitPlayer::ContentProvider",
9
- foreign_key: :bit_player_content_module_id,
10
- inverse_of: :content_module,
11
- dependent: :destroy
12
-
13
- validates :title, :tool, :position, presence: true
14
- validates :position, numericality: { greater_than_or_equal_to: 1 }
15
- validates :position, uniqueness: { scope: :bit_player_tool_id }
16
-
17
- def provider(position)
18
- content_providers.where(position: position).first ||
19
- ContentProviders::Null.new(self, position)
20
- end
21
-
22
- def provider_exists?(position)
23
- content_providers.exists?(position: position)
24
- end
25
-
26
- def add_content_provider(type)
27
- content_providers.create(type: type, position: last_position + 1)
28
- end
29
-
30
- private
31
-
32
- def last_position
33
- content_providers.order(:position).last.try(:position) || 0
34
- end
35
- end
36
- end
@@ -1,63 +0,0 @@
1
- module BitPlayer
2
- # Modeled after the presenter pattern. Ties data layer to view layer.
3
- class ContentProvider < ActiveRecord::Base
4
- include BitPlayer::ContentProviders::ViewProvider
5
-
6
- belongs_to :content_module,
7
- class_name: "BitPlayer::ContentModule",
8
- foreign_key: :bit_player_content_module_id,
9
- inverse_of: :content_providers
10
- belongs_to :source_content, polymorphic: true
11
-
12
- validates :content_module, :position, presence: true
13
- validates :position, numericality: { greater_than_or_equal_to: 1 }
14
- validates :show_next_nav, inclusion: { in: [true, false] }
15
- validate :template_path_exists
16
- validate :data_class_exists
17
- validate :data_attributes_exist
18
-
19
- serialize :data_attributes
20
- serialize :locals
21
-
22
- delegate :context, to: :content_module, prefix: false
23
-
24
- def exists?(position)
25
- false
26
- end
27
-
28
- def data_class
29
- data_class_name.constantize
30
- rescue NameError
31
- nil
32
- end
33
-
34
- # compatibility method
35
- def show_nav_link?
36
- show_next_nav
37
- end
38
-
39
- private
40
-
41
- def template_path_exists
42
- path = File.join(Rails.root, "app", "views", template_path || "")
43
- return if Dir.exists?(path)
44
- errors.add(:template_path, "not found at #{ path }")
45
- end
46
-
47
- def data_class_exists
48
- unless data_class
49
- errors.add(:data_class_name,
50
- "unable to find class '#{ data_class_name }'")
51
- end
52
- end
53
-
54
- def data_attributes_exist
55
- if data_attributes
56
- attribute_names = data_class.try(:attribute_names) || []
57
- unless data_attributes.all? { |a| attribute_names.include?(a.to_str) }
58
- errors.add(:data_attributes, "must be attributes on the model class")
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,26 +0,0 @@
1
- module BitPlayer
2
- module ContentProviders
3
- # The default provider.
4
- class Null
5
- attr_reader :position
6
-
7
- def initialize(content_module, position)
8
- @content_module = content_module
9
- @position = position
10
- end
11
-
12
- def render_current(options)
13
- "Content Module #{ @content_module.title }: Oops, did you expect a
14
- content provider here?"
15
- end
16
-
17
- def show_nav_link?
18
- false
19
- end
20
-
21
- def exists?(position)
22
- false
23
- end
24
- end
25
- end
26
- end
@@ -1,32 +0,0 @@
1
- module BitPlayer
2
- module ContentProviders
3
- # Defines presentation logic for a Slideshow.
4
- class SlideshowProvider < ContentProvider
5
- def slideshow
6
- source_content
7
- end
8
-
9
- def render_current(options)
10
- options.view_context.render(
11
- template: "slides/show",
12
- locals: {
13
- slide: slide(options.position)
14
- }
15
- )
16
- end
17
-
18
- def slide(position)
19
- slideshow.slides.where(position: position).first ||
20
- Slide.new(body: "no slides")
21
- end
22
-
23
- def exists?(position)
24
- slideshow.slides.exists?(position: position)
25
- end
26
-
27
- def show_nav_link?
28
- true
29
- end
30
- end
31
- end
32
- end
@@ -1,48 +0,0 @@
1
- require "redcarpet"
2
-
3
- module BitPlayer
4
- # A page of "static" or presentational content (as opposed to data capture).
5
- class Slide < ActiveRecord::Base
6
- belongs_to :slideshow,
7
- class_name: "BitPlayer::Slideshow",
8
- foreign_key: :bit_player_slideshow_id,
9
- inverse_of: :slides
10
-
11
- validates :title, :body, :position, presence: true
12
- validates :position, numericality: { greater_than_or_equal_to: 1 }
13
- validates :position, uniqueness: { scope: :bit_player_slideshow_id }
14
-
15
- before_destroy :push_to_be_deleted_slide_to_end
16
-
17
- def self.update_positions(ids)
18
- transaction do
19
- connection.execute "SET CONSTRAINTS bit_player_slide_position DEFERRED"
20
- ids.each_with_index do |id, index|
21
- where(id: id).update_all(position: index + 1)
22
- end
23
- end
24
- end
25
-
26
- def render_body
27
- return "" if body.nil?
28
-
29
- Redcarpet::Markdown.new(
30
- Redcarpet::Render::HTML.new(
31
- filter_html: true,
32
- safe_links_only: true
33
- ),
34
- space_after_headers: true
35
- ).render(body).html_safe
36
- end
37
-
38
- protected
39
-
40
- def push_to_be_deleted_slide_to_end
41
- slide_ids = slideshow.slide_ids
42
- slide_ids.delete(id)
43
- slide_ids.push(id)
44
- slideshow.slides.update_positions(slide_ids)
45
- end
46
-
47
- end
48
- end
@@ -1,19 +0,0 @@
1
- module BitPlayer
2
- # A collection of ordered Slides.
3
- class Slideshow < ActiveRecord::Base
4
- has_many :slides,
5
- -> { order "position" },
6
- class_name: "BitPlayer::Slide",
7
- foreign_key: :bit_player_slideshow_id,
8
- dependent: :destroy,
9
- inverse_of: :slideshow
10
- has_one :content_provider,
11
- as: :source_content,
12
- inverse_of: :source_content,
13
- dependent: :nullify
14
-
15
- validates :title, presence: true
16
-
17
- accepts_nested_attributes_for :slides
18
- end
19
- end
@@ -1,23 +0,0 @@
1
- module BitPlayer
2
- # A section of an application.
3
- class Tool < ActiveRecord::Base
4
- has_many :content_modules,
5
- class_name: "BitPlayer::ContentModule",
6
- foreign_key: :bit_player_tool_id,
7
- inverse_of: :tool,
8
- dependent: :destroy
9
- validates :title, presence: true
10
- validates :position, uniqueness: true
11
- validates :is_home, inclusion: { in: [true, false] }
12
-
13
- def add_module(title)
14
- content_modules.create(title: title, position: last_position + 1)
15
- end
16
-
17
- private
18
-
19
- def last_position
20
- content_modules.order(:position).last.try(:position) || 0
21
- end
22
- end
23
- end
@@ -1,6 +0,0 @@
1
- module BitPlayer
2
- # A Slide with video content.
3
- class VideoSlide < Slide
4
- serialize :options
5
- end
6
- end
@@ -1,30 +0,0 @@
1
- class ChangeModuleContextToTool < ActiveRecord::Migration
2
- def up
3
- add_column :bit_player_content_modules, :bit_player_tool_id, :integer
4
- BitPlayer::ContentModule.reset_column_information
5
- BitPlayer::ContentModule.all.each do |content_module|
6
- tool = BitPlayer::Tool.find_or_create_by_title(content_module.context)
7
- content_module.update!(bit_player_tool_id: tool.id)
8
- end
9
- change_column_null :bit_player_content_modules, :bit_player_tool_id, false
10
- remove_column :bit_player_content_modules, :context
11
- execute <<-SQL
12
- ALTER TABLE bit_player_content_modules
13
- ADD CONSTRAINT fk_content_modules_tools
14
- FOREIGN KEY (bit_player_tool_id)
15
- REFERENCES bit_player_tools(id)
16
- SQL
17
- end
18
-
19
- def down
20
- execute <<-SQL
21
- ALTER TABLE bit_player_content_modules
22
- DROP CONSTRAINT fk_content_modules_tools
23
- SQL
24
- add_column :bit_player_content_modules, :context, :string, null: false
25
- BitPlayer::ContentModule.all.each do |content_module|
26
- content_module.update(context: content_module.tool.title)
27
- end
28
- remove_column :bit_player_content_modules, :bit_player_tool_id
29
- end
30
- end
@@ -1,9 +0,0 @@
1
- class AddConfigFieldsToProviders < ActiveRecord::Migration
2
- def change
3
- add_column :bit_player_content_providers, :template_path, :string
4
- add_column :bit_player_content_providers, :data_class_name, :string
5
- add_column :bit_player_content_providers, :data_attributes, :text
6
- add_column :bit_player_content_providers, :show_next_nav, :boolean
7
- add_column :bit_player_content_providers, :locals, :text
8
- end
9
- end
@@ -1,17 +0,0 @@
1
- slide1:
2
- slideshow: slideshow1
3
- position: 1
4
- title: Slide 1
5
- body: lorem...
6
-
7
- slide2:
8
- slideshow: slideshow1
9
- position: 2
10
- title: Slide 2
11
- body: lorem...
12
-
13
- slide3:
14
- slideshow: slideshow1
15
- position: 3
16
- title: Slide 3
17
- body: lorem...
@@ -1,2 +0,0 @@
1
- slideshow1:
2
- title: Slideshow 1
@@ -1,20 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe BitPlayer::ContentModule do
4
- fixtures :"bit_player/tools", :"bit_player/content_modules",
5
- :"bit_player/content_providers"
6
-
7
- describe "#provider" do
8
- it "should return the Null Provider when one is not found" do
9
- provider = bit_player_content_modules(:home_landing).provider(8)
10
- expect(provider.position).to eq(8)
11
- expect(provider.class).to eq(BitPlayer::ContentProviders::Null)
12
- end
13
-
14
- it "should return the associated provider at the position" do
15
- provider = bit_player_content_modules(:home_landing).provider(1)
16
- expect(provider.position).to eq(1)
17
- expect(provider.class).not_to eq(BitPlayer::ContentProviders::Null)
18
- end
19
- end
20
- end
@@ -1,46 +0,0 @@
1
- require "spec_helper"
2
-
3
- module BitPlayer
4
- describe ContentProvider do
5
- describe "validations" do
6
- it "should validate the existence of the template path" do
7
- p = ContentProvider.new(template_path: "foobaz")
8
- p.valid?
9
-
10
- expect(p.errors[:template_path].length).to eq 1
11
-
12
- p.template_path = "layouts"
13
- p.valid?
14
-
15
- expect(p.errors[:template_path].length).to eq 0
16
- end
17
-
18
- it "should validate the existence of the data class" do
19
- p = ContentProvider.new(data_class_name: "foobaz")
20
- p.valid?
21
-
22
- expect(p.errors[:data_class_name].length).to eq 1
23
-
24
- p.data_class_name = "BitPlayer::ContentProvider"
25
- p.valid?
26
-
27
- expect(p.errors[:data_class_name].length).to eq 0
28
- end
29
-
30
- it "should validate the existence of the data attributes" do
31
- p = ContentProvider.new(
32
- data_class_name: "BitPlayer::ContentProvider",
33
- data_attributes: ["baz"]
34
- )
35
- p.valid?
36
-
37
- expect(p.errors[:data_attributes].length).to eq 1
38
-
39
- p.data_attributes = ["id", "data_attributes"]
40
- p.valid?
41
-
42
- expect(p.errors[:data_attributes].length).to eq 0
43
- end
44
- end
45
- end
46
- end
@@ -1,38 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe BitPlayer::Slide do
4
- fixtures :"bit_player/slideshows", :"bit_player/slides"
5
-
6
- describe ".update_positions" do
7
- it "should update slide positions to match the order of the ids" do
8
- slide1 = bit_player_slides(:slide1)
9
- slide2 = bit_player_slides(:slide2)
10
- slide3 = bit_player_slides(:slide3)
11
- BitPlayer::Slide.update_positions([slide3.id, slide1.id, slide2.id])
12
-
13
- expect(BitPlayer::Slide.find(slide1.id).position).to eq(2)
14
- expect(BitPlayer::Slide.find(slide2.id).position).to eq(3)
15
- expect(BitPlayer::Slide.find(slide3.id).position).to eq(1)
16
- end
17
- end
18
-
19
- describe "#render_body" do
20
- let(:slide) { BitPlayer::Slide.new }
21
-
22
- it "should render a nil body" do
23
- expect(slide.render_body).to eq("")
24
- end
25
-
26
- it "should render markdown as html" do
27
- slide.body = "# header"
28
-
29
- expect(slide.render_body).to match(/<h1>header<\/h1>/)
30
- end
31
-
32
- it "should escape html" do
33
- slide.body = "<div>my content</div>"
34
-
35
- expect(slide.render_body).to match(/<p>my content<\/p>/)
36
- end
37
- end
38
- end