runcible 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -82,7 +82,7 @@ module Runcible
82
82
 
83
83
  args = [method]
84
84
  args << generate_payload(options) if [:post, :put].include?(method)
85
- args << headers
85
+ args << headers
86
86
 
87
87
  response = get_response(client, path, *args)
88
88
  process_response(response)
@@ -112,17 +112,25 @@ module Runcible
112
112
  end
113
113
 
114
114
  def generate_payload(options)
115
- if options[:payload]
116
- if options[:payload][:optional]
117
- if options[:payload][:required]
118
- payload = options[:payload][:required].merge(options[:payload][:optional])
115
+ if options[:payload].is_a?(String)
116
+ return options[:payload]
117
+ elsif options[:payload].is_a?(Hash)
118
+ format_payload_json(options[:payload])
119
+ end
120
+ end
121
+
122
+ def format_payload_json(payload_hash)
123
+ if payload_hash
124
+ if payload_hash[:optional]
125
+ if payload_hash[:required]
126
+ payload = payload_hash[:required].merge(payload_hash[:optional])
119
127
  else
120
- payload = options[:payload][:optional]
128
+ payload = payload_hash[:optional]
121
129
  end
122
- elsif options[:payload][:delta]
123
- payload = options[:payload]
130
+ elsif payload_hash[:delta]
131
+ payload = payload_hash
124
132
  else
125
- payload = options[:payload][:required]
133
+ payload = payload_hash[:required]
126
134
  end
127
135
  else
128
136
  payload = {}
@@ -137,7 +137,13 @@ module Runcible
137
137
  units.each do |unit|
138
138
  content_unit = {}
139
139
  content_unit[:type_id] = type_id
140
- content_unit[:unit_key] = { unit_key => unit }
140
+ if unit.is_a?(Hash)
141
+ #allow user to pass in entire unit
142
+ content_unit[:unit_key] = unit
143
+ else
144
+ content_unit[:unit_key] = { unit_key => unit }
145
+ end
146
+
141
147
  content.push(content_unit)
142
148
  end
143
149
  end
@@ -50,8 +50,7 @@ module Runcible
50
50
  # @param [File] content content of the file being uploaded to the server
51
51
  # @return [RestClient::Response] none
52
52
  def upload_bits(upload_id, offset, content)
53
- required = required_params(binding.send(:local_variables), binding)
54
- call(:put, path("#{upload_id}/#{offset}/"), :payload => { :required => required })
53
+ call(:put, path("#{upload_id}/#{offset}/"), :payload => content)
55
54
  end
56
55
 
57
56
  # Import into a repository
@@ -1,3 +1,3 @@
1
1
  module Runcible
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runcible
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:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-21 00:00:00.000000000 Z
12
+ date: 2013-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json