fjords-client 0.0.6 → 1.0.1

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.
@@ -4,9 +4,10 @@ require 'addressable/uri'
4
4
  require 'tmpdir'
5
5
  require 'digest/md5'
6
6
  require 'pathname'
7
+ require "rbconfig"
7
8
 
8
9
  require "stripe"
9
- Stripe.api_key = 'pk_vfcVMdOHZGAFgqLGSEtlSKzsXeBYI'
10
+ Stripe.api_key = 'pk_NYJZbk2hGD8kHCGHLx15EHD5w7HPO'
10
11
 
11
12
  module Fjords
12
13
  class Token
@@ -35,6 +36,14 @@ module Fjords
35
36
  def host=(host)
36
37
  @_host = host
37
38
  end
39
+
40
+ def ruby_zip?
41
+ @_ruby_zip ||= false
42
+ end
43
+
44
+ def ruby_zip=(ruby_zip)
45
+ @_ruby_zip = ruby_zip
46
+ end
38
47
  end
39
48
 
40
49
  # Delegate methods
@@ -81,6 +90,8 @@ module Fjords
81
90
  class Conflict < ClientError; end
82
91
  class UploadTooLarge < ClientError; end
83
92
  class NothingToUpload < ClientError; end
93
+ class TooManyConnections < ClientError; end
94
+ class PreconditionFailed < ClientError; end
84
95
 
85
96
  attr_reader :username
86
97
 
@@ -261,8 +272,21 @@ module Fjords
261
272
 
262
273
  zip_excludes = excludes.map { |e| "-x \"#{e}\"" }.join(' ')
263
274
 
264
- Dir.chdir(path) do
265
- puts `zip -y -q -r #{zipfile} . #{zip_excludes}`
275
+ if self.class.ruby_zip?
276
+ require 'zip/zipfilesystem'
277
+
278
+ ::Zip::ZipFile::open(zipfile, true) do |zf|
279
+ get_file_paths(dir).each do |f|
280
+ zf.add(f.sub("#{path}/",''), f)
281
+ end
282
+ end
283
+ else
284
+ to_null = !!(RbConfig::CONFIG['host_os'] =~ /mingw|mswin32|cygwin/) ? 'nul' : '/dev/null'
285
+
286
+ Dir.chdir(path) do
287
+ `zip -y -q -r #{zipfile} . #{zip_excludes} 2> #{to_null}`
288
+ # return unless $? != 0
289
+ end
266
290
  end
267
291
 
268
292
  [zipfile, changeless]
@@ -336,6 +360,12 @@ module Fjords
336
360
  raise Conflict.new(e)
337
361
  rescue RestClient::Forbidden => e
338
362
  raise Forbidden.new(e)
363
+ rescue RestClient::TooManyConnectionsFromThisIP => e
364
+ raise TooManyConnections.new(e)
365
+ rescue RestClient::PreconditionFailed => e
366
+ # Bad token
367
+ remove_token if token
368
+ raise PreconditionFailed.new(e)
339
369
  rescue Errno::ECONNREFUSED => e
340
370
  raise ConnectionRefused.new(e)
341
371
  rescue Exception => e
@@ -1,5 +1,5 @@
1
1
  module Fjords
2
2
  class Client
3
- VERSION = "0.0.6"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fjords-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-28 00:00:00.000000000 Z
12
+ date: 2013-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  segments:
91
91
  - 0
92
- hash: 1471701448195210841
92
+ hash: 3275000126563766821
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  segments:
100
100
  - 0
101
- hash: 1471701448195210841
101
+ hash: 3275000126563766821
102
102
  requirements: []
103
103
  rubyforge_project:
104
104
  rubygems_version: 1.8.23