bit_core 1.4.7 → 2.0.0.beta1

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: 83988d5bc1ed3fb5a2f1279b14b3dd3928bfc774
4
- data.tar.gz: c85a209a18638f3d7ef8d263858fd25bba245b64
3
+ metadata.gz: 720c15056ce284cef90e3a0da4de5e4a49facadc
4
+ data.tar.gz: 96ac706ae8a7643791f9310e5a940f9e3fbe3893
5
5
  SHA512:
6
- metadata.gz: c2ad64b39006c828af0315f7a96f39e3e62c7a4775f09bd731c2c8f96fbb4d1c331769d010f6fcc3e7da5762b5a775ed9a1b78d17f10f0ee464409c586907478
7
- data.tar.gz: 5a7293edf55653af0318fbb5cc6eac0867a204a6dd9f6887dfe7f1869d05cfb14511a0837b99191ac6acf1f37341b8ead1924569e4db87ed689bed63b5b29d2f
6
+ metadata.gz: c7c06eda74f9facea4759c38653d8d6a731da64ad9c056e2f73fcb99f889a7f16e1bf6cb256b7bfb151a1565768955a7a9bb8ca02b18acd067a2bd4fc1a9a1ef
7
+ data.tar.gz: 87044fdf380eec58f6e1169d381a00c4c93d7286af38d86cce5cb6adc09a56bcaca9cb7c49482f8dac00fbcc2210a8c68afdd0bd6724ae98f94815e2390d4459
data/README.md CHANGED
@@ -1,22 +1,26 @@
1
- ## Installation
1
+ # Bit Core Rails engine
2
2
 
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
- ```
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
- # app/models/arm.rb
12
- class Arm
13
- ...
14
- end
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
- bin/rake app:db:drop app:db:create app:db:migrate RAILS_ENV=test
21
- bin/rspec
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 { |f| load f }
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,6 +1,6 @@
1
- # frozen_string_literal: true
2
1
  module BitCore
3
2
  # A Slide with audio content.
4
3
  class AudioSlide < Slide
4
+ serialize :options
5
5
  end
6
6
  end
@@ -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.find_by(position: position) ||
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.tr("_", " ")
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.find_by(position: position) ||
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
- .sort(slideshow.slide_ids)
33
+ .sort(slideshow.slide_ids)
42
34
  end
43
35
  end
44
36
  end
@@ -1,4 +1,3 @@
1
- # frozen_string_literal: true
2
1
  require "redcarpet"
3
2
 
4
3
  module BitCore
@@ -1,4 +1,3 @@
1
- # frozen_string_literal: true
2
1
  module BitCore
3
2
  # A section of an application.
4
3
  class Tool < ActiveRecord::Base
@@ -1,6 +1,6 @@
1
- # frozen_string_literal: true
2
1
  module BitCore
3
2
  # A Slide with video content.
4
3
  class VideoSlide < Slide
4
+ serialize :options
5
5
  end
6
6
  end
@@ -1,4 +1,3 @@
1
- # frozen_string_literal: true
2
1
  module BitCore
3
2
  # Mountable engine with isolated namespace.
4
3
  class Engine < ::Rails::Engine
@@ -1,5 +1,4 @@
1
- # frozen_string_literal: true
2
1
  # nodoc
3
2
  module BitCore
4
- VERSION = "1.4.7"
3
+ VERSION = "2.0.0.beta1"
5
4
  end
data/lib/bit_core.rb CHANGED
@@ -1,4 +1,3 @@
1
- # frozen_string_literal: true
2
1
  require "bit_core/engine"
3
2
 
4
3
  # nodoc
@@ -1,4 +1,3 @@
1
- # frozen_string_literal: true
2
1
  # desc "Explaining what the task does"
3
2
  # task :bit_core do
4
3
  # # Task goes here
@@ -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.serve_static_files = true
17
- config.static_cache_control = 'public, max-age=3600'
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
@@ -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"