metaforce 1.0.5 → 1.0.6

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.
data/README.md CHANGED
@@ -9,9 +9,17 @@ and [Services](http://www.salesforce.com/us/developer/docs/api/index.htm) APIs.
9
9
 
10
10
  ## Installation
11
11
 
12
- ```bash
13
- gem install metaforce
14
- ```
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'metaforce'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install metaforce
15
23
 
16
24
  ## Usage
17
25
 
@@ -14,6 +14,10 @@ module Metaforce
14
14
  @services ||= Metaforce::Services::Client.new(@options)
15
15
  end
16
16
 
17
+ def inspect
18
+ "#<#{self.class} @options=#{@options.inspect}>"
19
+ end
20
+
17
21
  def method_missing(method, *args, &block)
18
22
  if metadata.respond_to? method, false
19
23
  metadata.send(method, *args, &block)
@@ -64,27 +64,37 @@ module Metaforce
64
64
  # Returns self.
65
65
  def extract_to(destination)
66
66
  return on_complete { |job| job.extract_to(destination) } unless started?
67
- Zip::ZipFile.open(tmp_zip_file) do |zip|
67
+ with_tmp_zip_file do |file|
68
+ unzip(file, destination)
69
+ end
70
+ self
71
+ end
72
+
73
+ private
74
+
75
+ # Internal: Unzips source to destination.
76
+ def unzip(source, destination)
77
+ Zip::ZipFile.open(source) do |zip|
68
78
  zip.each do |f|
69
79
  path = File.join(destination, f.name)
70
80
  FileUtils.mkdir_p(File.dirname(path))
71
81
  zip.extract(f, path) { true }
72
82
  end
73
83
  end
74
- self
75
84
  end
76
85
 
77
- private
78
-
79
86
  # Internal: Writes the zip file content to a temporary location so it can
80
87
  # be extracted.
81
- def tmp_zip_file
82
- @tmp_zip_file ||= begin
83
- file = Tempfile.new('retrieve')
88
+ def with_tmp_zip_file
89
+ file = Tempfile.new('retrieve')
90
+ begin
91
+ file.binmode
84
92
  file.write(zip_file)
85
- path = file.path
93
+ file.rewind
94
+ yield file
95
+ ensure
86
96
  file.close
87
- path
97
+ file.unlink
88
98
  end
89
99
  end
90
100
 
@@ -9,6 +9,10 @@ module Metaforce
9
9
 
10
10
  endpoint :metadata_server_url
11
11
  wsdl Metaforce.configuration.metadata_wsdl
12
+
13
+ def inspect
14
+ "#<#{self.class} @options=#{@options.inspect}>"
15
+ end
12
16
  end
13
17
  end
14
18
  end
@@ -60,6 +60,10 @@ module Metaforce
60
60
  .select { |p| p.picklist_name == field }.first.picklist_values
61
61
  .select { |p| p.active }.collect { |p| [ p.label, p.value ] }
62
62
  end
63
+
64
+ def inspect
65
+ "#<#{self.class} @options=#{@options.inspect}>"
66
+ end
63
67
  end
64
68
  end
65
69
  end
@@ -1,3 +1,3 @@
1
1
  module Metaforce
2
- VERSION = '1.0.5'
2
+ VERSION = '1.0.6'
3
3
  end
@@ -31,4 +31,9 @@ describe Metaforce::Client do
31
31
  end
32
32
  end
33
33
  end
34
+
35
+ describe '.inspect' do
36
+ subject { client.inspect }
37
+ it { should eq '#<Metaforce::Client @options={:session_id=>"foobar"}>' }
38
+ end
34
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metaforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-05 00:00:00.000000000 Z
13
+ date: 2013-02-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: savon