eivid 1.0.0 → 1.0.4

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
  SHA256:
3
- metadata.gz: 98674e7ecdf813a76dda68ec8f37ad5a1ba3bee64c3c480d50b8f4d5f2cee8b1
4
- data.tar.gz: 3371b018b813ad3abde17f2ec6e5843d71227c98b1eff1fc8606bdd77863979e
3
+ metadata.gz: f3be70d9d3f995714108df4fb59cc7d437f02170ec3121ea58b349843873b149
4
+ data.tar.gz: '03315880246a5a57c4be6062fa6e6a3d19ba171cf16b783a9a323023265da1b4'
5
5
  SHA512:
6
- metadata.gz: c631a4883bd2318cd4ee1da40344e45e9b30158225f69187ca5bb14c3389d2fca39f1481ed0911ed35acc9a3892ec9058ae33b88a27213fbe6c41e9f43fca1f8
7
- data.tar.gz: f2f2d8e6ffcdec2242614f2cf86ac9f1ef45738d525912f919757b3a9d99b222c6c8a26e7c2a5d25404b13e04be8dd17ad7704bf49f45c6e2620f3681a85d03b
6
+ metadata.gz: 78b739ae6ad9a47dc281a2bbbe268cc87b26d600bc183d2907d63f036e61a237ecc22e5cb275019d01c6aeaa291cb20424f6146e8c15fae4c72e00a1f6e38d4a
7
+ data.tar.gz: fbb92b8cee87d4c61eae547dffd79358245fd92c6536d7b9ff68120d06e3d8d4289bcb4dd2ed4650a14b5ef34492b62f2576bee8be57e89735de19ddc5c0d56e
data/README.md CHANGED
@@ -10,18 +10,8 @@ Add the following to your application's Gemfile and run $bundle:
10
10
 
11
11
  ```ruby
12
12
 
13
- gem 'eivid', git: 'https://github.com/eitje-app/eivid_engine', branch: 'production'
13
+ gem 'eivid', "1.0.0" # check the latest version on: https://rubygems.org/gems/eivid
14
14
 
15
- ```
16
- Or, for development purposes, add instead:
17
-
18
- ```ruby
19
- local_eivid_path = "/Users/jurriaanschrofer/Documents/eivid"
20
- if ENV["RAILS_ENV"] == 'development' && Dir.glob(local_eivid_path).any?
21
- gem 'eivid', path: local_eivid_path
22
- else
23
- gem 'eivid', git: 'https://github.com/eitje-app/eivid_engine', branch: 'production'
24
- end
25
15
  ```
26
16
 
27
17
  Add the following file to your app's config/initializers directory:
@@ -13,7 +13,7 @@ module Eivid
13
13
  before_action :validate_video_file, only: [:upload_video]
14
14
 
15
15
  def upload_video
16
- record = UploadService.upload(owner: @owner, user: @user, video_file: video_params["video_file"])
16
+ record = UploadService.upload(owner: @owner, user: @user, video_file: video_params["video_file"], video_title: video_title)
17
17
  render json: record
18
18
  end
19
19
 
@@ -44,5 +44,10 @@ module Eivid
44
44
  params.permit("video_file")
45
45
  end
46
46
 
47
+ def video_title
48
+ title = video_params["video_file"].original_filename
49
+ title.include?('.') ? title.split('.')[0..-2].join('.') : title
50
+ end
51
+
47
52
  end
48
53
  end
@@ -38,7 +38,15 @@ module Eivid
38
38
  end
39
39
 
40
40
  def set_url_thumbnail
41
- @url_thumbnail = @response&.dig(:pictures, :sizes)&.find { |url| url[:width] == 640 && url[:height] == 360 }&.dig(:link_with_play_button)
41
+ @url_thumbnail = find_high_res_thumbnail || find_low_res_thumbnail
42
+ end
43
+
44
+ def find_high_res_thumbnail
45
+ @response&.dig(:pictures, :sizes)&.find { |url| url[:width] == 960 && url[:height] == 540 }&.dig(:link_with_play_button)
46
+ end
47
+
48
+ def find_low_res_thumbnail
49
+ @response&.dig(:pictures, :sizes)&.find { |url| url[:width] == 640 && url[:height] == 360 }&.dig(:link_with_play_button)
42
50
  end
43
51
 
44
52
  def validate_url_presence
@@ -3,7 +3,7 @@ module Eivid
3
3
 
4
4
  has_many :videos
5
5
 
6
- validates :external_id, presence: true #, uniqueness: true # comment out for dev only
6
+ validates :external_id, presence: true, uniqueness: true
7
7
 
8
8
  before_create :get_folder_id
9
9
 
@@ -5,6 +5,8 @@ module Eivid
5
5
  belongs_to :user, optional: true
6
6
  has_many :video_resources
7
7
 
8
+ after_commit :touch_video_resources
9
+
8
10
  def owner_id # required for aliassing :owner_id
9
11
  super
10
12
  end
@@ -17,5 +19,10 @@ module Eivid
17
19
  alias_method :"#{Eivid.owner_model}", :external_owner
18
20
  scope :"of_#{Eivid.owner_model}", -> (owner_id) { where(owner_id: owner_id) }
19
21
 
22
+ def touch_video_resources
23
+ # has_many touch implementation
24
+ video_resources.find_each { |record| record.update(updated_at: Time.now) }
25
+ end
26
+
20
27
  end
21
28
  end
@@ -2,7 +2,7 @@ module Eivid
2
2
  class VideoResource < ApplicationRecord
3
3
 
4
4
  belongs_to :video
5
- belongs_to :resource, polymorphic: true
5
+ belongs_to :resource, polymorphic: true, touch: true
6
6
 
7
7
  end
8
8
  end
@@ -1,9 +1,9 @@
1
1
  module Eivid::UploadService
2
2
  class << self
3
3
 
4
- def upload(owner:, user: nil, video_file:)
4
+ def upload(owner:, user: nil, video_file:, video_title:)
5
5
  @video_file = video_file
6
- @video_record = Eivid::Video.create(owner_id: owner.id, user_id: user&.id)
6
+ @video_record = Eivid::Video.create(owner_id: owner.id, user_id: user&.id, title: video_title)
7
7
  @user = user
8
8
  @file_name, @file_ext = @video_file.original_filename.split('.')
9
9
 
@@ -0,0 +1,5 @@
1
+ class AddTitleToVideo < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :eivid_videos, :title, :string
4
+ end
5
+ end
data/lib/eivid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eivid
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eivid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurriaan Schrofer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-03 00:00:00.000000000 Z
11
+ date: 2021-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -111,6 +111,7 @@ files:
111
111
  - db/migrate/20210419122001_change_url_to_embedded_url.rb
112
112
  - db/migrate/20210419122752_add_video_urls_to_videos.rb
113
113
  - db/migrate/20210420120017_add_user_id_to_eivid_videos.rb
114
+ - db/migrate/20210818121057_add_title_to_video.rb
114
115
  - lib/eivid.rb
115
116
  - lib/eivid/engine.rb
116
117
  - lib/eivid/version.rb