diarb 0.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.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 tduehr
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = diarb
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 tduehr. See LICENSE for details.
@@ -0,0 +1,61 @@
1
+ #
2
+ # Rakefile
3
+ # diarb
4
+ #
5
+ # Created by tduehr on 2010-05-12.
6
+ # Copyright 2010 tduehr.
7
+ # See LICENSE file for details.
8
+ #
9
+
10
+ require 'rubygems'
11
+ require 'rake'
12
+
13
+ begin
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = "diarb"
17
+ gem.summary = %Q{Input/output diary for IRB}
18
+ gem.description = %Q{Addon for IRB to log command run and their returns to a file. Return values are comments so the diary is valid Ruby. Just cut and paste into another session.}
19
+ gem.email = "td@matasano.com"
20
+ gem.homepage = "http://github.com/tduehr/diarb"
21
+ gem.authors = ["tduehr"]
22
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
23
+ end
24
+ Jeweler::GemcutterTasks.new
25
+ rescue LoadError
26
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
27
+ end
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ begin
37
+ require 'rcov/rcovtask'
38
+ Rcov::RcovTask.new do |test|
39
+ test.libs << 'test'
40
+ test.pattern = 'test/**/test_*.rb'
41
+ test.verbose = true
42
+ end
43
+ rescue LoadError
44
+ task :rcov do
45
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
46
+ end
47
+ end
48
+
49
+ task :test => :check_dependencies
50
+
51
+ task :default => :test
52
+
53
+ require 'rake/rdoctask'
54
+ Rake::RDocTask.new do |rdoc|
55
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
56
+
57
+ rdoc.rdoc_dir = 'rdoc'
58
+ rdoc.title = "diarb #{version}"
59
+ rdoc.rdoc_files.include('README*')
60
+ rdoc.rdoc_files.include('lib/**/*.rb')
61
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,23 @@
1
+ #
2
+ # diarb.rb
3
+ # diarb
4
+ #
5
+ # Created by tduehr on 2010-05-12.
6
+ # Copyright 2010 tduehr.
7
+ # See LICENSE file for details.
8
+ #
9
+
10
+ require 'irb'
11
+ # require './debug-output'
12
+
13
+ module Diarb
14
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
15
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
16
+
17
+ require ::File.join(LIBPATH, 'diarb', 'diary')
18
+ require ::File.join(LIBPATH, 'diarb', 'context')
19
+ # require ::File.join(LIBPATH, 'diarb', 'io-method')
20
+ require ::File.join(LIBPATH, 'diarb', 'cmdext')
21
+ end
22
+
23
+ # self.extend(Diarb::CommandExtensions)
@@ -0,0 +1,24 @@
1
+ #
2
+ # cmdext.rb
3
+ # diarb
4
+ #
5
+ # Created by tduehr on 2010-05-12.
6
+ # Copyright 2010 tduehr.
7
+ # See LICENSE file for details.
8
+ #
9
+
10
+ def self.diary_start(filename, mode="a")
11
+ if self.diary?
12
+ raise "diary already started"
13
+ else
14
+ self.context.start_diary(filename, mode)
15
+ end
16
+ end
17
+
18
+ def self.diary_stop
19
+ self.context.stop_diary
20
+ end
21
+
22
+ def self.diary?
23
+ self.context.diary?
24
+ end
@@ -0,0 +1,47 @@
1
+ #
2
+ # context.rb
3
+ # diarb
4
+ #
5
+ # Created by tduehr on 2010-05-25.
6
+ # Copyright 2010 tduehr.
7
+ # See LICENSE file for details.
8
+ #
9
+ # module Diarb
10
+ # module ContextExtensions
11
+ module IRB
12
+ class Context
13
+ attr_accessor :diary
14
+ def evaluate(line, line_no, test="")
15
+ @line_no = line_no
16
+ @diary.print_input(line) if diary?
17
+ lv = @workspace.evaluate(self, line, irb_path, line_no)
18
+ @diary.print_output(lv) if diary?
19
+ set_last_value(lv)
20
+ # set_last_value(@workspace.evaluate(self, line, irb_path, line_no))
21
+ end
22
+
23
+ def start_diary(filename, mode)
24
+ if @diary
25
+ raise "diary already started #{@diary.filename}"
26
+ else
27
+ begin
28
+ @diary = Diarb::Diary.new(filename, mode)
29
+ rescue => e
30
+ @diary = nil
31
+ raise e
32
+ end
33
+ end
34
+ end
35
+
36
+ def stop_diary
37
+ if @diary
38
+ @diary.close
39
+ @diary = nil
40
+ end
41
+ end
42
+
43
+ def diary?
44
+ !!@diary
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,35 @@
1
+ #
2
+ # diary.rb
3
+ # diarb
4
+ #
5
+ # Created by tduehr on 2010-06-09.
6
+ # Copyright 2010 tduehr.
7
+ # See LICENSE file for details.
8
+ #
9
+
10
+ module Diarb
11
+ class Diary
12
+ attr_reader :file
13
+ attr_reader :filename
14
+ attr_reader :mode
15
+ def initialize(filename, mode="a")
16
+ @file = File.open(filename, mode)
17
+ @mode = mode
18
+ @filename = filename
19
+ end
20
+
21
+ def print_input(line)
22
+ @file.print line
23
+ @file.flush
24
+ end
25
+
26
+ def print_output(val)
27
+ @file.print "\# =>", val.inspect, "\n"
28
+ @file.flush
29
+ end
30
+
31
+ def close
32
+ @file.close
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: diarb
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - tduehr
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-06-16 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Addon for IRB to log command run and their returns to a file. Return values are comments so the diary is valid Ruby. Just cut and paste into another session.
23
+ email: td@matasano.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - LICENSE
30
+ - README.rdoc
31
+ files:
32
+ - .document
33
+ - .gitignore
34
+ - LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - VERSION
38
+ - lib/diarb.rb
39
+ - lib/diarb/cmdext.rb
40
+ - lib/diarb/context.rb
41
+ - lib/diarb/diary.rb
42
+ has_rdoc: true
43
+ homepage: http://github.com/tduehr/diarb
44
+ licenses: []
45
+
46
+ post_install_message:
47
+ rdoc_options:
48
+ - --charset=UTF-8
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ requirements: []
70
+
71
+ rubyforge_project:
72
+ rubygems_version: 1.3.7
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: Input/output diary for IRB
76
+ test_files: []
77
+