export_mongo_s3 0.0.2 → 0.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 +4 -4
- data/export_mongo_s3.gemspec +1 -1
- data/lib/export_mongo_s3/application.rb +17 -1
- data/lib/export_mongo_s3/db.rb +7 -7
- data/lib/helpers/config.yml.template +2 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76a26aaa62058eb973d17ac3cbc0c95c2eec696c
|
4
|
+
data.tar.gz: 37044bf2601d7edad94e302f741188e1c1b5bb03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03e8a4caf2ceebdbc13a1330766bd08718f938edbd8f56e1803573e1d55f05233ecd26403a9ce40ccdf1c8fd3bc2b2a4894a0f92085ca8e6d266ef60a19176b8
|
7
|
+
data.tar.gz: 01201971b79f19b8049f3b49ea5af181c74c1e51f7ee32b9ee7940d293c32428cea6189405ce2ce99e883f758b8f94c41c0969b3831f99ff44baf9a06c620957
|
data/export_mongo_s3.gemspec
CHANGED
@@ -102,7 +102,8 @@ module ExportMongoS3
|
|
102
102
|
else
|
103
103
|
|
104
104
|
puts "\t compress..."
|
105
|
-
|
105
|
+
compression_level = get_compression_level
|
106
|
+
zip_result = %x(zip -#{compression_level} -r '#{export_path}.zip' '#{export_path}/' -j)
|
106
107
|
raise "Error zip. Msg: #{zip_result}" unless $?.exitstatus.zero?
|
107
108
|
|
108
109
|
FileUtils.rm_rf(export_path)
|
@@ -222,5 +223,20 @@ module ExportMongoS3
|
|
222
223
|
Dir.mktmpdir(nil, temp_dir)
|
223
224
|
end
|
224
225
|
|
226
|
+
def get_compression_level
|
227
|
+
compression_level = @config[:export][:compression_level]
|
228
|
+
|
229
|
+
if compression_level.nil? || compression_level == ''
|
230
|
+
result = 6 #default value
|
231
|
+
else
|
232
|
+
result = Integer(compression_level)
|
233
|
+
unless result >= 0 and result <= 9
|
234
|
+
raise 'compression_level is not in [0..9]'
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
result
|
239
|
+
end
|
240
|
+
|
225
241
|
end
|
226
242
|
end
|
data/lib/export_mongo_s3/db.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module ExportMongoS3
|
2
2
|
class Db
|
3
3
|
|
4
|
-
SYSTEM_COLLECTIONS = %w(admin_users
|
4
|
+
SYSTEM_COLLECTIONS = %w(admin_users system.indexes)
|
5
5
|
|
6
6
|
def initialize(options)
|
7
7
|
@options = options
|
@@ -66,7 +66,7 @@ module ExportMongoS3
|
|
66
66
|
|
67
67
|
command = 'mongoexport'
|
68
68
|
command << " #{@connection_options}"
|
69
|
-
command << ' --csv'
|
69
|
+
command << ' --type=csv'
|
70
70
|
command << " --db '#{db}'"
|
71
71
|
command << " --collection '#{collection}'"
|
72
72
|
command << " --fields '#{fields.join(',')}'"
|
@@ -113,6 +113,11 @@ module ExportMongoS3
|
|
113
113
|
collection_settings.each do |collection|
|
114
114
|
|
115
115
|
name = collection['name']
|
116
|
+
|
117
|
+
if name.nil? || name == ''
|
118
|
+
raise "Not valid param <name: #{collection}>"
|
119
|
+
end
|
120
|
+
|
116
121
|
query = collection['query'].nil? || collection['query'] == '' ? nil : collection['query'].to_s
|
117
122
|
|
118
123
|
fields = if collection['fields'].is_a?(String)
|
@@ -121,11 +126,6 @@ module ExportMongoS3
|
|
121
126
|
[]
|
122
127
|
end
|
123
128
|
|
124
|
-
|
125
|
-
if name.nil? || name == ''
|
126
|
-
raise "Not valid param <name: #{collection}>"
|
127
|
-
end
|
128
|
-
|
129
129
|
prepared_settings[name] =
|
130
130
|
{
|
131
131
|
name: name,
|
@@ -12,6 +12,8 @@ export:
|
|
12
12
|
query: '{field1: { $gte: 3 }, field2: 'value1'}'
|
13
13
|
fields: field1, field2, field3
|
14
14
|
|
15
|
+
# Set zip compression level from 0(faster, just archives the file without any compression) to 9(slower, maximum compression)
|
16
|
+
compression_level: 6
|
15
17
|
|
16
18
|
# Temporary directory for files. Default: system temp directory
|
17
19
|
temp_directory:
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: export_mongo_s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yakupov Dima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: aws-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.57'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.57'
|
41
41
|
description: Command-line application for MongoDB export(mongoexport) to CSV and upload
|
@@ -47,7 +47,7 @@ executables:
|
|
47
47
|
extensions: []
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
-
- .gitignore
|
50
|
+
- ".gitignore"
|
51
51
|
- Gemfile
|
52
52
|
- README.md
|
53
53
|
- bin/export_mongo_s3
|
@@ -71,17 +71,17 @@ require_paths:
|
|
71
71
|
- lib
|
72
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.4.
|
84
|
+
rubygems_version: 2.4.5
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: Some summary
|