git_time_machine 1.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ba78c2b125892fc2039c2afc0a3a5d65a272c926
4
+ data.tar.gz: 8b62617fa7c3e3ff58738793f31efab5e08507fe
5
+ SHA512:
6
+ metadata.gz: aeac301db29bb9c994c92f50dacc7fdd8d8bb42ab740b816c749e3fb9efdc09a2b420a09eec37bc7fb6e6eff9c25a98cd6b2b1346cd2edfae92c75ba952bbbe6
7
+ data.tar.gz: e69992d43b40300523886f6a306e409499cb75be837c339122bd9cb7d7bb84710aa57a3b6bac2b46472e7c9383d7db8468e939c876de6a75f27642b6b548a3c2
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.swp
2
+ /pkg/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in git_time_machine.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ git_time_machine (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.5.0)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.13)
16
+ git_time_machine!
17
+ rake (~> 10.0)
18
+
19
+ BUNDLED WITH
20
+ 1.13.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Chris Jewell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # GitTimeMachine
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/git_time_machine`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'git_time_machine'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install git_time_machine
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/git_time_machine.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "git_time_machine"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'git_time_machine'
4
+
5
+ GitTimeMachine::TravelThroughTime.travel_through_time
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'git_time_machine/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "git_time_machine"
8
+ spec.version = GitTimeMachine::VERSION
9
+ spec.authors = ["Chris Jewell"]
10
+ spec.email = ["chrisjohnjewell@gmail.com"]
11
+
12
+ spec.summary = %q{Pretend to travel through time to impress your friends}
13
+ spec.description = %q{This is a demo project to demonstrate the basics of how git works}
14
+ spec.homepage = "https://github.com/knightstick/git_time_machine"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ #if spec.respond_to?(:metadata)
20
+ #spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ #else
22
+ #raise "RubyGems 2.0 or newer is required to protect against " \
23
+ #"public gem pushes."
24
+ #end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "bin"
30
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.13"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ end
@@ -0,0 +1,45 @@
1
+ require "git_time_machine/version"
2
+ require "git_time_machine/time_machine"
3
+
4
+ module GitTimeMachine
5
+ module TravelThroughTime
6
+ class LawsOfPhysicsError < RuntimeError; end
7
+
8
+ def self.travel_through_time
9
+ time_machine = TimeMachine.new
10
+ time_machine.get_ready!
11
+ perform_status_check(time_machine)
12
+
13
+ if can_travel_through_time?(time_machine)
14
+ time_machine.back_to "1955"
15
+ else
16
+ raise LawsOfPhysicsError, 'Cannot Travel Through Time'
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def self.can_travel_through_time?(time_machine)
23
+ time_machine.flux_capacitated? &&
24
+ (time_machine.velocity >= 88)
25
+ end
26
+
27
+ def self.perform_status_check(time_machine)
28
+ print "Checking flux"
29
+ 3.times do
30
+ sleep 1
31
+ print '.'
32
+ end
33
+
34
+ puts "\nFlux status: #{time_machine.flux_capacitated?}"
35
+
36
+ print "Checking velocity"
37
+ 3.times do
38
+ sleep 1
39
+ print '.'
40
+ end
41
+
42
+ puts "\nVelocity: #{time_machine.velocity}"
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,13 @@
1
+ module GitTimeMachine
2
+ class Delorean
3
+ attr_reader :velocity
4
+
5
+ def initialize
6
+ @velocity = 0
7
+ end
8
+
9
+ def accelerate(speed)
10
+ @velocity += speed
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,32 @@
1
+ module GitTimeMachine
2
+ class FluxCapacitor
3
+ class NoFuelError < RuntimeError; end
4
+
5
+ def initialize
6
+ @plutonium = nil
7
+ end
8
+
9
+ def setup
10
+ @plutonium = :weapons_grade
11
+ end
12
+
13
+ def capacitate!
14
+ raise NoFuelError unless plutonium_present?
15
+
16
+ @flux = :capacitated
17
+ end
18
+
19
+ def capacitated?
20
+ flux == :capacitated
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :flux
26
+ attr_reader :plutonium
27
+
28
+ def plutonium_present?
29
+ !plutonium.nil?
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,44 @@
1
+ require 'git_time_machine/delorean'
2
+ require 'git_time_machine/flux_capacitor'
3
+
4
+ module GitTimeMachine
5
+ class TimeMachine
6
+ extend Forwardable
7
+
8
+ def_delegators :@delorean, :velocity
9
+
10
+ def initialize
11
+ @flux_capacitor = GitTimeMachine::FluxCapacitor.new
12
+ @delorean = GitTimeMachine::Delorean.new
13
+ end
14
+
15
+ def get_ready!
16
+ flux_capacitor.setup
17
+ flux_capacitor.capacitate!
18
+ delorean.accelerate(88)
19
+ end
20
+
21
+ def flux_capacitated?
22
+ flux_capacitor.capacitated?
23
+ end
24
+
25
+ def back_to(year_string)
26
+ year = year_string.to_i
27
+ now = Time.now
28
+ new_time_space_continuum = Time.new(
29
+ year, now.month, now.day, now.hour, now.min, now.sec
30
+ )
31
+
32
+ puts "*********************************************"
33
+ puts "Time Travel Succeeded"
34
+ puts "*********************************************"
35
+ puts "The Time Now is: #{new_time_space_continuum.strftime("%I:%M%p on %A %d %B %Y")}"
36
+ end
37
+
38
+ private
39
+
40
+ attr_reader :delorean
41
+
42
+ attr_reader :flux_capacitor
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module GitTimeMachine
2
+ VERSION = "1.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_time_machine
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Jewell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: This is a demo project to demonstrate the basics of how git works
42
+ email:
43
+ - chrisjohnjewell@gmail.com
44
+ executables:
45
+ - console
46
+ - git_time_machine
47
+ - setup
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/console
58
+ - bin/git_time_machine
59
+ - bin/setup
60
+ - git_time_machine.gemspec
61
+ - lib/git_time_machine.rb
62
+ - lib/git_time_machine/delorean.rb
63
+ - lib/git_time_machine/flux_capacitor.rb
64
+ - lib/git_time_machine/time_machine.rb
65
+ - lib/git_time_machine/version.rb
66
+ homepage: https://github.com/knightstick/git_time_machine
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.5.1
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Pretend to travel through time to impress your friends
90
+ test_files: []