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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65eefe9683e95026fb2ef0a51fc5a05bb84aacc9
4
- data.tar.gz: bc7364b7a6a06109c40772ddf0459ae1fb63f8f7
3
+ metadata.gz: e3384be7f326b7aafce86e1e0e79caf1e813a557
4
+ data.tar.gz: ede39b3c8e27736a01e50a266112ad6b526632be
5
5
  SHA512:
6
- metadata.gz: 80a5f5a423ff5e5bb337c1f34119dde3e9a85f3af7c39739d400e9c5242b8e7285cc75dfb9f0459ef6ae420507c04260ff825291edb2a6cfa58674f361439d24
7
- data.tar.gz: 30fe39730b2ee0d4f0593aa2c15cea498f3d51e606d716ca6f1205ad9c6386f3c978cce6ab7e5c07c1df8a863375c81e018139b42a06c24a1af35d4687e6b7d2
6
+ metadata.gz: 3e16bb6ada7edfd397593d3447bbb1d5933ce7a0d5fd9256fd8fc0ebd33243820c3246671ebc57af193cafa5de8b1d727e8afa430d318ccde1b4790d039ddd1f
7
+ data.tar.gz: 5051ab184deb2e9d5dec797e4fcd0d699d9115f69ff11e01ddcbfca2247513a5328741b0e66f32acff2a74332f92e1755fbe21529b4a3a499b1ef45ad58774c1
@@ -1,3 +1,5 @@
1
+ require "bit_core"
2
+
1
3
  module BitPlayer
2
4
  # Business rules for proceeding statefully through an application.
3
5
  class Navigator
@@ -57,7 +59,7 @@ module BitPlayer
57
59
  end
58
60
 
59
61
  def initialize_location(options)
60
- content_module = ContentModule.find(options[:module_id])
62
+ content_module = BitCore::ContentModule.find(options[:module_id])
61
63
  @status.context = content_module.tool.title
62
64
  @status.module_position = content_module.position
63
65
  @status.provider_position = 1
@@ -73,15 +75,15 @@ module BitPlayer
73
75
  @current_module ||= nil
74
76
 
75
77
  module_attrs = {
76
- bit_player_tool_id: Tool.find_by_title(context).try(:id),
78
+ bit_core_tool_id: BitCore::Tool.find_by_title(context).try(:id),
77
79
  position: module_position
78
80
  }
79
81
 
80
82
  if current_module_stale?
81
- @current_module = ContentModule.where(module_attrs).first
83
+ @current_module = BitCore::ContentModule.where(module_attrs).first
82
84
  end
83
85
 
84
- @current_module ||= ContentModule.new(module_attrs)
86
+ @current_module ||= BitCore::ContentModule.new(module_attrs)
85
87
  end
86
88
 
87
89
  private
@@ -0,0 +1,33 @@
1
+ class BitPlayer::Slideshow < ActiveRecord::Base; end
2
+ class BitPlayer::Slide < ActiveRecord::Base; end
3
+
4
+ class ConvertSlidesSlideshowsToBitCore < ActiveRecord::Migration
5
+ def up
6
+ BitPlayer::Slideshow.all.each do |slideshow|
7
+ BitCore::Slideshow.create!(title: slideshow.title, id: slideshow.id)
8
+ end
9
+ BitPlayer::Slide.all.each do |slide|
10
+ BitCore::Slide.create!(
11
+ title: slide.title,
12
+ id: slide.id,
13
+ body: slide.body,
14
+ position: slide.position,
15
+ bit_core_slideshow_id: bit_player_slideshow_id,
16
+ type: slide.type,
17
+ options: slide.options,
18
+ is_title_visible: slide.is_title_visible
19
+ )
20
+ end
21
+ execute <<-SQL
22
+ ALTER TABLE bit_player_slides
23
+ DROP CONSTRAINT fk_slides_slideshows
24
+ SQL
25
+
26
+ execute <<-SQL
27
+ ALTER TABLE bit_player_slides
28
+ DROP CONSTRAINT IF EXISTS bit_player_slide_position
29
+ SQL
30
+ drop_table :bit_player_slides
31
+ drop_table :bit_player_slideshows
32
+ end
33
+ end
@@ -0,0 +1,46 @@
1
+ class BitPlayer::Tool < ActiveRecord::Base; end
2
+ class BitPlayer::ContentModule < ActiveRecord::Base; end
3
+ class BitPlayer::ContentProvider < ActiveRecord::Base; end
4
+
5
+ class ConvertToolsModulesPresentersToBitCore < ActiveRecord::Migration
6
+ def up
7
+ BitPlayer::Tool.all.each do |tool|
8
+ BitCore::Tool.create!(
9
+ title: tool.title,
10
+ position: tool.position,
11
+ is_home: tool.is_home
12
+ )
13
+ end
14
+ BitPlayer::ContentModule.all.each do |mod|
15
+ BitCore::ContentModule.create!(
16
+ title: mod.title,
17
+ bit_core_tool_id: mod.bit_player_tool_id,
18
+ position: mod.position
19
+ )
20
+ end
21
+ BitPlayer::ContentProvider.all.each do |pro|
22
+ type = pro.type
23
+ if type == "BitPlayer::ContentProviders::SlideshowProvider"
24
+ type = "BitCore::ContentProviders::SlideshowProvider"
25
+ end
26
+ BitCore::ContentProvider.create!(
27
+ type: type,
28
+ source_content_type: pro.source_content_type,
29
+ source_content_id: pro.source_content_id,
30
+ bit_core_content_module_id: pro.bit_player_content_module_id,
31
+ position: pro.position
32
+ )
33
+ end
34
+ execute <<-SQL
35
+ ALTER TABLE bit_player_content_modules
36
+ DROP CONSTRAINT IF EXISTS fk_content_modules_tools
37
+ SQL
38
+ execute <<-SQL
39
+ ALTER TABLE bit_player_content_providers
40
+ DROP CONSTRAINT IF EXISTS fk_content_providers_modules
41
+ SQL
42
+ drop_table :bit_player_tools
43
+ drop_table :bit_player_content_modules
44
+ drop_table :bit_player_content_providers
45
+ end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module BitPlayer
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/bit_player.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  require "bit_player/engine"
2
+ # Required to load the BitCore namespace.
3
+ require "bit_core"
2
4
 
