eivid 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +215 -0
- data/Rakefile +18 -0
- data/app/controllers/eivid/application_controller.rb +20 -0
- data/app/controllers/eivid/concerns/video_validations.rb +42 -0
- data/app/controllers/eivid/videos_controller.rb +48 -0
- data/app/dump/eivid/video_mime_dump.rb +9 -0
- data/app/errors/eivid/incorrect_video_mime_type_error.rb +4 -0
- data/app/errors/eivid/main_app_record_not_found_error.rb +4 -0
- data/app/errors/eivid/maximum_vimeo_poll_reached_error.rb +4 -0
- data/app/errors/eivid/video_file_not_present_error.rb +4 -0
- data/app/errors/eivid/video_file_size_too_big_error.rb +4 -0
- data/app/errors/eivid/video_unavailable_error.rb +4 -0
- data/app/errors/eivid/video_urls_unavailable_error.rb +4 -0
- data/app/jobs/eivid/application_job.rb +4 -0
- data/app/jobs/eivid/check_vimeo_status_job.rb +46 -0
- data/app/jobs/eivid/get_vimeo_urls_job.rb +62 -0
- data/app/jobs/eivid/upload_vimeo_job.rb +55 -0
- data/app/mailers/eivid/application_mailer.rb +6 -0
- data/app/models/eivid/application_record.rb +5 -0
- data/app/models/eivid/concerns/main_app/owner.rb +17 -0
- data/app/models/eivid/concerns/main_app/user.rb +11 -0
- data/app/models/eivid/concerns/main_app/video_concerns.rb +16 -0
- data/app/models/eivid/concerns/main_app/video_resource.rb +11 -0
- data/app/models/eivid/concerns/request_service/delete_video.rb +17 -0
- data/app/models/eivid/concerns/request_service/get_video.rb +9 -0
- data/app/models/eivid/concerns/request_service/manage_folder.rb +29 -0
- data/app/models/eivid/concerns/request_service/poll_status.rb +9 -0
- data/app/models/eivid/concerns/request_service/testing_methods.rb +38 -0
- data/app/models/eivid/concerns/request_service/upload_video.rb +31 -0
- data/app/models/eivid/owner.rb +21 -0
- data/app/models/eivid/video.rb +21 -0
- data/app/models/eivid/video_resource.rb +8 -0
- data/app/services/eivid/notify_front_service.rb +14 -0
- data/app/services/eivid/request_service.rb +42 -0
- data/app/services/eivid/upload_service.rb +30 -0
- data/config/initializers/macro_initializer.rb +22 -0
- data/config/routes.rb +8 -0
- data/db/migrate/20210325114212_create_eivid_videos.rb +11 -0
- data/db/migrate/20210325140804_add_uploaded_bool_to_videos.rb +5 -0
- data/db/migrate/20210330092643_create_eivid_owners.rb +9 -0
- data/db/migrate/20210330094604_add_external_id_to_owner.rb +5 -0
- data/db/migrate/20210330100147_add_folder_id_to_owner.rb +5 -0
- data/db/migrate/20210330103729_add_vimeo_id_to_videos.rb +5 -0
- data/db/migrate/20210331082454_add_status_poll_cnt_to_videos.rb +5 -0
- data/db/migrate/20210401091448_create_eivid_video_resources.rb +12 -0
- data/db/migrate/20210401123512_remove_status_poll_cnt_from_eivid_videos.rb +5 -0
- data/db/migrate/20210401132759_create_eivid_dev_envs.rb +11 -0
- data/db/migrate/20210401134700_drop.rb +5 -0
- data/db/migrate/20210419122001_change_url_to_embedded_url.rb +5 -0
- data/db/migrate/20210419122752_add_video_urls_to_videos.rb +7 -0
- data/db/migrate/20210420120017_add_user_id_to_eivid_videos.rb +5 -0
- data/lib/eivid.rb +6 -0
- data/lib/eivid/engine.rb +33 -0
- data/lib/eivid/version.rb +3 -0
- data/lib/tasks/eivid_tasks.rake +4 -0
- metadata +144 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
module Eivid::UploadService
|
2
|
+
class << self
|
3
|
+
|
4
|
+
def upload(owner:, user: nil, video_file:)
|
5
|
+
@video_file = video_file
|
6
|
+
@video_record = Eivid::Video.create(owner_id: owner.id, user_id: user&.id)
|
7
|
+
@user = user
|
8
|
+
@file_name, @file_ext = @video_file.original_filename.split('.')
|
9
|
+
|
10
|
+
create_temp_file
|
11
|
+
upload_to_vimeo
|
12
|
+
@video_record
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def create_temp_file
|
18
|
+
@temp_file = Tempfile.new([@file_name, ".#{@file_ext.downcase}"], "#{Rails.root}/tmp/")
|
19
|
+
@temp_file << @video_file.tempfile.open.read
|
20
|
+
|
21
|
+
@temp_path = @temp_file.path
|
22
|
+
@temp_file.close
|
23
|
+
end
|
24
|
+
|
25
|
+
def upload_to_vimeo
|
26
|
+
Eivid::UploadVimeoJob.perform_later(video_record: @video_record, video_path: @temp_path)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Eivid::Macros
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
included do
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def eivid_owner
|
7
|
+
include Eivid::Concerns::MainApp::Owner
|
8
|
+
end
|
9
|
+
|
10
|
+
def eivid_video_resource
|
11
|
+
include Eivid::Concerns::MainApp::VideoResource
|
12
|
+
end
|
13
|
+
|
14
|
+
def eivid_user
|
15
|
+
include Eivid::Concerns::MainApp::User
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
::ActiveRecord::Base.send :include, Eivid::Macros
|
data/config/routes.rb
ADDED
data/lib/eivid.rb
ADDED
data/lib/eivid/engine.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Eivid
|
2
|
+
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
|
5
|
+
isolate_namespace Eivid
|
6
|
+
config.generators.api_only = true
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
mattr_accessor :owner_model, :infer_external_owner_id, :notify_front_enabled, :notify_method_on_upload,
|
13
|
+
:notify_method_on_video_available, :notify_method_on_versions_available
|
14
|
+
|
15
|
+
#sets video owner in the main app
|
16
|
+
self.owner_model = nil
|
17
|
+
|
18
|
+
# sets how to extract the owner_id in controller actions
|
19
|
+
self.infer_external_owner_id = "params['external_owner_id'].to_i"
|
20
|
+
|
21
|
+
# sets front end notifiers
|
22
|
+
self.notify_front_enabled = false
|
23
|
+
self.notify_method_on_upload = nil
|
24
|
+
self.notify_method_on_video_available = nil
|
25
|
+
self.notify_method_on_versions_available = nil
|
26
|
+
|
27
|
+
def set_mattr_accessors(&block)
|
28
|
+
yield self
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eivid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jurriaan Schrofer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.2.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.2.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.17.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.17.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: amazing_print
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.0
|
55
|
+
description: Eivid because we can.
|
56
|
+
email:
|
57
|
+
- jschrofer@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- app/controllers/eivid/application_controller.rb
|
66
|
+
- app/controllers/eivid/concerns/video_validations.rb
|
67
|
+
- app/controllers/eivid/videos_controller.rb
|
68
|
+
- app/dump/eivid/video_mime_dump.rb
|
69
|
+
- app/errors/eivid/incorrect_video_mime_type_error.rb
|
70
|
+
- app/errors/eivid/main_app_record_not_found_error.rb
|
71
|
+
- app/errors/eivid/maximum_vimeo_poll_reached_error.rb
|
72
|
+
- app/errors/eivid/video_file_not_present_error.rb
|
73
|
+
- app/errors/eivid/video_file_size_too_big_error.rb
|
74
|
+
- app/errors/eivid/video_unavailable_error.rb
|
75
|
+
- app/errors/eivid/video_urls_unavailable_error.rb
|
76
|
+
- app/jobs/eivid/application_job.rb
|
77
|
+
- app/jobs/eivid/check_vimeo_status_job.rb
|
78
|
+
- app/jobs/eivid/get_vimeo_urls_job.rb
|
79
|
+
- app/jobs/eivid/upload_vimeo_job.rb
|
80
|
+
- app/mailers/eivid/application_mailer.rb
|
81
|
+
- app/models/eivid/application_record.rb
|
82
|
+
- app/models/eivid/concerns/main_app/owner.rb
|
83
|
+
- app/models/eivid/concerns/main_app/user.rb
|
84
|
+
- app/models/eivid/concerns/main_app/video_concerns.rb
|
85
|
+
- app/models/eivid/concerns/main_app/video_resource.rb
|
86
|
+
- app/models/eivid/concerns/request_service/delete_video.rb
|
87
|
+
- app/models/eivid/concerns/request_service/get_video.rb
|
88
|
+
- app/models/eivid/concerns/request_service/manage_folder.rb
|
89
|
+
- app/models/eivid/concerns/request_service/poll_status.rb
|
90
|
+
- app/models/eivid/concerns/request_service/testing_methods.rb
|
91
|
+
- app/models/eivid/concerns/request_service/upload_video.rb
|
92
|
+
- app/models/eivid/owner.rb
|
93
|
+
- app/models/eivid/video.rb
|
94
|
+
- app/models/eivid/video_resource.rb
|
95
|
+
- app/services/eivid/notify_front_service.rb
|
96
|
+
- app/services/eivid/request_service.rb
|
97
|
+
- app/services/eivid/upload_service.rb
|
98
|
+
- config/initializers/macro_initializer.rb
|
99
|
+
- config/routes.rb
|
100
|
+
- db/migrate/20210325114212_create_eivid_videos.rb
|
101
|
+
- db/migrate/20210325140804_add_uploaded_bool_to_videos.rb
|
102
|
+
- db/migrate/20210330092643_create_eivid_owners.rb
|
103
|
+
- db/migrate/20210330094604_add_external_id_to_owner.rb
|
104
|
+
- db/migrate/20210330100147_add_folder_id_to_owner.rb
|
105
|
+
- db/migrate/20210330103729_add_vimeo_id_to_videos.rb
|
106
|
+
- db/migrate/20210331082454_add_status_poll_cnt_to_videos.rb
|
107
|
+
- db/migrate/20210401091448_create_eivid_video_resources.rb
|
108
|
+
- db/migrate/20210401123512_remove_status_poll_cnt_from_eivid_videos.rb
|
109
|
+
- db/migrate/20210401132759_create_eivid_dev_envs.rb
|
110
|
+
- db/migrate/20210401134700_drop.rb
|
111
|
+
- db/migrate/20210419122001_change_url_to_embedded_url.rb
|
112
|
+
- db/migrate/20210419122752_add_video_urls_to_videos.rb
|
113
|
+
- db/migrate/20210420120017_add_user_id_to_eivid_videos.rb
|
114
|
+
- lib/eivid.rb
|
115
|
+
- lib/eivid/engine.rb
|
116
|
+
- lib/eivid/version.rb
|
117
|
+
- lib/tasks/eivid_tasks.rake
|
118
|
+
homepage: https://github.com/eitje-app/eivid_engine
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata:
|
122
|
+
homepage_uri: https://github.com/eitje-app/eivid_engine
|
123
|
+
source_code_uri: https://github.com/eitje-app/eivid_engine
|
124
|
+
changelog_uri: https://github.com/eitje-app/eivid_engine
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubygems_version: 3.1.2
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Eivid because we can.
|
144
|
+
test_files: []
|