quantum_leap 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6573232468bb00173ef5a5a8fe561cf3c6ae83ea
4
+ data.tar.gz: 0b018140dab2a5467d6bd9e568b5ae3983a3db7b
5
+ SHA512:
6
+ metadata.gz: c119021b8581adceffa56fcf3fa0e4189d04311225afe6994d0d8d943133bf09b3081451bbc165cab99bead20af020c2eaebae7187d1abac15d1cd3e500c7da7
7
+ data.tar.gz: e178a8a69e594a46fa5c8883cc363543211b50f098c9bd1460c0df43d4d92ac543e66d314d9bf8306202b5d0a9e1eff63b15b897bc0ab0bedb2f9551254feb88
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Matthew Conway
1
+ Copyright (c) 2014 Matthew Conway
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # QuantumLeap
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/mattonrails/quantum_leap.png?branch=master)](http://travis-ci.org/mattonrails/quantum_leap)
4
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/mattonrails/quantum_leap)
3
+ [![Build Status](https://travis-ci.org/mattreduce/quantum_leap.svg?branch=master)](https://travis-ci.org/mattreduce/quantum_leap)
4
+ [![Code Climate](https://codeclimate.com/github/mattreduce/quantum_leap/badges/gpa.svg)](https://codeclimate.com/github/mattreduce/quantum_leap)
5
5
 
6
6
  Righting wrongs in your test suite with time travel!
7
7
 
data/lib/quantum.rb CHANGED
@@ -1,9 +1,36 @@
1
1
  require 'quantum_leap'
2
2
 
3
+ # Public: Quantum is the public-facing interface to the library.
4
+ #
5
+ # Examples
6
+ #
7
+ # Quantum.leap(Time.new(1956, 9, 13))
8
+ # # => 1956-09-13 00:00:00 -0700
9
+ #
10
+ # Quantum.leap_back
11
+ # # => 2013-05-20 21:55:54 -0700
12
+ #
13
+ # Quantum.leap(Time.new(1974, 10, 24)) do
14
+ # puts Time.now
15
+ # end
3
16
  class Quantum
4
- INITIAL_LEAP = Time.new(1956, 9, 13, 15, 00)
5
-
6
- def self.leap(time = INITIAL_LEAP)
17
+ # Public: Change the current time to a specific point in the past or future.
18
+ # You can change the time temporarily by specifying a block; time is
19
+ # unchanged outside the context of the block.
20
+ #
21
+ # time - The Time to leap to (default: 1956-09-13 00:00:00).
22
+ #
23
+ # Examples
24
+ #
25
+ # Quantum.leap(Time.new(1956, 9, 13))
26
+ # # => 1956-09-13 00:00:00 -0700
27
+ #
28
+ # Quantum.leap(Time.new(1974, 10, 24)) do
29
+ # puts Time.now
30
+ # end
31
+ #
32
+ # Returns the current time.
33
+ def self.leap(time = QuantumLeap::INITIAL_LEAP)
7
34
  QuantumLeap::Accelerator.mock_current_time(time)
8
35
  if block_given?
9
36
  begin
@@ -15,6 +42,9 @@ class Quantum
15
42
  return Time.now
16
43
  end
17
44
 
45
+ # Public: Return to the present time.
46
+ #
47
+ # Returns the current time.
18
48
  def self.leap_back
19
49
  QuantumLeap::Accelerator.reset
20
50
  Time.now
@@ -1,25 +1,87 @@
1
1
  require 'quantum_leap'
2
2
 
3
3
  module QuantumLeap
4
+ # Internal: The main module for methods that manipulate time, and provide
5
+ # interfaces to the custom time.
6
+ #
7
+ # All methods are module methods and should be called on the
8
+ # QuantumLeap::Accelerator module.
9
+ #
10
+ # Examples
11
+ #
12
+ # QuantumLeap::Accelerator.mock_current_time(Time.new(1956, 9, 13))
13
+ # # => [1788820900.589824]
14
+ #
15
+ # QuantumLeap::Accelerator.time_travel_offsets
16
+ # # => [1788820900.589824]
17
+ #
18
+ # QuantumLeap::Accelerator.now
19
+ # # => 1956-09-13 00:00:01 -0700
20
+ #
21
+ # QuantumLeap::Accelerator.date
22
+ # # => #<Date: 1956-09-13 ((2435730j,0s,0n),+0s,2299161j)>
23
+ #
24
+ # QuantumLeap::Accelerator.reset
25
+ # # => []
4
26
  module Accelerator
5
27
  extend self
6
28
 
29
+ # Internal: Return or initialize the stack of time offsets as Floats.
30
+ #
31
+ # Examples
32
+ #
33
+ # QuantumLeap::Accelerator.time_travel_offsets
34
+ # # => [1788820900.589824]
35
+ #
36
+ # Returns an empty Array or an Array of Floats.
7
37
  def time_travel_offsets
8
38
  @time_travel_offsets ||= []
9
39
  end
10
40
 
41
+ # Internal: Empties the stack of time offsets, effectively resetting the
42
+ # current time to the actual time.
43
+ #
44
+ # Returns an empty Array.
11
45
  def reset
12
46
  @time_travel_offsets = []
13
47
  end
14
48
 
49
+ # Internal: Add to the stack of time offsets the difference between the
50
+ # actual current time, and the desired new time.
51
+ #
52
+ # new_time - The past or future Time to leap to.
53
+ #
54
+ # Examples
55
+ #
56
+ # QuantumLeap::Accelerator.mock_current_time(Time.new(1956, 9, 13))
57
+ # # => [1788820900.589824]
58
+ #
59
+ # Returns the stack of time offsets, an Array of Floats.
15
60
  def mock_current_time(new_time)
16
61
  time_travel_offsets.push(Time.now - new_time)
17
62
  end
18
63
 
64
+ # Internal: Provide the mocked time by applying all offsets to the actual
65
+ # current time.
66
+ #
67
+ # Examples
68
+ #
69
+ # QuantumLeap::Accelerator.now
70
+ # # => 1956-09-13 00:00:01 -0700
71
+ #
72
+ # Returns the mocked current Time.
19
73
  def now
20
74
  Time.really_now - time_travel_offsets.inject(0, :+)
21
75
  end
22
76
 
77
+ # Internal: Converts the current mocked Time to a Date object.
78
+ #
79
+ # Examples
80
+ #
81
+ # QuantumLeap::Accelerator.date
82
+ # # => #<Date: 1956-09-13 ((2435730j,0s,0n),+0s,2299161j)>
83
+ #
84
+ # Returns the mocked current Date.
23
85
  def date
24
86
  now.to_date
25
87
  end
@@ -1,3 +1,3 @@
1
1
  module QuantumLeap
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
data/lib/quantum_leap.rb CHANGED
@@ -3,5 +3,10 @@ require 'quantum_leap/version'
3
3
  require 'quantum_leap/core_ext/date'
4
4
  require 'quantum_leap/core_ext/time'
5
5
 
6
+ module QuantumLeap
7
+ # Internal: Default time to replace the real current time with.
8
+ INITIAL_LEAP = Time.new(1956, 9, 13, 15, 00)
9
+ end
10
+
6
11
  require 'quantum_leap/accelerator'
7
12
  require 'quantum'
data/quantum_leap.gemspec CHANGED
@@ -2,16 +2,18 @@
2
2
  require File.expand_path('../lib/quantum_leap/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Matthew Conway"]
6
- gem.email = ["mattonrails@shortmail.com"]
5
+ gem.name = "quantum_leap"
7
6
  gem.description = %q{Righting wrongs in your test suite with time travel!}
8
7
  gem.summary = %q{Lets you change the current time in your tests}
9
- gem.homepage = "http://mattonrails.github.com/quantum_leap/"
8
+
9
+ gem.authors = ["Matthew Conway"]
10
+ gem.license = 'MIT'
11
+ gem.email = ["himself@mattonrails.com"]
12
+ gem.homepage = "https://mattreduce.github.io/quantum_leap/"
10
13
 
11
14
  gem.files = `git ls-files`.split($\)
12
15
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "quantum_leap"
15
17
  gem.require_paths = ["lib"]
16
18
  gem.version = QuantumLeap::VERSION
17
19
 
metadata CHANGED
@@ -1,41 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quantum_leap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
5
- prerelease:
4
+ version: 0.7.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matthew Conway
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-21 00:00:00.000000000 Z
11
+ date: 2014-11-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  description: Righting wrongs in your test suite with time travel!
31
28
  email:
32
- - mattonrails@shortmail.com
29
+ - himself@mattonrails.com
33
30
  executables: []
34
31
  extensions: []
35
32
  extra_rdoc_files: []
36
33
  files:
37
- - .gitignore
38
- - .travis.yml
34
+ - ".gitignore"
35
+ - ".travis.yml"
39
36
  - CONTRIBUTING.md
40
37
  - Gemfile
41
38
  - LICENSE
@@ -50,35 +47,29 @@ files:
50
47
  - quantum_leap.gemspec
51
48
  - spec/quantum_spec.rb
52
49
  - spec/spec_helper.rb
53
- homepage: http://mattonrails.github.com/quantum_leap/
54
- licenses: []
50
+ homepage: https://mattreduce.github.io/quantum_leap/
51
+ licenses:
52
+ - MIT
53
+ metadata: {}
55
54
  post_install_message:
56
55
  rdoc_options: []
57
56
  require_paths:
58
57
  - lib
59
58
  required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
59
  requirements:
62
- - - ! '>='
60
+ - - ">="
63
61
  - !ruby/object:Gem::Version
64
62
  version: '0'
65
- segments:
66
- - 0
67
- hash: 781284437395688069
68
63
  required_rubygems_version: !ruby/object:Gem::Requirement
69
- none: false
70
64
  requirements:
71
- - - ! '>='
65
+ - - ">="
72
66
  - !ruby/object:Gem::Version
73
67
  version: '0'
74
- segments:
75
- - 0
76
- hash: 781284437395688069
77
68
  requirements: []
78
69
  rubyforge_project:
79
- rubygems_version: 1.8.23
70
+ rubygems_version: 2.2.2
80
71
  signing_key:
81
- specification_version: 3
72
+ specification_version: 4
82
73
  summary: Lets you change the current time in your tests
83
74
  test_files:
84
75
  - spec/quantum_spec.rb