jobba 1.0.0 → 1.0.1

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: 5188a37939c0f9b306f0d98e01dfb9abf6ef3a31
4
- data.tar.gz: 9cc2a58ff46d55c13aa25bec9e98b395916fd13b
3
+ metadata.gz: f867ae880d3339b25e987267ac135429ee2fb80e
4
+ data.tar.gz: 3882b0e610200fe6b2c119dc46efe37261dea455
5
5
  SHA512:
6
- metadata.gz: 8f6d7780ac4361ba25a5f73f4a1df1746c6954e947497fcb6e1f97d6b9d5c360d891835fd12cb2f09f52c557d9abc304a881b5fd3e40131c3ad7521a812d1a6a
7
- data.tar.gz: e7fec3fbfd1e73496816907efbc28723daa1d148180b1cda7e71ec47ec176a5cbf4280be40491b751ed59a86a7fe35d7736a146b902dfe3a9a85851c90fcf8b9
6
+ metadata.gz: 369cddf40dd02571641bd114043f8f70f74ba6b0803d191893a79f7375c40bfaa8114436fbabcbc95986d231491d4f86979af90564e8b284608f7cdad46b5553
7
+ data.tar.gz: 966e2fc051cd4d8c5f5c9a2abebb4286aa9960cfad46d77ca52bdbe06351bf92945963c1c3d7d0cf9694b3fe6b84ccfe7b0610cef169a125dbbfb1aaa251cbe4
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # jobba
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/jobba.svg)](http://badge.fury.io/rb/jobba)
3
4
  [![Build Status](https://travis-ci.org/openstax/jobba.svg?branch=master)](https://travis-ci.org/openstax/jobba)
4
5
  [![Code Climate](https://codeclimate.com/github/openstax/jobba/badges/gpa.svg)](https://codeclimate.com/github/openstax/jobba)
5
6
 
@@ -145,6 +146,8 @@ my_status.save({a: 'blah', b: [1,2,3]})
145
146
  my_status.save("some string")
146
147
  ```
147
148
 
149
+ Note that if you `save` a hash with symbol keys it will be converted to string keys. In fact, any argument passed in to `save` will be converted to JSON and parsed back so that the `data` attribute returns the same thing regardless of if `data` is retrieved immediately after being set or after being loaded from Redis.
150
+
148
151
  ## Setting Job Name and Arguments
149
152
 
150
153
  If you want to be able to query for all statuses for a certain kind of job, you can set the job's name in the status:
data/lib/jobba/status.rb CHANGED
@@ -128,7 +128,8 @@ module Jobba
128
128
  # end
129
129
 
130
130
  def save(data)
131
- set(data: data)
131
+ normalized_data = JSON.parse(data.to_json, quirks_mode: true)
132
+ set(data: normalized_data)
132
133
  end
133
134
 
134
135
  def delete
@@ -193,16 +194,12 @@ module Jobba
193
194
 
194
195
  @json_encoded_attrs = attrs[:raw]
195
196
 
196
- if !@json_encoded_attrs.nil? && !@json_encoded_attrs.empty?
197
- @json_encoded_attrs['data'] ||= "{}"
198
- @json_encoded_attrs['job_args'] ||= "{}"
199
- else
197
+ if @json_encoded_attrs.nil? || @json_encoded_attrs.empty?
200
198
  @id = attrs[:id] || attrs['id'] || SecureRandom.uuid
201
199
  @state = attrs[:state] || attrs['state'] || State::UNKNOWN
202
200
  @progress = attrs[:progress] || attrs['progress'] || 0
203
201
  @errors = attrs[:errors] || attrs['errors'] || []
204
202
  @data = attrs[:data] || attrs['data'] || {}
205
- @job_args = OpenStruct.new # TODO need this and the above job args init?
206
203
 
207
204
  if attrs[:persist]
208
205
  redis.multi do
@@ -249,9 +246,7 @@ module Jobba
249
246
 
250
247
  def set_hash_in_redis(hash)
251
248
  redis_key_value_array =
252
- hash.to_a
253
- .collect{|kv_array| [kv_array[0], kv_array[1].to_json]}
254
- .flatten(1)
249
+ hash.to_a.flat_map{|kv_array| [kv_array[0], kv_array[1].to_json]}
255
250
 
256
251
  Jobba.redis.hmset(job_key, *redis_key_value_array)
257
252
  end
data/lib/jobba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jobba
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobba
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky