blockspring 0.1.1 → 0.1.2

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: c742bc005dd2cd402d34a17b507e60f8c72753af
4
- data.tar.gz: e0d6b60af2996aba8cbaa412975b8f4dfd72bf6c
3
+ metadata.gz: 302eceaf4796ab9ca3e0195c35423805ed1864ac
4
+ data.tar.gz: 28fe7c7021613c6363c2f976cee039268fced591
5
5
  SHA512:
6
- metadata.gz: 78c740aad38e1860790d5147849c037456cac347b912e5a89f5df4bfd4fa52d4e04ba41bd30cc7af1493bc69b687be131d5d1f918939e2ceb150d942f5727d61
7
- data.tar.gz: f58698472924808c1f0362cd9cbe94fcd62babe2068d7c11d5096b982dbe7f7ba40c695d83a3c6149fcd50f08a9d43c2174d073158abdc06da0e21d37d2c7855
6
+ metadata.gz: 9ae88098f14fd0a23e376215b7187943809e617f20f2c74260cbb20e7309c3e3b388a3e2acfc2d40bd59662bfc22efde76752ff50575ac120bc1cf997c82847d
7
+ data.tar.gz: 04a3c95352d8fbad28befe81671a62a7c301f3681672f934100e799b51fdef1fc04605f4bf6aca8374190941122bdb28e4077d5f2636f8f84aab255ccc823dfd
@@ -1,3 +1,3 @@
1
1
  module Blockspring
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/blockspring.rb CHANGED
@@ -77,18 +77,33 @@ module Blockspring
77
77
  return @request
78
78
  end
79
79
 
80
- def self.run(block, data = {}, api_key = nil )
80
+ def self.run(block, data = {}, options = {})
81
+ if (options.is_a?(String))
82
+ options = {
83
+ "api_key" => options,
84
+ "cache" => false,
85
+ "expiry" => 0
86
+ }
87
+ end
88
+
89
+ unless (options.has_key?("api_key"))
90
+ options["api_key"] = nil
91
+ end
92
+
81
93
  if !(data.is_a?(Hash))
82
94
  raise "your data needs to be a dictionary."
83
95
  end
84
96
 
85
97
  data = data.to_json
86
- api_key = api_key || ENV['BLOCKSPRING_API_KEY'] || ""
98
+ api_key = options["api_key"] || ENV['BLOCKSPRING_API_KEY'] || ""
99
+ cache = options.has_key?("cache") ? options["cache"] : false
100
+ expiry = options.has_key?("expiry") ? options["expiry"] : nil
101
+
87
102
  blockspring_url = ENV['BLOCKSPRING_URL'] || 'https://sender.blockspring.com'
88
103
  block = block.split("/")[-1]
89
104
 
90
105
  begin
91
- response = RestClient.post "#{blockspring_url}/api_v2/blocks/#{block}?api_key=#{api_key}", data, :content_type => :json
106
+ response = RestClient.post "#{blockspring_url}/api_v2/blocks/#{block}?api_key=#{api_key}&cache=#{cache}&expiry=#{expiry}", data, :content_type => :json
92
107
  rescue => e
93
108
  response = e.response
94
109
  end
@@ -102,18 +117,31 @@ module Blockspring
102
117
  end
103
118
  end
104
119
 
105
- def self.runParsed(block, data = {}, api_key = nil )
120
+ def self.runParsed(block, data = {}, options = {})
121
+ if (options.is_a?(String))
122
+ options = {
123
+ "api_key" => options
124
+ }
125
+ end
126
+
127
+ unless (options.has_key?("api_key"))
128
+ options["api_key"] = nil
129
+ end
130
+
106
131
  if !(data.is_a?(Hash))
107
132
  raise "your data needs to be a dictionary."
108
133
  end
109
134
 
110
135
  data = data.to_json
111
- api_key = api_key || ENV['BLOCKSPRING_API_KEY'] || ""
136
+ api_key = options["api_key"] || ENV['BLOCKSPRING_API_KEY'] || ""
137
+ cache = options.has_key?("cache") ? options["cache"] : false
138
+ expiry = options.has_key?("expiry") ? options["expiry"] : nil
139
+
112
140
  blockspring_url = ENV['BLOCKSPRING_URL'] || 'https://sender.blockspring.com'
113
141
  block = block.split("/")[-1]
114
142
 
115
143
  begin
116
- response = RestClient.post "#{blockspring_url}/api_v2/blocks/#{block}?api_key=#{api_key}", data, :content_type => :json
144
+ response = RestClient.post "#{blockspring_url}/api_v2/blocks/#{block}?api_key=#{api_key}&cache=#{cache}&expiry=#{expiry}", data, :content_type => :json
117
145
  rescue => e
118
146
  response = e.response
119
147
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blockspring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Don Pinkus
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-20 00:00:00.000000000 Z
13
+ date: 2015-02-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler