bit_core 1.2.2 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -3
- data/Rakefile +1 -1
- data/app/models/bit_core/audio_slide.rb +6 -0
- data/app/models/bit_core/content_provider.rb +3 -1
- data/app/models/bit_core/content_providers/slideshow_provider.rb +3 -3
- data/app/models/bit_core/slide.rb +9 -0
- data/app/models/bit_core/slideshow.rb +3 -1
- data/app/models/bit_core/tool.rb +5 -3
- data/db/migrate/20141205202720_create_bit_core_arms.rb +10 -0
- data/db/migrate/20141205202724_add_arm_id_to_bit_core_slideshows.rb +25 -0
- data/db/migrate/20141205202740_add_arm_id_to_bit_core_tools.rb +25 -0
- data/db/migrate/20150130155627_add_type_to_tools.rb +5 -0
- data/db/migrate/20150131195914_add_is_viz_to_content_modules.rb +5 -0
- data/db/migrate/20150210161229_add_tool_constraint.rb +25 -0
- data/lib/bit_core/version.rb +1 -1
- data/spec/dummy/config/database.yml +0 -1
- data/spec/dummy/log/development.log +1486 -495
- data/spec/dummy/log/test.log +784 -7780
- data/spec/fixtures/arms.yml +6 -0
- data/spec/fixtures/bit_core/slideshows.yml +1 -0
- data/spec/fixtures/bit_core/tools.yml +1 -0
- data/spec/models/bit_core/content_providers/slideshow_provider_spec.rb +14 -0
- data/spec/models/bit_core/slide_spec.rb +15 -0
- data/spec/models/bit_core/slideshow_spec.rb +12 -0
- metadata +14 -5
- data/spec/dummy/db/schema.rb +0 -76
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 991b3c0c91e0767d75b53eedd8651564d1052b34
|
4
|
+
data.tar.gz: 03a383080f938a4e459e05c82b88eaf59d9e75d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70d02c6df793095ae7d65b2da1b6f90d107f56cbdd068313726d4d126b96e7c9cd5aafa451406ac6f586a5be81b29c36ec304eddee07928b5cff29f5acdedc54
|
7
|
+
data.tar.gz: b2e710249bf82545686a53772e23d435ddcfa380fdcc625bdd3776079492a6dadb7692927eee04d701c1919bffe3ec3e98945b4427a258778bca0aa7329b82c9
|
data/README.md
CHANGED
@@ -1,4 +1,22 @@
|
|
1
|
-
|
1
|
+
## Installation
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
In order to run migrations, you will need to create a 'schema.rb' file (it is in the .gitignore).
|
4
|
+
```console
|
5
|
+
touch spec/dummy/db/schema.rb
|
6
|
+
```
|
7
|
+
|
8
|
+
## Dependencies
|
9
|
+
The host application will need to specify an Arm class 'app/models/arm.rb'
|
10
|
+
```ruby
|
11
|
+
# app/models/arm.rb
|
12
|
+
class Arm
|
13
|
+
...
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
## Running Specs
|
18
|
+
|
19
|
+
```console
|
20
|
+
bin/rake app:db:drop app:db:create app:db:migrate RAILS_ENV=test
|
21
|
+
bin/rspec
|
22
|
+
```
|
data/Rakefile
CHANGED
@@ -62,6 +62,7 @@ module BitCore
|
|
62
62
|
"unable to find class '#{ data_class_name }'")
|
63
63
|
end
|
64
64
|
|
65
|
+
# rubocop:disable Metrics/AbcSize
|
65
66
|
def data_attributes_exist
|
66
67
|
return unless data_attributes
|
67
68
|
attr_names = data_class.try(:attribute_names) || []
|
@@ -71,7 +72,8 @@ module BitCore
|
|
71
72
|
return if unknown_attrs.count == 0
|
72
73
|
|
73
74
|
errors.add(:data_attributes, "must be attributes on the model class " \
|
74
|
-
"(unrecognized: #{ unknown_attrs.join(
|
75
|
+
"(unrecognized: #{ unknown_attrs.join(', ') })")
|
75
76
|
end
|
77
|
+
# rubocop:enable Metrics/AbcSize
|
76
78
|
end
|
77
79
|
end
|
@@ -3,7 +3,7 @@ module BitCore
|
|
3
3
|
# Defines presentation logic for a Slideshow.
|
4
4
|
class SlideshowProvider < BitCore::ContentProvider
|
5
5
|
def slideshow
|
6
|
-
source_content
|
6
|
+
source_content || Slideshow.new
|
7
7
|
end
|
8
8
|
|
9
9
|
def render_current(options)
|
@@ -28,11 +28,11 @@ module BitCore
|
|
28
28
|
true
|
29
29
|
end
|
30
30
|
|
31
|
-
def add_or_update_slideshow(title)
|
31
|
+
def add_or_update_slideshow(title, arm_id = nil)
|
32
32
|
if source_content
|
33
33
|
source_content.update(title: title)
|
34
34
|
else
|
35
|
-
slideshow = BitCore::Slideshow.create(title: title)
|
35
|
+
slideshow = BitCore::Slideshow.create(arm_id: arm_id, title: title)
|
36
36
|
update(source_content: slideshow)
|
37
37
|
end
|
38
38
|
|
@@ -12,6 +12,8 @@ module BitCore
|
|
12
12
|
validates :position, numericality: { greater_than_or_equal_to: 1 }
|
13
13
|
validates :position, uniqueness: { scope: :bit_core_slideshow_id }
|
14
14
|
|
15
|
+
after_destroy :update_slide_positions
|
16
|
+
|
15
17
|
def render_body
|
16
18
|
return "" if body.nil?
|
17
19
|
|
@@ -23,5 +25,12 @@ module BitCore
|
|
23
25
|
space_after_headers: true
|
24
26
|
).render(body).html_safe
|
25
27
|
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def update_slide_positions
|
32
|
+
slideshow.reload
|
33
|
+
.sort(slideshow.slide_ids)
|
34
|
+
end
|
26
35
|
end
|
27
36
|
end
|
@@ -3,6 +3,8 @@ require "redcarpet"
|
|
3
3
|
module BitCore
|
4
4
|
# A collection of ordered Slides.
|
5
5
|
class Slideshow < ActiveRecord::Base
|
6
|
+
belongs_to :arm
|
7
|
+
|
6
8
|
has_many :slides,
|
7
9
|
-> { order "position" },
|
8
10
|
class_name: "BitCore::Slide",
|
@@ -13,7 +15,7 @@ module BitCore
|
|
13
15
|
as: :source_content,
|
14
16
|
dependent: :nullify
|
15
17
|
|
16
|
-
validates :title, presence: true
|
18
|
+
validates :arm_id, :title, presence: true
|
17
19
|
|
18
20
|
accepts_nested_attributes_for :slides
|
19
21
|
|
data/app/models/bit_core/tool.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
module BitCore
|
2
2
|
# A section of an application.
|
3
3
|
class Tool < ActiveRecord::Base
|
4
|
+
belongs_to :arm
|
5
|
+
|
4
6
|
has_many :content_modules,
|
5
7
|
class_name: "BitCore::ContentModule",
|
6
8
|
foreign_key: :bit_core_tool_id,
|
7
9
|
inverse_of: :tool,
|
8
10
|
dependent: :destroy
|
9
11
|
|
10
|
-
validates :
|
12
|
+
validates :arm, :position, :title, presence: true
|
11
13
|
validates :position,
|
12
|
-
|
13
|
-
|
14
|
+
numericality: { greater_than_or_equal_to: 0 },
|
15
|
+
uniqueness: { scope: :arm_id }
|
14
16
|
|
15
17
|
def add_module(title_or_module)
|
16
18
|
if title_or_module.class == String
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class AddArmIdToBitCoreSlideshows < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :bit_core_slideshows, :arm_id, :integer, null: false
|
4
|
+
|
5
|
+
reversible do |dir|
|
6
|
+
dir.up do
|
7
|
+
# add foreign key constaint
|
8
|
+
execute <<-SQL
|
9
|
+
ALTER TABLE bit_core_slideshows
|
10
|
+
ADD CONSTRAINT fk_bit_core_slideshows_arms
|
11
|
+
FOREIGN KEY (arm_id)
|
12
|
+
REFERENCES arms(id)
|
13
|
+
SQL
|
14
|
+
end
|
15
|
+
|
16
|
+
dir.down do
|
17
|
+
# remove foreign key constaint
|
18
|
+
execute <<-SQL
|
19
|
+
ALTER TABLE bit_core_slideshows
|
20
|
+
DROP CONSTRAINT fk_bit_core_slideshows_arms
|
21
|
+
SQL
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class AddArmIdToBitCoreTools < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :bit_core_tools, :arm_id, :integer, null: false
|
4
|
+
|
5
|
+
reversible do |dir|
|
6
|
+
dir.up do
|
7
|
+
# add foreign key constaint
|
8
|
+
execute <<-SQL
|
9
|
+
ALTER TABLE bit_core_tools
|
10
|
+
ADD CONSTRAINT fk_bit_core_tools_arms
|
11
|
+
FOREIGN KEY (arm_id)
|
12
|
+
REFERENCES arms(id)
|
13
|
+
SQL
|
14
|
+
end
|
15
|
+
|
16
|
+
dir.down do
|
17
|
+
# remove foreign key constaint
|
18
|
+
execute <<-SQL
|
19
|
+
ALTER TABLE bit_core_tools
|
20
|
+
DROP CONSTRAINT fk_bit_core_tools_arms
|
21
|
+
SQL
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class AddToolConstraint < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
BitCore::Tool.all.each do |t|
|
4
|
+
t.destroy! if t.arm.nil?
|
5
|
+
end
|
6
|
+
|
7
|
+
reversible do |dir|
|
8
|
+
dir.up do
|
9
|
+
execute <<-SQL
|
10
|
+
ALTER TABLE bit_core_tools
|
11
|
+
ADD CONSTRAINT fk_tools_arms
|
12
|
+
FOREIGN KEY (arm_id)
|
13
|
+
REFERENCES arms(id)
|
14
|
+
SQL
|
15
|
+
end
|
16
|
+
|
17
|
+
dir.down do
|
18
|
+
execute <<-SQL
|
19
|
+
ALTER TABLE bit_core_tools
|
20
|
+
DROP CONSTRAINT IF EXISTS fk_tools_arms
|
21
|
+
SQL
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/bit_core/version.rb
CHANGED