5
+ # nodoc
3
6
  module BitPlayer
4
7
  end
@@ -0,0 +1,29 @@
1
+ # This migration comes from bit_core (originally 20140415210052)
2
+ class CreateBitCoreTools < ActiveRecord::Migration
3
+ def change
4
+ create_table :bit_core_tools do |t|
5
+ t.string :title, null: false, unique: true
6
+ t.integer :position, null: false, default: 0
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ reversible do |dir|
12
+ dir.up do
13
+ # make deferrable so that positions can be updated
14
+ execute <<-SQL
15
+ ALTER TABLE bit_core_tools
16
+ ADD CONSTRAINT bit_core_tool_position UNIQUE (position)
17
+ DEFERRABLE INITIALLY IMMEDIATE
18
+ SQL
19
+ end
20
+
21
+ dir.down do
22
+ execute <<-SQL
23
+ ALTER TABLE bit_core_tools
24
+ DROP CONSTRAINT IF EXISTS bit_core_tool_position
25
+ SQL
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,41 @@
1
+ # This migration comes from bit_core (originally 20140415211458)
2
+ class CreateBitCoreContentModules < ActiveRecord::Migration
3
+ def change
4
+ create_table :bit_core_content_modules do |t|
5
+ t.string :title, null: false
6
+ t.integer :position, null: false, default: 1
7
+ t.integer :bit_core_tool_id, null: false
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ reversible do |dir|
13
+ dir.up do
14
+ execute <<-SQL
15
+ ALTER TABLE bit_core_content_modules
16
+ ADD CONSTRAINT bit_core_content_module_position UNIQUE (bit_core_tool_id, position)
17
+ DEFERRABLE INITIALLY IMMEDIATE
18
+ SQL
19
+
20
+ execute <<-SQL
21
+ ALTER TABLE bit_core_content_modules
22
+ ADD CONSTRAINT fk_content_modules_tools
23
+ FOREIGN KEY (bit_core_tool_id)
24
+ REFERENCES bit_core_tools(id)
25
+ SQL
26
+ end
27
+
28
+ dir.down do
29
+ execute <<-SQL
30
+ ALTER TABLE bit_core_content_modules
31
+ DROP CONSTRAINT fk_content_modules_tools
32
+ SQL
33
+
34
+ execute <<-SQL
35
+ ALTER TABLE bit_core_content_modules
36
+ DROP CONSTRAINT IF EXISTS bit_core_content_module_position
37
+ SQL
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,43 @@
1
+ # This migration comes from bit_core (originally 20140415213346)
2
+ class CreateBitCoreContentProviders < ActiveRecord::Migration
3
+ def change
4
+ create_table :bit_core_content_providers do |t|
5
+ t.string :type, null: false
6
+ t.string :source_content_type
7
+ t.integer :source_content_id
8
+ t.integer :bit_core_content_module_id, null: false
9
+ t.integer :position, null: false, default: 1
10
+
11
+ t.timestamps
12
+ end
13
+
14
+ reversible do |dir|
15
+ dir.up do
16
+ execute <<-SQL
17
+ ALTER TABLE bit_core_content_providers
18
+ ADD CONSTRAINT bit_core_content_provider_position UNIQUE (bit_core_content_module_id, position)
19
+ DEFERRABLE INITIALLY IMMEDIATE
20
+ SQL
21
+
22
+ execute <<-SQL
23
+ ALTER TABLE bit_core_content_providers
24
+ ADD CONSTRAINT fk_content_providers_modules
25
+ FOREIGN KEY (bit_core_content_module_id)
26
+ REFERENCES bit_core_content_modules(id)
27
+ SQL
28
+ end
29
+
30
+ dir.down do
31
+ execute <<-SQL
32
+ ALTER TABLE bit_core_content_providers
33
+ DROP CONSTRAINT fk_content_providers_modules
34
+ SQL
35
+
36
+ execute <<-SQL
37
+ ALTER TABLE bit_core_content_providers
38
+ DROP CONSTRAINT IF EXISTS bit_core_content_provider_position
39
+ SQL
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,10 @@
1
+ # This migration comes from bit_core (originally 20140417173056)
2
+ class CreateBitCoreSlideshows < ActiveRecord::Migration
3
+ def change
4
+ create_table :bit_core_slideshows do |t|
5
+ t.string :title, null: false
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,44 @@
1
+ # This migration comes from bit_core (originally 20140417174159)
2
+ class CreateBitCoreSlides < ActiveRecord::Migration
3
+ def change
4
+ create_table :bit_core_slides do |t|
5
+ t.string :title, null: false
6
+ t.text :body, null: false
7
+ t.integer :position, null: false, default: 1
8
+ t.integer :bit_core_slideshow_id, null: false
9
+ t.string :type
10
+ t.boolean :is_title_visible, null: false, default: true
11
+
12
+ t.timestamps
13
+ end
14
+
15
+ reversible do |dir|
16
+ dir.up do
17
+ execute <<-SQL
18
+ ALTER TABLE bit_core_slides
19
+ ADD CONSTRAINT bit_core_slide_position UNIQUE (bit_core_slideshow_id, position)
20
+ DEFERRABLE INITIALLY IMMEDIATE
21
+ SQL
22
+
23
+ execute <<-SQL
24
+ ALTER TABLE bit_core_slides
25
+ ADD CONSTRAINT fk_slideshows_slides
26
+ FOREIGN KEY (bit_core_slideshow_id)
27
+ REFERENCES bit_core_slideshows(id)
28
+ SQL
29
+ end
30
+
31
+ dir.down do
32
+ execute <<-SQL
33
+ ALTER TABLE bit_core_slides
34
+ DROP CONSTRAINT fk_slideshows_slides
35
+ SQL
36
+
37
+ execute <<-SQL
38
+ ALTER TABLE bit_core_slides
39
+ DROP CONSTRAINT IF EXISTS bit_core_slide_position
40
+ SQL
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,6 @@
1
+ # This migration comes from bit_core (originally 20140620174146)
2
+ class AddOptionsToSlides < ActiveRecord::Migration
3
+ def change
4
+ add_column :bit_core_slides, :options, :text
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ # This migration comes from bit_core (originally 20140620174147)
2
+ class AddConfigFieldsToProviders < ActiveRecord::Migration
3
+ def change
4
+ add_column :bit_core_content_providers, :template_path, :string
5
+ add_column :bit_core_content_providers, :data_class_name, :string
6
+ add_column :bit_core_content_providers, :data_attributes, :text
7
+ add_column :bit_core_content_providers, :show_next_nav, :boolean
8
+ add_column :bit_core_content_providers, :locals, :text
9
+ end
10
+ end
@@ -11,25 +11,27 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20140619200219) do
14
+ ActiveRecord::Schema.define(version: 20140620222851) do
15
15
 
16
16
  # These are extensions that must be enabled in order to support this database
17
17
  enable_extension "plpgsql"
18
18
 
19
- create_table "bit_player_content_modules", force: true do |t|
20
- t.string "title", null: false
21
- t.integer "position", default: 1, null: false
19
+ create_table "bit_core_content_modules", force: true do |t|
20
+ t.string "title", null: false
21
+ t.integer "position", default: 1, null: false
22
+ t.integer "bit_core_tool_id", null: false
22
23
  t.datetime "created_at"
23
24
  t.datetime "updated_at"
24
- t.integer "bit_player_tool_id", null: false
25
25
  end
26
26
 
27
- create_table "bit_player_content_providers", force: true do |t|
28
- t.string "type", null: false
27
+ add_index "bit_core_content_modules", ["bit_core_tool_id", "position"], name: "bit_core_content_module_position", unique: true, using: :btree
28
+
29
+ create_table "bit_core_content_providers", force: true do |t|
30
+ t.string "type", null: false
29
31
  t.string "source_content_type"
30
32
  t.integer "source_content_id"
31
- t.integer "bit_player_content_module_id", null: false
32
- t.integer "position", default: 1, null: false
33
+ t.integer "bit_core_content_module_id", null: false
34
+ t.integer "position", default: 1, null: false
33
35
  t.datetime "created_at"
