bit_core 2.0.0.beta1 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +17 -2
- data/app/models/bit_core/audio_slide.rb +1 -1
- data/app/models/bit_core/content_module.rb +2 -1
- data/app/models/bit_core/content_provider.rb +5 -4
- data/app/models/bit_core/content_providers/null.rb +2 -1
- data/app/models/bit_core/content_providers/slideshow_provider.rb +2 -1
- data/app/models/bit_core/slide.rb +9 -1
- data/app/models/bit_core/slideshow.rb +1 -0
- data/app/models/bit_core/tool.rb +1 -0
- data/app/models/bit_core/video_slide.rb +1 -1
- data/lib/bit_core/engine.rb +1 -0
- data/lib/bit_core/version.rb +2 -1
- data/lib/bit_core.rb +1 -0
- data/lib/tasks/bit_core_tasks.rake +1 -0
- data/spec/dummy/log/test.log +1759 -0
- data/spec/models/bit_core/content_module_spec.rb +1 -0
- data/spec/models/bit_core/content_provider_spec.rb +1 -0
- data/spec/models/bit_core/content_providers/slideshow_provider_spec.rb +1 -0
- data/spec/models/bit_core/slide_spec.rb +24 -2
- data/spec/models/bit_core/slideshow_spec.rb +1 -0
- data/spec/spec_helper.rb +4 -3
- metadata +43 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca1dff08831343bb3c24fd66207082497817a71b
|
4
|
+
data.tar.gz: f1786b5914c92a36970fde58843ee3db09d433c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 403a490583533d46c4519396607474cc4be15d0328ae37aa5c415f5c50ad7e7daeef09653fd9f9955c5539dfbc4837002c14c71b5a68ff7ce6e324f66e7d0ae3
|
7
|
+
data.tar.gz: 0aa6a99a0f53fa4ff68fcc8d0e33c04fc8043b5328904bda11bc9165000ae20e847067ec3607c60535e0a73bd5d55b62490ac6efbce096e687688c8786f54adf
|
data/Rakefile
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
begin
|
2
3
|
require "bundler/setup"
|
3
4
|
rescue LoadError
|
@@ -10,7 +11,17 @@ load "rails/tasks/engine.rake"
|
|
10
11
|
|
11
12
|
Bundler::GemHelper.install_tasks
|
12
13
|
|
13
|
-
Dir[File.join(File.dirname(__FILE__), "tasks/**/*.rake")].each {|f| load f }
|
14
|
+
Dir[File.join(File.dirname(__FILE__), "tasks/**/*.rake")].each { |f| load f }
|
15
|
+
|
16
|
+
require "rubocop/rake_task"
|
17
|
+
|
18
|
+
RuboCop::RakeTask.new
|
19
|
+
|
20
|
+
desc "Run Brakeman"
|
21
|
+
task :brakeman do
|
22
|
+
dir = File.dirname(__FILE__)
|
23
|
+
puts `#{ File.join(dir, "bin", "brakeman") } #{ File.join(dir, ".") }`
|
24
|
+
end
|
14
25
|
|
15
26
|
require "rspec/core"
|
16
27
|
require "rspec/core/rake_task"
|
@@ -18,4 +29,8 @@ require "rspec/core/rake_task"
|
|
18
29
|
desc "Run all specs in spec directory (excluding plugin specs)"
|
19
30
|
RSpec::Core::RakeTask.new(:spec)
|
20
31
|
|
21
|
-
task default
|
32
|
+
task :default do
|
33
|
+
Rake::Task["rubocop"].invoke
|
34
|
+
Rake::Task["brakeman"].invoke
|
35
|
+
Rake::Task["spec"].invoke
|
36
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module BitCore
|
2
3
|
# A logical unit of content, possibly containing mixed provider types.
|
3
4
|
class ContentModule < ActiveRecord::Base
|
@@ -18,7 +19,7 @@ module BitCore
|
|
18
19
|
# Returns the `ContentProvider` at the given position, or a `Null`
|
19
20
|
# `ContentProvider` if none exists.
|
20
21
|
def provider(position)
|
21
|
-
content_providers.
|
22
|
+
content_providers.find_by(position: position) ||
|
22
23
|
ContentProviders::Null.new(self, position)
|
23
24
|
end
|
24
25
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module BitCore
|
2
3
|
# Modeled after the presenter pattern. Ties data layer to view layer.
|
3
4
|
class ContentProvider < ActiveRecord::Base
|
@@ -43,7 +44,7 @@ module BitCore
|
|
43
44
|
# Returns a human readable string extracted from the ContentProvider class
|
44
45
|
# name.
|
45
46
|
def pretty_label
|
46
|
-
self.class.to_s.split("::").last.underscore.
|
47
|
+
self.class.to_s.split("::").last.underscore.tr("_", " ")
|
47
48
|
end
|
48
49
|
|
49
50
|
private
|
@@ -52,14 +53,14 @@ module BitCore
|
|
52
53
|
path = File.join(Rails.root, "app", "views", template_path || "")
|
53
54
|
return if Dir.exist?(path)
|
54
55
|
|
55
|
-
errors.add(:template_path, "not found at #{
|
56
|
+
errors.add(:template_path, "not found at #{path}")
|
56
57
|
end
|
57
58
|
|
58
59
|
def data_class_exists
|
59
60
|
return unless data_class_name && !data_class
|
60
61
|
|
61
62
|
errors.add(:data_class_name,
|
62
|
-
"unable to find class '#{
|
63
|
+
"unable to find class '#{data_class_name}'")
|
63
64
|
end
|
64
65
|
|
65
66
|
# rubocop:disable Metrics/AbcSize
|
@@ -72,7 +73,7 @@ module BitCore
|
|
72
73
|
return if unknown_attrs.count == 0
|
73
74
|
|
74
75
|
errors.add(:data_attributes, "must be attributes on the model class " \
|
75
|
-
"(unrecognized: #{
|
76
|
+
"(unrecognized: #{unknown_attrs.join(', ')})")
|
76
77
|
end
|
77
78
|
# rubocop:enable Metrics/AbcSize
|
78
79
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module BitCore
|
2
3
|
module ContentProviders
|
3
4
|
# The default provider.
|
@@ -10,7 +11,7 @@ module BitCore
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def render_current(_options)
|
13
|
-
"Content Module #{
|
14
|
+
"Content Module #{@content_module.title}: Oops, did you expect a
|
14
15
|
content provider here?"
|
15
16
|
end
|
16
17
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module BitCore
|
2
3
|
module ContentProviders
|
3
4
|
# Defines presentation logic for a Slideshow.
|
@@ -16,7 +17,7 @@ module BitCore
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def slide(position)
|
19
|
-
slideshow.slides.
|
20
|
+
slideshow.slides.find_by(position: position) ||
|
20
21
|
BitCore::Slide.new(body: "no slides")
|
21
22
|
end
|
22
23
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "redcarpet"
|
2
3
|
|
3
4
|
module BitCore
|
@@ -12,8 +13,11 @@ module BitCore
|
|
12
13
|
validates :position, numericality: { greater_than_or_equal_to: 1 }
|
13
14
|
validates :position, uniqueness: { scope: :bit_core_slideshow_id }
|
14
15
|
|
16
|
+
before_validation :normalize_options
|
15
17
|
after_destroy :update_slide_positions
|
16
18
|
|
19
|
+
serialize :options
|
20
|
+
|
17
21
|
def render_body
|
18
22
|
return "" if body.nil?
|
19
23
|
|
@@ -28,9 +32,13 @@ module BitCore
|
|
28
32
|
|
29
33
|
private
|
30
34
|
|
35
|
+
def normalize_options
|
36
|
+
self.options = options.try(:to_h)
|
37
|
+
end
|
38
|
+
|
31
39
|
def update_slide_positions
|
32
40
|
slideshow.reload
|
33
|
-
|
41
|
+
.sort(slideshow.slide_ids)
|
34
42
|
end
|
35
43
|
end
|
36
44
|
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