party_mover 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 34cb4c884d3dfd901cc34a43b170f0d51465bb0d
4
+ data.tar.gz: 4a7a02bc0b75e79a66136961e52ca7afd5af38ec
5
+ SHA512:
6
+ metadata.gz: 9549d9dea66af51498dcb4569f153be95e33df0ea6b7042c56aaf3b7ea56030895a60b3e77a30eb23a522b18e2272d2a0322815d5a1d80693286b9295e818a1d
7
+ data.tar.gz: 542b06758bc4ee693c7dff2e4620a348a0d1755390305bec217b95339e1398d8df6f94c6bd4576318b865e857c91c5f98d33f60f4fe0254da7c4a38ef9c97fb8
@@ -0,0 +1 @@
1
+ party_mover-*.gem
@@ -0,0 +1 @@
1
+ require 'party_mover/party_mover'
@@ -0,0 +1,51 @@
1
+ class PartyMover
2
+ class << self
3
+ def move!(uploader, mounted_as, *instances)
4
+ i_d_like_to_move_it_move_it(uploader, mounted_as, *instances)
5
+ move_it!
6
+ end
7
+
8
+ private
9
+
10
+ def i_d_like_to_move_it_move_it(uploader, mounted_as, *instances)
11
+ @uploader = uploader
12
+ @mounted_as = mounted_as
13
+ @instances = instances.flatten
14
+ end
15
+
16
+ def move_it!
17
+ @instances.each do |instance|
18
+ @current_instance = instance
19
+ save_content
20
+ store_content
21
+ clean_content
22
+ end
23
+ end
24
+
25
+ def save_content
26
+ File.open(content_path, 'wb') do |file|
27
+ file.write(content)
28
+ end
29
+ end
30
+
31
+ def store_content
32
+ @uploader.new(@current_instance, @mounted_as).store!(File.open(content_path))
33
+ end
34
+
35
+ def clean_content
36
+ File.delete(content_path)
37
+ end
38
+
39
+ def content_path
40
+ Rails.root.join('tmp', content_name)
41
+ end
42
+
43
+ def content_name
44
+ @current_instance.send(@mounted_as).file.path.split('/').last
45
+ end
46
+
47
+ def content
48
+ @current_instance.send(@mounted_as).read
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,16 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "party_mover"
6
+ s.version = "0.1.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Yauheni Sushkevich"]
9
+ s.email = ["yauhenisushkevich@gmail.com"]
10
+ s.homepage = "https://github.com/yauhenininjia/party_mover"
11
+ s.summary = %q{Move uploaded by CarrierWave content from one server to another.}
12
+ s.description = %q{This gem can move your content from one server to another}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.require_paths = ["lib"]
16
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: party_mover
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Yauheni Sushkevich
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem can move your content from one server to another
14
+ email:
15
+ - yauhenisushkevich@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - lib/party_mover.rb
22
+ - lib/party_mover/party_mover.rb
23
+ - party_mover.gemspec
24
+ homepage: https://github.com/yauhenininjia/party_mover
25
+ licenses: []
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.4.8
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Move uploaded by CarrierWave content from one server to another.
47
+ test_files: []