quantum_leap 0.6.0 → 0.7.0

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.
data/.gitignore CHANGED
@@ -3,6 +3,8 @@
3
3
  .bundle
4
4
  .config
5
5
  .rbx
6
+ .rbenv-gemsets
7
+ .rbenv-version
6
8
  .rvmrc
7
9
  .yardoc
8
10
  Gemfile.lock
data/.travis.yml CHANGED
@@ -4,3 +4,6 @@ rvm:
4
4
  - 1.9.3
5
5
  - jruby-19mode
6
6
  - rbx-19mode
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: jruby-19mode
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,45 @@
1
+ # Contributing
2
+
3
+ I would love for the community to help me make `quantum_leap` the time mocking
4
+ gem we've collectively always wanted!
5
+
6
+ Here's all the information you'll need:
7
+
8
+ ## GitHub Issues
9
+
10
+ Issues is an excellent feature! Leave any suggestions, feature requests and bug
11
+ reports there. I will try to address all as time allows.
12
+
13
+ If I haven't responded to your Issue within a reasonable timeframe, feel free
14
+ to ping me at <mattonrails@shortmail.com> or on
15
+ [Twitter](http://twitter.com/mattonrails).
16
+
17
+ ## Trello Board
18
+
19
+ Check out the [Trello
20
+ board](https://trello.com/board/quantumleap/4fc55ee290d3e95063cfc925) to see
21
+ what features and enhancements are planned for QuantumLeap and what is
22
+ currently in process.
23
+
24
+ Anyone can view, comment on, or vote for cards on this board. If you would like
25
+ to be a member and collaborate on this board, let me know.
26
+
27
+ ## Code
28
+
29
+ This is a **Ruby 1.9** gem meant to support **MRI**, **Rubinius** and
30
+ **JRuby**.
31
+
32
+ Changes to `quantum_leap` should not break on any of the supported Ruby
33
+ implementations. [Travis CI](http://travis-ci.org/#!/mattonrails/quantum_leap)
34
+ indicates the current build status on all three rubies.
35
+
36
+ QuantumLeap comes with a `MiniTest::Spec` test suite--the test framework built
37
+ into Ruby 1.9, with a little extra sugar.
38
+
39
+ 1. Fork this project
40
+ 2. Consider working in a topic branch (git checkout -b lazers)
41
+ 3. Write your patch or new functionality
42
+ 4. Please provide test coverage
43
+ 5. Push to the branch (git push origin lazers)
44
+ 6. Create new Pull Request
45
+
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # QuantumLeap
2
2
 
3
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)
4
5
 
5
6
  Righting wrongs in your test suite with time travel!
6
7
 
@@ -35,11 +36,3 @@ Quantum.leap(Time.new(1974, 10, 24)) do
35
36
  sam.must_win_the_championship
36
37
  end
37
38
  ```
38
-
39
- ## Contributing
40
-
41
- 1. Fork it
42
- 2. Create your feature branch (`git checkout -b my-new-feature`)
43
- 3. Commit your changes (`git commit -am 'Added some feature'`)
44
- 4. Push to the branch (`git push origin my-new-feature`)
45
- 5. Create new Pull Request
data/lib/quantum.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'quantum_leap'
2
+
3
+ class Quantum
4
+ INITIAL_LEAP = Time.new(1956, 9, 13, 15, 00)
5
+
6
+ def self.leap(time = INITIAL_LEAP)
7
+ QuantumLeap::Accelerator.mock_current_time(time)
8
+ if block_given?
9
+ begin
10
+ yield
11
+ ensure
12
+ QuantumLeap::Accelerator.reset
13
+ end
14
+ end
15
+ return Time.now
16
+ end
17
+
18
+ def self.leap_back
19
+ QuantumLeap::Accelerator.reset
20
+ Time.now
21
+ end
22
+ end
data/lib/quantum_leap.rb CHANGED
@@ -1,57 +1,7 @@
1
1
  require 'quantum_leap/version'
2
- require 'date'
3
2
 
4
- module QuantumLeap
5
- extend self
3
+ require 'quantum_leap/core_ext/date'
4
+ require 'quantum_leap/core_ext/time'
6
5
 
7
- def time_travel_offsets
8
- @time_travel_offsets ||= []
9
- end
10
-
11
- def reset
12
- @time_travel_offsets = []
13
- end
14
-
15
- def mock_current_time(new_time)
16
- time_travel_offsets.push(Time.now - new_time)
17
- end
18
-
19
- def now
20
- Time.really_now - time_travel_offsets.inject(0, :+)
21
- end
22
-
23
- def date
24
- now.to_date
25
- end
26
- end
27
-
28
- class << Time
29
- alias_method :really_now, :now
30
- def now; QuantumLeap.now; end
31
- end
32
-
33
- class << Date
34
- alias_method :really_today, :today
35
- def today; QuantumLeap.date; end
36
- end
37
-
38
- class Quantum
39
- INITIAL_LEAP = Time.new(1956, 9, 13, 15, 00)
40
-
41
- def self.leap(time = INITIAL_LEAP)
42
- QuantumLeap.mock_current_time(time)
43
- if block_given?
44
- begin
45
- yield
46
- ensure
47
- QuantumLeap.reset
48
- end
49
- end
50
- return Time.now
51
- end
52
-
53
- def self.leap_back
54
- QuantumLeap.reset
55
- Time.now
56
- end
57
- end
6
+ require 'quantum_leap/accelerator'
7
+ require 'quantum'
@@ -0,0 +1,28 @@
1
+ require 'quantum_leap'
2
+
3
+ module QuantumLeap
4
+ module Accelerator
5
+ extend self
6
+
7
+ def time_travel_offsets
8
+ @time_travel_offsets ||= []
9
+ end
10
+
11
+ def reset
12
+ @time_travel_offsets = []
13
+ end
14
+
15
+ def mock_current_time(new_time)
16
+ time_travel_offsets.push(Time.now - new_time)
17
+ end
18
+
19
+ def now
20
+ Time.really_now - time_travel_offsets.inject(0, :+)
21
+ end
22
+
23
+ def date
24
+ now.to_date
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,6 @@
1
+ require 'date'
2
+
3
+ class << Date
4
+ alias_method :really_today, :today
5
+ def today; QuantumLeap::Accelerator.date; end
6
+ end
@@ -0,0 +1,4 @@
1
+ class << Time
2
+ alias_method :really_now, :now
3
+ def now; QuantumLeap::Accelerator.now; end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module QuantumLeap
2
- VERSION = "0.6.0"
2
+ VERSION = '0.7.0'
3
3
  end
data/quantum_leap.gemspec CHANGED
@@ -16,5 +16,4 @@ Gem::Specification.new do |gem|
16
16
  gem.version = QuantumLeap::VERSION
17
17
 
18
18
  gem.add_development_dependency("rake")
19
- gem.add_development_dependency("minitest-colorize")
20
19
  end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1 @@
1
1
  require 'minitest/autorun'
2
- require 'minitest/colorize'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quantum_leap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-31 00:00:00.000000000 Z
12
+ date: 2013-05-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70356085914680 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,18 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70356085914680
25
- - !ruby/object:Gem::Dependency
26
- name: minitest-colorize
27
- requirement: &70356085913680 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
28
25
  none: false
29
26
  requirements:
30
27
  - - ! '>='
31
28
  - !ruby/object:Gem::Version
32
29
  version: '0'
33
- type: :development
34
- prerelease: false
35
- version_requirements: *70356085913680
36
30
  description: Righting wrongs in your test suite with time travel!
37
31
  email:
38
32
  - mattonrails@shortmail.com
@@ -41,13 +35,17 @@ extensions: []
41
35
  extra_rdoc_files: []
42
36
  files:
43
37
  - .gitignore
44
- - .rbenv-version
45
38
  - .travis.yml
39
+ - CONTRIBUTING.md
46
40
  - Gemfile
47
41
  - LICENSE
48
42
  - README.md
49
43
  - Rakefile
44
+ - lib/quantum.rb
50
45
  - lib/quantum_leap.rb
46
+ - lib/quantum_leap/accelerator.rb
47
+ - lib/quantum_leap/core_ext/date.rb
48
+ - lib/quantum_leap/core_ext/time.rb
51
49
  - lib/quantum_leap/version.rb
52
50
  - quantum_leap.gemspec
53
51
  - spec/quantum_spec.rb
@@ -64,15 +62,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
62
  - - ! '>='
65
63
  - !ruby/object:Gem::Version
66
64
  version: '0'
65
+ segments:
66
+ - 0
67
+ hash: 781284437395688069
67
68
  required_rubygems_version: !ruby/object:Gem::Requirement
68
69
  none: false
69
70
  requirements:
70
71
  - - ! '>='
71
72
  - !ruby/object:Gem::Version
72
73
  version: '0'
74
+ segments:
75
+ - 0
76
+ hash: 781284437395688069
73
77
  requirements: []
74
78
  rubyforge_project:
75
- rubygems_version: 1.8.16
79
+ rubygems_version: 1.8.23
76
80
  signing_key:
77
81
  specification_version: 3
78
82
  summary: Lets you change the current time in your tests
data/.rbenv-version DELETED
@@ -1 +0,0 @@
1
- 1.9.3-p125