34
36
  t.datetime "updated_at"
35
37
  t.string "template_path"
@@ -39,50 +41,47 @@ ActiveRecord::Schema.define(version: 20140619200219) do
39
41
  t.text "locals"
40
42
  end
41
43
 
42
- add_index "bit_player_content_providers", ["bit_player_content_module_id"], name: "content_module_index", using: :btree
44
+ add_index "bit_core_content_providers", ["bit_core_content_module_id", "position"], name: "bit_core_content_provider_position", unique: true, using: :btree
43
45
 
44
- create_table "bit_player_participant_statuses", force: true do |t|
45
- t.string "context"
46
- t.integer "module_position"
47
- t.integer "provider_position"
48
- t.integer "content_position"
49
- t.integer "participant_id", null: false
46
+ create_table "bit_core_slides", force: true do |t|
47
+ t.string "title", null: false
48
+ t.text "body", null: false
49
+ t.integer "position", default: 1, null: false
50
+ t.integer "bit_core_slideshow_id", null: false
51
+ t.string "type"
52
+ t.boolean "is_title_visible", default: true, null: false
50
53
  t.datetime "created_at"
51
54
  t.datetime "updated_at"
55
+ t.text "options"
52
56
  end
53
57
 
54
- add_index "bit_player_participant_statuses", ["participant_id"], name: "index_participant_statuses_on_participant_id", using: :btree
58
+ add_index "bit_core_slides", ["bit_core_slideshow_id", "position"], name: "bit_core_slide_position", unique: true, using: :btree
55
59
 
56
- create_table "bit_player_slides", force: true do |t|
57
- t.string "title"
58
- t.text "body", null: false
59
- t.integer "position", default: 1, null: false
60
- t.integer "bit_player_slideshow_id", null: false
61
- t.string "type"
62
- t.text "options"
63
- t.boolean "is_title_visible", default: true, null: false
60
+ create_table "bit_core_slideshows", force: true do |t|
61
+ t.string "title", null: false
64
62
  t.datetime "created_at"
65
63
  t.datetime "updated_at"
66
64
  end
67
65
 
68
- add_index "bit_player_slides", ["bit_player_slideshow_id", "position"], name: "bit_player_slide_position", unique: true, using: :btree
69
- add_index "bit_player_slides", ["bit_player_slideshow_id"], name: "index_bit_player_slides_on_bit_player_slideshow_id", using: :btree
70
-
71
- create_table "bit_player_slideshows", force: true do |t|
72
- t.string "title", null: false
66
+ create_table "bit_core_tools", force: true do |t|
67
+ t.string "title", null: false
68
+ t.integer "position", default: 0, null: false
73
69
  t.datetime "created_at"
74
70
  t.datetime "updated_at"
75
71
  end
76
72
 
77
- create_table "bit_player_tools", force: true do |t|
78
- t.string "title", null: false
79
- t.integer "position"
80
- t.boolean "is_home", default: false, null: false
73
+ add_index "bit_core_tools", ["position"], name: "bit_core_tool_position", unique: true, using: :btree
74
+
75
+ create_table "bit_player_participant_statuses", force: true do |t|
76
+ t.string "context"
77
+ t.integer "module_position"
78
+ t.integer "provider_position"
79
+ t.integer "content_position"
80
+ t.integer "participant_id", null: false
81
81
  t.datetime "created_at"
82
82
  t.datetime "updated_at"
83
83
  end
84
84
 
85
- add_index "bit_player_tools", ["position"], name: "index_bit_player_tools_on_position", unique: true, using: :btree
86
- add_index "bit_player_tools", ["title"], name: "index_bit_player_tools_on_title", unique: true, using: :btree
85
+ add_index "bit_player_participant_statuses", ["participant_id"], name: "index_participant_statuses_on_participant_id", using: :btree
87
86
 
88
87
  end