This repository was archived by the owner on Sep 15, 2018. It is now read-only.
File tree 7 files changed +64
-0
lines changed
7 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ OptionParser.new do |opts|
18
18
exit
19
19
end
20
20
21
+ opts . on ( '--history' , "Print History" ) do
22
+ History . list
23
+ exit
24
+ end
25
+
21
26
opts . on ( '--version' , "Print the version" ) do
22
27
puts "Captured #{ File . open ( "#{ File . dirname ( __FILE__ ) } /../VERSION" , "r" ) . read } "
23
28
exit
Original file line number Diff line number Diff line change
1
+ require "#{ File . dirname ( __FILE__ ) } /captured/history"
1
2
require "#{ File . dirname ( __FILE__ ) } /captured/file_tracker"
2
3
require "#{ File . dirname ( __FILE__ ) } /captured/file_uploader"
3
4
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ def process_upload(file)
50
50
puts "Uploaded '#{ file } ' to '#{ remote_path } '"
51
51
pbcopy remote_path
52
52
growl ( "Upload Succeeded" , "#{ File . dirname ( File . expand_path ( __FILE__ ) ) } /../../resources/green_check.png" )
53
+ History . append ( file , remote_path )
53
54
rescue => e
54
55
puts e
55
56
puts e . backtrace
Original file line number Diff line number Diff line change
1
+ require 'shellwords'
2
+
3
+ class History
4
+
5
+ def self . file_path
6
+ "#{ ENV [ 'HOME' ] } /.captured_history"
7
+ end
8
+
9
+ def self . time_stamp
10
+ DateTime . now . strftime ( "%m/%d/%Y-%I:%M%p" )
11
+ end
12
+
13
+ def self . append ( original_name , remote_path )
14
+ File . open ( History . file_path , 'a' ) do |f |
15
+ f . puts ( History . format_line ( original_name , remote_path ) )
16
+ end
17
+ end
18
+
19
+ def self . format_line ( original_name , remote_path )
20
+ "#{ History . time_stamp } \" #{ original_name } \" #{ remote_path } "
21
+ end
22
+
23
+ def self . list
24
+ if File . exists? History . file_path
25
+ File . open ( History . file_path ) . each do |line |
26
+ puts line
27
+ end
28
+ else
29
+ puts "You ain't got no history yet"
30
+ end
31
+ end
32
+ end
Original file line number Diff line number Diff line change
1
+ 01/11/2010 02:47PM original_file remote_path
2
+ 01/11/2010 02:48PM original_file remote_path
3
+ 01/11/2010 02:49PM original_file remote_path
Original file line number Diff line number Diff line change
1
+ require File . expand_path ( File . dirname ( __FILE__ ) + '/spec_helper' )
2
+
3
+ describe "History" do
4
+ before ( :each ) do
5
+ @date_time = mock ( DateTime )
6
+ @date_time . stub! ( :strftime ) . and_return ( "01/11/2010 02:48PM" )
7
+ DateTime . stub! ( :now ) . and_return ( @date_time )
8
+ History . stub! ( :file_path ) . and_return ( "#{ File . dirname ( __FILE__ ) } /fixtures/history" )
9
+ end
10
+
11
+ it "should format a line" do
12
+ line = History . format_line ( "original_name" , "remote_path" )
13
+ line . should == "01/11/2010 02:48PM original_name remote_path"
14
+ end
15
+
16
+ it "should list the history" do
17
+ History . should respond_to ( :list )
18
+ end
19
+ end
20
+
Original file line number Diff line number Diff line change 5
5
$LOAD_PATH. unshift ( File . join ( File . dirname ( __FILE__ ) , '..' , 'lib' ) )
6
6
require 'captured'
7
7
8
+ CONFIG = YAML . load_file ( "#{ ENV [ 'HOME' ] } /.captured.yml" )
9
+
8
10
Spec ::Runner . configure do |config |
9
11
10
12
end
You can’t perform that action at this time.
0 commit comments