bit_core 2.0.0.beta1 → 2.0.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 720c15056ce284cef90e3a0da4de5e4a49facadc
4
- data.tar.gz: 96ac706ae8a7643791f9310e5a940f9e3fbe3893
3
+ metadata.gz: ca1dff08831343bb3c24fd66207082497817a71b
4
+ data.tar.gz: f1786b5914c92a36970fde58843ee3db09d433c5
5
5
  SHA512:
6
- metadata.gz: c7c06eda74f9facea4759c38653d8d6a731da64ad9c056e2f73fcb99f889a7f16e1bf6cb256b7bfb151a1565768955a7a9bb8ca02b18acd067a2bd4fc1a9a1ef
7
- data.tar.gz: 87044fdf380eec58f6e1169d381a00c4c93d7286af38d86cce5cb6adc09a56bcaca9cb7c49482f8dac00fbcc2210a8c68afdd0bd6724ae98f94815e2390d4459
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: :spec
32
+ task :default do
33
+ Rake::Task["rubocop"].invoke
34
+ Rake::Task["brakeman"].invoke
35
+ Rake::Task["spec"].invoke
36
+ end
@@ -1,6 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  module BitCore
2
3
  # A Slide with audio content.
3
4
  class AudioSlide < Slide
4
- serialize :options
5
5
  end
6
6
  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.where(position: position).first ||
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.gsub(/_/, " ")
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 #{ path }")
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 '#{ data_class_name }'")
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: #{ unknown_attrs.join(', ') })")
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 #{ @content_module.title }: Oops, did you expect a
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.where(position: position).first ||
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
- .sort(slideshow.slide_ids)
41
+ .sort(slideshow.slide_ids)
34
42
  end
35
43
  end
36
44
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "redcarpet"
2
3
 
3
4
  module BitCore
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module BitCore
2
3
  # A section of an application.
3
4
  class Tool < ActiveRecord::Base
@@ -1,6 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  module BitCore
2
3
  # A Slide with video content.
3
4
  class VideoSlide < Slide
4
- serialize :options
5
5
  end
6
6
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module BitCore
2
3
  # Mountable engine with isolated namespace.
3
4
  class Engine < ::Rails::Engine
@@ -1,4 +1,5 @@
1
+ # frozen_string_literal: true
1
2
  # nodoc
2
3
  module BitCore
3
- VERSION = "2.0.0.beta1"
4
+ VERSION = "2.0.0.beta2"
4
5
  end
data/lib/bit_core.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bit_core/engine"
2
3
 
3
4
  # nodoc
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # desc "Explaining what the task does"
2
3
  # task :bit_core do
3
4
  # # Task goes here