eivid 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +215 -0
  4. data/Rakefile +18 -0
  5. data/app/controllers/eivid/application_controller.rb +20 -0
  6. data/app/controllers/eivid/concerns/video_validations.rb +42 -0
  7. data/app/controllers/eivid/videos_controller.rb +48 -0
  8. data/app/dump/eivid/video_mime_dump.rb +9 -0
  9. data/app/errors/eivid/incorrect_video_mime_type_error.rb +4 -0
  10. data/app/errors/eivid/main_app_record_not_found_error.rb +4 -0
  11. data/app/errors/eivid/maximum_vimeo_poll_reached_error.rb +4 -0
  12. data/app/errors/eivid/video_file_not_present_error.rb +4 -0
  13. data/app/errors/eivid/video_file_size_too_big_error.rb +4 -0
  14. data/app/errors/eivid/video_unavailable_error.rb +4 -0
  15. data/app/errors/eivid/video_urls_unavailable_error.rb +4 -0
  16. data/app/jobs/eivid/application_job.rb +4 -0
  17. data/app/jobs/eivid/check_vimeo_status_job.rb +46 -0
  18. data/app/jobs/eivid/get_vimeo_urls_job.rb +62 -0
  19. data/app/jobs/eivid/upload_vimeo_job.rb +55 -0
  20. data/app/mailers/eivid/application_mailer.rb +6 -0
  21. data/app/models/eivid/application_record.rb +5 -0
  22. data/app/models/eivid/concerns/main_app/owner.rb +17 -0
  23. data/app/models/eivid/concerns/main_app/user.rb +11 -0
  24. data/app/models/eivid/concerns/main_app/video_concerns.rb +16 -0
  25. data/app/models/eivid/concerns/main_app/video_resource.rb +11 -0
  26. data/app/models/eivid/concerns/request_service/delete_video.rb +17 -0
  27. data/app/models/eivid/concerns/request_service/get_video.rb +9 -0
  28. data/app/models/eivid/concerns/request_service/manage_folder.rb +29 -0
  29. data/app/models/eivid/concerns/request_service/poll_status.rb +9 -0
  30. data/app/models/eivid/concerns/request_service/testing_methods.rb +38 -0
  31. data/app/models/eivid/concerns/request_service/upload_video.rb +31 -0
  32. data/app/models/eivid/owner.rb +21 -0
  33. data/app/models/eivid/video.rb +21 -0
  34. data/app/models/eivid/video_resource.rb +8 -0
  35. data/app/services/eivid/notify_front_service.rb +14 -0
  36. data/app/services/eivid/request_service.rb +42 -0
  37. data/app/services/eivid/upload_service.rb +30 -0
  38. data/config/initializers/macro_initializer.rb +22 -0
  39. data/config/routes.rb +8 -0
  40. data/db/migrate/20210325114212_create_eivid_videos.rb +11 -0
  41. data/db/migrate/20210325140804_add_uploaded_bool_to_videos.rb +5 -0
  42. data/db/migrate/20210330092643_create_eivid_owners.rb +9 -0
  43. data/db/migrate/20210330094604_add_external_id_to_owner.rb +5 -0
  44. data/db/migrate/20210330100147_add_folder_id_to_owner.rb +5 -0
  45. data/db/migrate/20210330103729_add_vimeo_id_to_videos.rb +5 -0
  46. data/db/migrate/20210331082454_add_status_poll_cnt_to_videos.rb +5 -0
  47. data/db/migrate/20210401091448_create_eivid_video_resources.rb +12 -0
  48. data/db/migrate/20210401123512_remove_status_poll_cnt_from_eivid_videos.rb +5 -0
  49. data/db/migrate/20210401132759_create_eivid_dev_envs.rb +11 -0
  50. data/db/migrate/20210401134700_drop.rb +5 -0
  51. data/db/migrate/20210419122001_change_url_to_embedded_url.rb +5 -0
  52. data/db/migrate/20210419122752_add_video_urls_to_videos.rb +7 -0
  53. data/db/migrate/20210420120017_add_user_id_to_eivid_videos.rb +5 -0
  54. data/lib/eivid.rb +6 -0
  55. data/lib/eivid/engine.rb +33 -0
  56. data/lib/eivid/version.rb +3 -0
  57. data/lib/tasks/eivid_tasks.rake +4 -0
  58. 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
@@ -0,0 +1,8 @@
1
+ Eivid::Engine.routes.draw do
2
+
3
+ resources :videos do
4
+ post 'upload_video', on: :collection
5
+ get 'owner_videos', on: :collection
6
+ end
7
+
8
+ end
@@ -0,0 +1,11 @@
1
+ class CreateEividVideos < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :eivid_videos do |t|
4
+
5
+ t.timestamps
6
+ t.integer :owner_id
7
+ t.string :url
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class AddUploadedBoolToVideos < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :eivid_videos, :uploaded, :boolean, default: false
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ class CreateEividOwners < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :eivid_owners do |t|
4
+
5
+ t.timestamps
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class AddExternalIdToOwner < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :eivid_owners, :external_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddFolderIdToOwner < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :eivid_owners, :folder_id, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddVimeoIdToVideos < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :eivid_videos, :vimeo_id, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddStatusPollCntToVideos < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :eivid_videos, :status_poll_cnt, :integer, default: 0
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ class CreateEividVideoResources < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :eivid_video_resources do |t|
4
+
5
+ t.timestamps
6
+ t.integer :video_id
7
+ t.integer :resource_id
8
+ t.string :resource_type
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class RemoveStatusPollCntFromEividVideos < ActiveRecord::Migration[5.2]
2
+ def change
3
+ remove_column :eivid_videos, :status_poll_cnt
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ class CreateEividDevEnvs < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :eivid_dev_envs do |t|
4
+
5
+ t.timestamps
6
+ t.string :env
7
+ t.string :folder_id
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class Drop < ActiveRecord::Migration[5.2]
2
+ def change
3
+ drop_table :eivid_dev_envs
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class ChangeUrlToEmbeddedUrl < ActiveRecord::Migration[5.2]
2
+ def change
3
+ rename_column :eivid_videos, :url, :url_embedded
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ class AddVideoUrlsToVideos < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :eivid_videos, :url_sd, :string
4
+ add_column :eivid_videos, :url_hd, :string
5
+ add_column :eivid_videos, :url_thumbnail, :string
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ class AddUserIdToEividVideos < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :eivid_videos, :user_id, :integer
4
+ end
5
+ end
data/lib/eivid.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "eivid/version"
2
+ require "eivid/engine"
3
+
4
+ module Eivid
5
+ # Your code goes here...
6
+ end
@@ -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
@@ -0,0 +1,3 @@
1
+ module Eivid
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :eivid do
3
+ # # Task goes here
4
+ # 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: []