bit_core 1.4.7 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -11
- data/Rakefile +1 -2
- data/app/models/bit_core/audio_slide.rb +1 -1
- data/app/models/bit_core/content_module.rb +1 -2
- data/app/models/bit_core/content_provider.rb +4 -5
- data/app/models/bit_core/content_providers/null.rb +1 -2
- data/app/models/bit_core/content_providers/slideshow_provider.rb +1 -2
- data/app/models/bit_core/slide.rb +1 -9
- data/app/models/bit_core/slideshow.rb +0 -1
- data/app/models/bit_core/tool.rb +0 -1
- data/app/models/bit_core/video_slide.rb +1 -1
- data/lib/bit_core/engine.rb +0 -1
- data/lib/bit_core/version.rb +1 -2
- data/lib/bit_core.rb +0 -1
- data/lib/tasks/bit_core_tasks.rake +0 -1
- data/spec/dummy/config/application.rb +0 -4
- data/spec/dummy/config/environments/development.rb +1 -1
- data/spec/dummy/config/environments/test.rb +3 -3
- data/spec/dummy/db/schema.rb +4 -8
- data/spec/dummy/log/test.log +0 -1906
- data/spec/models/bit_core/content_module_spec.rb +0 -1
- data/spec/models/bit_core/content_provider_spec.rb +0 -1
- data/spec/models/bit_core/content_providers/slideshow_provider_spec.rb +0 -1
- data/spec/models/bit_core/slide_spec.rb +2 -24
- data/spec/models/bit_core/slideshow_spec.rb +0 -1
- data/spec/spec_helper.rb +3 -5
- metadata +77 -23
- data/app/assets/stylesheets/bit_core/application.css +0 -15
- data/app/controllers/bit_core/application_controller.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 720c15056ce284cef90e3a0da4de5e4a49facadc
|
4
|
+
data.tar.gz: 96ac706ae8a7643791f9310e5a940f9e3fbe3893
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7c06eda74f9facea4759c38653d8d6a731da64ad9c056e2f73fcb99f889a7f16e1bf6cb256b7bfb151a1565768955a7a9bb8ca02b18acd067a2bd4fc1a9a1ef
|
7
|
+
data.tar.gz: 87044fdf380eec58f6e1169d381a00c4c93d7286af38d86cce5cb6adc09a56bcaca9cb7c49482f8dac00fbcc2210a8c68afdd0bd6724ae98f94815e2390d4459
|
data/README.md
CHANGED
@@ -1,22 +1,26 @@
|
|
1
|
-
|
1
|
+
# Bit Core Rails engine
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
This engine provides basic models and logic for slideshows.
|
4
|
+
|
5
|
+
## Version 2.0.x
|
6
|
+
|
7
|
+
Please note that version 2.0.x supports only Ruby 2.3.0 and Rails 5. If you need
|
8
|
+
support for Rails 4, please use the latest 1.x version.
|
7
9
|
|
8
10
|
## Dependencies
|
11
|
+
|
9
12
|
The host application will need to specify an Arm class 'app/models/arm.rb'
|
13
|
+
|
10
14
|
```ruby
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
# app/models/arm.rb
|
16
|
+
class Arm
|
17
|
+
...
|
18
|
+
end
|
15
19
|
```
|
16
20
|
|
17
21
|
## Running Specs
|
18
22
|
|
19
23
|
```console
|
20
|
-
|
21
|
-
|
24
|
+
bin/rake app:db:drop app:db:create app:db:migrate RAILS_ENV=test
|
25
|
+
bin/rake
|
22
26
|
```
|
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
begin
|
3
2
|
require "bundler/setup"
|
4
3
|
rescue LoadError
|
@@ -11,7 +10,7 @@ load "rails/tasks/engine.rake"
|
|
11
10
|
|
12
11
|
Bundler::GemHelper.install_tasks
|
13
12
|
|
14
|
-
Dir[File.join(File.dirname(__FILE__), "tasks/**/*.rake")].each {
|
13
|
+
Dir[File.join(File.dirname(__FILE__), "tasks/**/*.rake")].each {|f| load f }
|
15
14
|
|
16
15
|
require "rspec/core"
|
17
16
|
require "rspec/core/rake_task"
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
module BitCore
|
3
2
|
# A logical unit of content, possibly containing mixed provider types.
|
4
3
|
class ContentModule < ActiveRecord::Base
|
@@ -19,7 +18,7 @@ module BitCore
|
|
19
18
|
# Returns the `ContentProvider` at the given position, or a `Null`
|
20
19
|
# `ContentProvider` if none exists.
|
21
20
|
def provider(position)
|
22
|
-
content_providers.
|
21
|
+
content_providers.where(position: position).first ||
|
23
22
|
ContentProviders::Null.new(self, position)
|
24
23
|
end
|
25
24
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
module BitCore
|
3
2
|
# Modeled after the presenter pattern. Ties data layer to view layer.
|
4
3
|
class ContentProvider < ActiveRecord::Base
|
@@ -44,7 +43,7 @@ module BitCore
|
|
44
43
|
# Returns a human readable string extracted from the ContentProvider class
|
45
44
|
# name.
|
46
45
|
def pretty_label
|
47
|
-
self.class.to_s.split("::").last.underscore.
|
46
|
+
self.class.to_s.split("::").last.underscore.gsub(/_/, " ")
|
48
47
|
end
|
49
48
|
|
50
49
|
private
|
@@ -53,14 +52,14 @@ module BitCore
|
|
53
52
|
path = File.join(Rails.root, "app", "views", template_path || "")
|
54
53
|
return if Dir.exist?(path)
|
55
54
|
|
56
|
-
errors.add(:template_path, "not found at #{path}")
|
55
|
+
errors.add(:template_path, "not found at #{ path }")
|
57
56
|
end
|
58
57
|
|
59
58
|
def data_class_exists
|
60
59
|
return unless data_class_name && !data_class
|
61
60
|
|
62
61
|
errors.add(:data_class_name,
|
63
|
-
"unable to find class '#{data_class_name}'")
|
62
|
+
"unable to find class '#{ data_class_name }'")
|
64
63
|
end
|
65
64
|
|
66
65
|
# rubocop:disable Metrics/AbcSize
|
@@ -73,7 +72,7 @@ module BitCore
|
|
73
72
|
return if unknown_attrs.count == 0
|
74
73
|
|
75
74
|
errors.add(:data_attributes, "must be attributes on the model class " \
|
76
|
-
"(unrecognized: #{unknown_attrs.join(', ')})")
|
75
|
+
"(unrecognized: #{ unknown_attrs.join(', ') })")
|
77
76
|
end
|
78
77
|
# rubocop:enable Metrics/AbcSize
|
79
78
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
module BitCore
|
3
2
|
module ContentProviders
|
4
3
|
# The default provider.
|
@@ -11,7 +10,7 @@ module BitCore
|
|
11
10
|
end
|
12
11
|
|
13
12
|
def render_current(_options)
|
14
|
-
"Content Module #{@content_module.title}: Oops, did you expect a
|
13
|
+
"Content Module #{ @content_module.title }: Oops, did you expect a
|
15
14
|
content provider here?"
|
16
15
|
end
|
17
16
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
module BitCore
|
3
2
|
module ContentProviders
|
4
3
|
# Defines presentation logic for a Slideshow.
|
@@ -17,7 +16,7 @@ module BitCore
|
|
17
16
|
end
|
18
17
|
|
19
18
|
def slide(position)
|
20
|
-
slideshow.slides.
|
19
|
+
slideshow.slides.where(position: position).first ||
|
21
20
|
BitCore::Slide.new(body: "no slides")
|
22
21
|
end
|
23
22
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
require "redcarpet"
|
3
2
|
|
4
3
|
module BitCore
|
@@ -13,11 +12,8 @@ module BitCore
|
|
13
12
|
validates :position, numericality: { greater_than_or_equal_to: 1 }
|
14
13
|
validates :position, uniqueness: { scope: :bit_core_slideshow_id }
|
15
14
|
|
16
|
-
before_validation :normalize_options
|
17
15
|
after_destroy :update_slide_positions
|
18
16
|
|
19
|
-
serialize :options
|
20
|
-
|
21
17
|
def render_body
|
22
18
|
return "" if body.nil?
|
23
19
|
|
@@ -32,13 +28,9 @@ module BitCore
|
|
32
28
|
|
33
29
|
private
|
34
30
|
|
35
|
-
def normalize_options
|
36
|
-
self.options = options.try(:to_h)
|
37
|
-
end
|
38
|
-
|
39
31
|
def update_slide_positions
|
40
32
|
slideshow.reload
|
41
|
-
|
33
|
+
.sort(slideshow.slide_ids)
|
42
34
|
end
|
43
35
|
end
|
44
36
|
end
|
data/app/models/bit_core/tool.rb
CHANGED
data/lib/bit_core/engine.rb
CHANGED
data/lib/bit_core/version.rb
CHANGED
data/lib/bit_core.rb
CHANGED
@@ -2,11 +2,7 @@ require File.expand_path('../boot', __FILE__)
|
|
2
2
|
|
3
3
|
# Pick the frameworks you want:
|
4
4
|
require "active_record/railtie"
|
5
|
-
require "action_controller/railtie"
|
6
|
-
require "action_mailer/railtie"
|
7
5
|
require "action_view/railtie"
|
8
|
-
require "sprockets/railtie"
|
9
|
-
# require "rails/test_unit/railtie"
|
10
6
|
|
11
7
|
Bundler.require(*Rails.groups)
|
12
8
|
require "bit_core"
|
@@ -14,7 +14,7 @@ Rails.application.configure do
|
|
14
14
|
config.action_controller.perform_caching = false
|
15
15
|
|
16
16
|
# Don't care if the mailer can't send.
|
17
|
-
config.action_mailer.raise_delivery_errors = false
|
17
|
+
# config.action_mailer.raise_delivery_errors = false
|
18
18
|
|
19
19
|
# Print deprecation notices to the Rails logger.
|
20
20
|
config.active_support.deprecation = :log
|
@@ -13,8 +13,8 @@ Rails.application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
config.
|
17
|
-
config.
|
16
|
+
config.public_file_server.enabled = true
|
17
|
+
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
|
18
18
|
|
19
19
|
# Show full error reports and disable caching.
|
20
20
|
config.consider_all_requests_local = true
|
@@ -29,7 +29,7 @@ Rails.application.configure do
|
|
29
29
|
# Tell Action Mailer not to deliver emails to the real world.
|
30
30
|
# The :test delivery method accumulates sent emails in the
|
31
31
|
# ActionMailer::Base.deliveries array.
|
32
|
-
config.action_mailer.delivery_method = :test
|
32
|
+
# config.action_mailer.delivery_method = :test
|
33
33
|
|
34
34
|
# Print deprecation notices to the stderr.
|
35
35
|
config.active_support.deprecation = :stderr
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -31,10 +31,9 @@ ActiveRecord::Schema.define(version: 20160311210938) do
|
|
31
31
|
t.datetime "updated_at"
|
32
32
|
t.string "type"
|
33
33
|
t.boolean "is_viz", default: false, null: false
|
34
|
+
t.index ["bit_core_tool_id", "position"], name: "bit_core_content_module_position", unique: true, using: :btree
|
34
35
|
end
|
35
36
|
|
36
|
-
add_index "bit_core_content_modules", ["bit_core_tool_id", "position"], name: "bit_core_content_module_position", unique: true, using: :btree
|
37
|
-
|
38
37
|
create_table "bit_core_content_providers", force: :cascade do |t|
|
39
38
|
t.string "type", null: false
|
40
39
|
t.string "source_content_type"
|
@@ -48,10 +47,9 @@ ActiveRecord::Schema.define(version: 20160311210938) do
|
|
48
47
|
t.text "data_attributes"
|
49
48
|
t.boolean "show_next_nav", default: false, null: false
|
50
49
|
t.text "locals"
|
50
|
+
t.index ["bit_core_content_module_id", "position"], name: "bit_core_content_provider_position", unique: true, using: :btree
|
51
51
|
end
|
52
52
|
|
53
|
-
add_index "bit_core_content_providers", ["bit_core_content_module_id", "position"], name: "bit_core_content_provider_position", unique: true, using: :btree
|
54
|
-
|
55
53
|
create_table "bit_core_slides", force: :cascade do |t|
|
56
54
|
t.string "title", null: false
|
57
55
|
t.text "body", null: false
|
@@ -62,10 +60,9 @@ ActiveRecord::Schema.define(version: 20160311210938) do
|
|
62
60
|
t.datetime "created_at"
|
63
61
|
t.datetime "updated_at"
|
64
62
|
t.text "options"
|
63
|
+
t.index ["bit_core_slideshow_id", "position"], name: "bit_core_slide_position", unique: true, using: :btree
|
65
64
|
end
|
66
65
|
|
67
|
-
add_index "bit_core_slides", ["bit_core_slideshow_id", "position"], name: "bit_core_slide_position", unique: true, using: :btree
|
68
|
-
|
69
66
|
create_table "bit_core_slideshows", force: :cascade do |t|
|
70
67
|
t.string "title", null: false
|
71
68
|
t.datetime "created_at"
|
@@ -80,10 +77,9 @@ ActiveRecord::Schema.define(version: 20160311210938) do
|
|
80
77
|
t.datetime "updated_at"
|
81
78
|
t.integer "arm_id", null: false
|
82
79
|
t.string "type"
|
80
|
+
t.index ["position"], name: "bit_core_tool_position", unique: true, using: :btree
|
83
81
|
end
|
84
82
|
|
85
|
-
add_index "bit_core_tools", ["position"], name: "bit_core_tool_position", unique: true, using: :btree
|
86
|
-
|
87
83
|
add_foreign_key "bit_core_content_modules", "bit_core_tools", name: "fk_content_modules_tools"
|
88
84
|
add_foreign_key "bit_core_content_providers", "bit_core_content_modules", name: "fk_content_providers_modules"
|
89
85
|
add_foreign_key "bit_core_slides", "bit_core_slideshows", name: "fk_slideshows_slides"
|