datapimp 1.0.13 → 1.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f92a9f500550b9bf611651ec9269f1f1022b50aa
4
- data.tar.gz: 8513b18bb3c76b1ea20e3eb91d532f8f37976994
3
+ metadata.gz: fe14e7bc0d6be32f769b6fac511147dc2cef501d
4
+ data.tar.gz: 470fdf3998730258b25faec69bffca68b7db465d
5
5
  SHA512:
6
- metadata.gz: c59ce1165293766f89ed019f6862e39cfc8097c39efe7e152918b512a88605197b8aaa3dcee138655bb1ba42a6f7610a13b45692f6f2ee56886bb83fba59d0ed
7
- data.tar.gz: 761f03f731d979fdae3760884eb5954c8f4b0de1179a71d85bb3577b04abbde1693ee076c6aeda3de1159a68046a73504e816619b4994ee2c20b7a74acd66cf7
6
+ metadata.gz: 15440f01cee38dd52a4256c73796302a0ffd732de8c5b42dd43f2531c3794e8ff12ed1f078146dc660718b5fd575b7ce09d90d0546192bb93ed3ae32763fc8e0
7
+ data.tar.gz: 2ba18490dac8bc77d4ccc57eb76482c87ad8381f3e7ec21ff9e00a823197af66c0ba6ecaddf1599aa7bca8ed773dd99d8bc5acee41ca482040908ed25b804118
data/bin/datapimp CHANGED
@@ -1,16 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- begin
4
- require "bundler"
5
- Bundler.require
6
- rescue
7
- require "rubygems"
8
- end
9
-
10
- $:.unshift Pathname(File.dirname(__FILE__)).join("..","lib")
3
+ require "rubygems"
4
+ require "bundler"
11
5
 
12
6
  require "pathname"
13
7
  require "pry"
8
+ require "hashie"
14
9
  require "commander/import"
15
10
  require 'datapimp'
16
11
  require 'datapimp/cli'
@@ -32,6 +32,10 @@ module Datapimp
32
32
  google_access_token: ''
33
33
  }
34
34
 
35
+ def current(using_environment = true)
36
+ @current ||= calculate_config(using_environment)
37
+ end
38
+
35
39
  def self.method_missing(meth, *args, &block)
36
40
  if instance.respond_to?(meth)
37
41
  return instance.send meth, *args, &block
@@ -123,13 +127,14 @@ module Datapimp
123
127
  DefaultSettings.dup
124
128
  end
125
129
 
126
- def current(using_environment = true)
127
- @current ||= calculate_config(using_environment)
128
- end
129
-
130
130
  def calculate_config(using_environment = true)
131
131
  @current = defaults.merge(home_config.merge(cwd_config.merge(applied_config))).to_mash
132
132
 
133
+ if ENV['DATAPIMP_CONFIG_EXTRA'].to_s.length > 0
134
+ extra_config = Datapimp::Util.load_config_file(ENV['DATAPIMP_CONFIG_EXTRA'])
135
+ @current.merge!(extra_config) if extra_config.is_a?(Hash)
136
+ end
137
+
133
138
  (defaults.keys + home_config.keys + cwd_config.keys).uniq.each do |key|
134
139
  upper = key.to_s.upcase
135
140
  if ENV[upper]
@@ -1,3 +1,4 @@
1
+ require 'logger'
1
2
  module Datapimp
2
3
  module Logging
3
4
  def log(*args)
@@ -73,6 +73,7 @@ module Datapimp
73
73
  end
74
74
 
75
75
  def run_push_action(options={})
76
+ require 'rack' unless defined?(::Rack)
76
77
  entries = Dir[local_path.join('**/*')].map(&:to_pathname)
77
78
  prepare_manifest_for(entries)
78
79
 
@@ -90,19 +91,22 @@ module Datapimp
90
91
  next
91
92
  end
92
93
 
94
+ content_type = Rack::Mime.mime_type(File.extname(destination.split("/").last))
95
+
93
96
  if existing = s3.files.get(destination)
94
97
  if existing.etag == fingerprint
95
98
  log "Skipping #{ destination }: similar etag"
96
99
  else
97
100
  existing.body = entry.read
98
101
  existing.acl = 'public-read'
99
- log "Updated #{ destination }"
102
+ existing.content_type = content_type
103
+ log "Updated #{ destination }; content-type: #{ content_type }"
100
104
  uploaded << destination
101
105
  existing.save
102
106
  end
103
107
  else
104
- log "Uploaded #{ destination }"
105
- s3.files.create(key: destination, body: entry.read, acl: 'public-read')
108
+ log "Uploaded #{ destination }; content-type: #{ content_type }"
109
+ s3.files.create(key: destination, body: entry.read, acl: 'public-read', content_type: content_type)
106
110
  uploaded << destination
107
111
  end
108
112
 
@@ -0,0 +1,16 @@
1
+ module Datapimp
2
+ module Util
3
+ def self.load_config_file(at_path)
4
+ at_path = Pathname(at_path)
5
+ extension = at_path.extname.to_s.downcase
6
+
7
+ raise 'No config file exists at: ' + at_path.to_s unless at_path.exist?
8
+
9
+ if extension == '.yml' || extension == '.yaml'
10
+ YAML.load_file(at_path)
11
+ elsif extension == '.json'
12
+ JSON.parse(at_path.read)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Datapimp
2
- VERSION = "1.0.13"
2
+ VERSION = "1.0.14"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datapimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Soeder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-01 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -409,6 +409,7 @@ files:
409
409
  - lib/datapimp/sync/dropbox_folder.rb
410
410
  - lib/datapimp/sync/google_drive_folder.rb
411
411
  - lib/datapimp/sync/s3_bucket.rb
412
+ - lib/datapimp/util.rb
412
413
  - lib/datapimp/version.rb
413
414
  - packaging/wrapper.sh
414
415
  - spec/spec_helper.rb
@@ -444,7 +445,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
444
445
  version: '0'
445
446
  requirements: []
446
447
  rubyforge_project:
447
- rubygems_version: 2.2.2
448
+ rubygems_version: 2.4.5
448
449
  signing_key:
449
450
  specification_version: 4
450
451
  summary: A collection of API development patterns that I have accumulated in my career
@@ -452,3 +453,4 @@ summary: A collection of API development patterns that I have accumulated in my
452
453
  test_files:
453
454
  - spec/spec_helper.rb
454
455
  - spec/support/test_helpers.rb
456
+ has_rdoc: