sinderella 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1813bf663a9701a435caba5b1b3eab7769b247cc
4
- data.tar.gz: d70679fededf9482ba94a5cc0e4a25629539c285
3
+ metadata.gz: 39abb1c105e591f8898213b99b255d6a89f24954
4
+ data.tar.gz: 26d03bef0214e7800a626e470e04e715e2a41f20
5
5
  SHA512:
6
- metadata.gz: c987c2e6411c2e4085b5aac74d734ffdddd9702a74a2eec489defe338e091a540d8d928cdfb7649102c364f6c49de973d4f41dfa88143d70de44093caf6a16cd
7
- data.tar.gz: ddece4bd51bd34cd6d319c32c33fb8bebb8acf856b8dd0e2735da2b673fe4a9e5cf672bd2a4b2243aaa61e05f32cee8b736e8819b0a773ffb437cfeb43b1f7e1
6
+ metadata.gz: ac8a4eeef9c743682f312735bae50016345d776bb19f3c019290e67aca39088c724ed5a49055d2aeb9fabe0a98e5c41bf5b00688df38753a7753377ae48cb33c
7
+ data.tar.gz: 40048e55198f175968c588bcd817306d095688dd34e1dcfd0a6e65a30e86a99664fbcac1b0e0b3308af9c01d1ce700eed5480fdd69f4c2307aa0d4dd3435c4e5
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Sinderella
2
2
 
3
- [![Build Status](https://travis-ci.org/Integralist/Sinderella.png?branch=master)](https://travis-ci.org/Integralist/Sinderella)
3
+ [![Build Status](https://travis-ci.org/Integralist/Sinderella.png?branch=master)](https://travis-ci.org/Integralist/Sinderella) [![Gem Version](https://badge.fury.io/rb/sinderella.png)](http://badge.fury.io/rb/sinderella)
4
4
 
5
5
  Ruby gem which will allow authors to pass a code block to transform a data object for a specific period of time.
6
6
 
@@ -27,16 +27,32 @@ Or install it yourself as:
27
27
  ## Usage
28
28
 
29
29
  ```ruby
30
+ require 'sinderella'
31
+
30
32
  data = { :key => 'value' }
31
- till_midnight = 60 * 60 # 1hr
33
+ till_midnight = 60 # 1 minute
32
34
 
33
35
  id = Sinderella.transforms(data, till_midnight) do |data|
34
36
  data.each do |key, value|
35
- data.tap { |d| d[key].upcase! } # convert data to uppercase
37
+ data.tap { |d| d[key].upcase! }
36
38
  end
37
- end # returns a hash of the data to use as an id/key
39
+ end
40
+
41
+ puts Sinderella.get(id)
42
+
43
+ # we'll randomly reset the data before the time expires...
44
+ puts "Resetting data early" and Sinderella.midnight(id) if (rand() * 2).to_i == 1
45
+
46
+ sleep 10
47
+
48
+ # if reset early == { :key => 'value' }
49
+ # if not reset early == { :key => 'VALUE' }
50
+ puts Sinderella.get(id)
51
+
52
+ sleep 60
38
53
 
39
- Sinderella.midnight(id) # reset the data ahead of schedule
54
+ # time has expired by this point so == { :key => 'value' }
55
+ puts Sinderella.get(id)
40
56
  ```
41
57
 
42
58
  ## Contributing
@@ -38,7 +38,7 @@ module Sinderella
38
38
  end
39
39
 
40
40
  def self.check(id, seconds)
41
- Thread.new { sleep seconds; reset_data_at id }.join
41
+ Thread.new { sleep seconds; reset_data_at id }
42
42
  end
43
43
 
44
44
  def self.reset_data_at(id)
@@ -1,3 +1,3 @@
1
1
  module Sinderella
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -32,6 +32,7 @@ describe Sinderella do
32
32
  context 'past midnight (after time expired)' do
33
33
  it 'returns the original data' do
34
34
  create_new_instance
35
+ Sinderella.reset_data_at @id
35
36
  expect(subject.get(@id)).to eq({ :key => 'value' })
36
37
  end
37
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinderella
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Integralist