metacrunch 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 897ee8027975194e69d06b916f4602317eddf075
4
- data.tar.gz: 31311e170a4a84e6968e14bd189c36fc1cb8890f
3
+ metadata.gz: 071c720dfc2ad17aa71665f25579961eb1a0beea
4
+ data.tar.gz: 622e3192f6021da9e5851485b7fb9181ec75e2c6
5
5
  SHA512:
6
- metadata.gz: a92ccefea01550a5f664f744c760092a4e6165480684d3eba6833a9e62b74f638f1e5f588a6b666a1be238705a59f9dd1a0f3ee2afe13bfea404428613298dce
7
- data.tar.gz: cf6854080223578ff1819a4c802257b6a7fcdc74dcd2aa4c91df3adb90c2492d601b0d71bcce5c49fc318d4005eb02dda30110ced80cb89a8bd808f234450b1d
6
+ metadata.gz: 6fe42cf29e183659f667cfac082cebebee345ab199a4fd99dd175a0ea1716ea3a5b38b3a4ce9ab13c790a4dc03d4775d343d55fe0593b43ba10eaac5557654c9
7
+ data.tar.gz: f14bee54085db41b4ed15a6f551a9f6a1465541c896037a3674cafff4cbbab375574c0236b2e9c33b9c03e3fbef929d11e0aa473b11f4a8f763ef001c371e879
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
- require "bundler/gem_tasks"
2
1
  require "rspec/core/rake_task"
3
2
 
4
3
  RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,19 @@
1
+ require_relative "../writer"
2
+
3
+ class Metacrunch::File::Writer::PlainFileWriter
4
+ def self.supports?(filename)
5
+ true
6
+ end
7
+
8
+ def initialize(filename)
9
+ @io = File.open(filename, "w")
10
+ end
11
+
12
+ def close
13
+ @io.close
14
+ end
15
+
16
+ def write(options = {})
17
+ @io.write(options[:content])
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ require "rubygems/package"
2
+ require "zlib"
3
+ require_relative "../writer"
4
+
5
+ class Metacrunch::File::Writer::TarFileWriter
6
+ def self.supports?(filename)
7
+ !!filename[/\.tar\Z|\.tar\.gz\Z|\.tgz\Z/]
8
+ end
9
+
10
+ def initialize(filename)
11
+ @io = File.open(filename, "w")
12
+ @io = Zlib::GzipWriter.new(@io) if filename.end_with?("gz")
13
+ @tar_writer = Gem::Package::TarWriter.new(@io)
14
+ end
15
+
16
+ def close
17
+ @tar_writer.close
18
+ @io.close
19
+ end
20
+
21
+ def write(options = {})
22
+ @tar_writer.add_file_simple(options[:entry_name], 0644, options[:content].bytesize) do |_tar_entry|
23
+ _tar_entry.write(options[:content])
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ require "zip"
2
+ require_relative "../writer"
3
+
4
+ class Metacrunch::File::Writer::ZipFileWriter
5
+ def self.supports?(filename)
6
+ !!filename[/\.zip\Z/]
7
+ end
8
+
9
+ def self.write(*args)
10
+ end
11
+
12
+ =begin
13
+ def each
14
+ return enum_for(__method__) unless block_given?
15
+
16
+ Zip::File.open(@filename) do |_zip_file|
17
+ _zip_file.each do |_zip_entry|
18
+ unless _zip_entry.directory?
19
+ yield Metacrunch::File.new({
20
+ content: _zip_entry.get_input_stream.read,
21
+ entry_name: _zip_entry.name,
22
+ file_name: @filename
23
+ })
24
+ end
25
+ end
26
+ end
27
+ end
28
+ =end
29
+ end
@@ -0,0 +1,26 @@
1
+ require_relative "../file"
2
+ require_relative "../processor"
3
+
4
+ class Metacrunch::File::Writer < Metacrunch::Processor
5
+ require_relative "./writer/plain_file_writer"
6
+ require_relative "./writer/tar_file_writer"
7
+ require_relative "./writer/zip_file_writer"
8
+
9
+ def initialize(filename)
10
+ @writer =
11
+ [TarFileWriter, ZipFileWriter, PlainFileWriter].find do |_writer|
12
+ _writer.supports?(filename)
13
+ end
14
+ .try do |_appropriate_writer_class|
15
+ _appropriate_writer_class.new(filename)
16
+ end
17
+ end
18
+
19
+ def close
20
+ @writer.close
21
+ end
22
+
23
+ def write(*args)
24
+ @writer.write(*args)
25
+ end
26
+ end
@@ -2,6 +2,7 @@ require_relative "../metacrunch"
2
2
 
3
3
  class Metacrunch::File
4
4
  require_relative "./file/reader"
5
+ require_relative "./file/writer"
5
6
 
6
7
  attr_accessor :content
7
8
  attr_accessor :entry_name # equals file_name for plain files
@@ -1,3 +1,3 @@
1
1
  module Metacrunch
2
- VERSION = "2.2.2"
2
+ VERSION = "2.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metacrunch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Sprotte
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2015-09-25 00:00:00.000000000 Z
13
+ date: 2016-01-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -186,6 +186,10 @@ files:
186
186
  - lib/metacrunch/file/reader/scp_fetcher.rb
187
187
  - lib/metacrunch/file/reader/tar_file_reader.rb
188
188
  - lib/metacrunch/file/reader/zip_file_reader.rb
189
+ - lib/metacrunch/file/writer.rb
190
+ - lib/metacrunch/file/writer/plain_file_writer.rb
191
+ - lib/metacrunch/file/writer/tar_file_writer.rb
192
+ - lib/metacrunch/file/writer/zip_file_writer.rb
189
193
  - lib/metacrunch/file_reader.rb
190
194
  - lib/metacrunch/file_reader_entry.rb
191
195
  - lib/metacrunch/file_writer.rb
@@ -224,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
228
  version: '0'
225
229
  requirements: []
226
230
  rubyforge_project:
227
- rubygems_version: 2.4.8
231
+ rubygems_version: 2.5.1
228
232
  signing_key:
229
233
  specification_version: 4
230
234
  summary: Data processing toolkit for Ruby