snapper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in snapper.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Eric Sendelbach
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
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.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Snapper
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'snapper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install snapper
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,15 @@
1
+ require "active_support/all"
2
+
3
+ module IRB
4
+ class ReadlineInputMethod
5
+ def gets_with_snapper
6
+ line = gets_without_snapper
7
+ snapper = Snapper.instance
8
+ # TODO: Make detecting our own command less ghetto
9
+ snapper.snapper_file.puts(line) unless line.blank? || line =~ /Snapper/
10
+ snapper.snapper_file.flush
11
+ line
12
+ end
13
+ alias_method_chain :gets, :snapper
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ class Snapper
2
+ VERSION = "0.0.1"
3
+ end
data/lib/snapper.rb ADDED
@@ -0,0 +1,35 @@
1
+ require "snapper/version"
2
+ require "snapper/irb_patch"
3
+ require "uuid"
4
+
5
+ class Snapper
6
+ SNAPPER_DIR = ENV['SNAPPER_DIR'] || "#{ENV['HOME']}/.snapper"
7
+
8
+ attr_reader :snapper_file
9
+
10
+ def initialize
11
+ FileUtils.mkdir_p(SNAPPER_DIR) unless File.exists?(SNAPPER_DIR)
12
+ @uuid = UUID.new
13
+ @snapper_file = File.new("/tmp/#{@uuid.generate}.snapper", "w+")
14
+ end
15
+
16
+ @@instance = Snapper.new
17
+
18
+ def self.instance
19
+ return @@instance
20
+ end
21
+
22
+ def self.snap(name)
23
+ FileUtils.mv(instance.snapper_file.path, "#{SNAPPER_DIR}/#{name}.snapper")
24
+ return true
25
+ end
26
+
27
+ def self.restore(name)
28
+ file = File.open("#{SNAPPER_DIR}/#{name}.snapper")
29
+ while line = file.gets
30
+ IRB.CurrentContext.evaluate(line, 0)
31
+ end
32
+ end
33
+
34
+ private_class_method :new
35
+ end
data/snapper.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/snapper/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Adam Darrah", "Eric Sendelbach"]
6
+ gem.email = ["piremies@gmail.com", "eric.sendelbach@gmail.com"]
7
+ gem.description = %q{Capture and restore irb snapshots and stuff}
8
+ gem.summary = %q{Capture and restore irb snapshots}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "snapper"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Snapper::VERSION
17
+ gem.add_dependency("activesupport")
18
+ gem.add_dependency("uuid")
19
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: snapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adam Darrah
9
+ - Eric Sendelbach
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-04-14 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ requirement: &70114498670440 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *70114498670440
26
+ - !ruby/object:Gem::Dependency
27
+ name: uuid
28
+ requirement: &70114498669780 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *70114498669780
37
+ description: Capture and restore irb snapshots and stuff
38
+ email:
39
+ - piremies@gmail.com
40
+ - eric.sendelbach@gmail.com
41
+ executables: []
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - LICENSE
48
+ - README.md
49
+ - Rakefile
50
+ - lib/snapper.rb
51
+ - lib/snapper/irb_patch.rb
52
+ - lib/snapper/version.rb
53
+ - snapper.gemspec
54
+ homepage: ''
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.8.17
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Capture and restore irb snapshots
78
+ test_files: []