hurl 0.0.2
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/README +72 -0
- data/bin/hurl +97 -0
- metadata +62 -0
data/README
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
About
|
2
|
+
=====
|
3
|
+
Hurl is an Applescript wrapper built to assist in scripting terminal events. By defining some actions in a config file (hurls.rb) you can open terminal tabs & launch applications with one command (hurl). ITerm and Terminal.app are supported and adding new apps is fairly straight forward.
|
4
|
+
|
5
|
+
Install
|
6
|
+
=======
|
7
|
+
The ruby appscript gem is required.
|
8
|
+
|
9
|
+
sudo gem install hurl
|
10
|
+
|
11
|
+
Usage
|
12
|
+
=====
|
13
|
+
|
14
|
+
When hurl is called from the command line with a directory path it will search for a hurls.rb file in the root and the lib directory. Actions in this file will be executed in the order they are defined.
|
15
|
+
|
16
|
+
iTerm is the default, but you can specify other applications by placing this in your hurls file:
|
17
|
+
|
18
|
+
using Terminal
|
19
|
+
|
20
|
+
In order to execute a command in the tab that hurl was called from:
|
21
|
+
|
22
|
+
this_tab do |t|
|
23
|
+
t.exec "ls"
|
24
|
+
end
|
25
|
+
|
26
|
+
Command line executables can be called directly:
|
27
|
+
|
28
|
+
this_tab do |t|
|
29
|
+
t.cd "~/"
|
30
|
+
t.ls
|
31
|
+
end
|
32
|
+
|
33
|
+
The project_dir method returns the path passed into hurl:
|
34
|
+
|
35
|
+
this_tab do |t|
|
36
|
+
t.cd project_dir
|
37
|
+
t.exec "script/server run"
|
38
|
+
end
|
39
|
+
|
40
|
+
You can create a new tab using create_tab:
|
41
|
+
|
42
|
+
create_tab do |t|
|
43
|
+
t.cd project_dir
|
44
|
+
t.autotest
|
45
|
+
end
|
46
|
+
|
47
|
+
Example
|
48
|
+
=======
|
49
|
+
|
50
|
+
# Here is an example hurl.rb placed in ~/your_project/lib
|
51
|
+
# run hurl ~/your_project to watch awesome happen.
|
52
|
+
|
53
|
+
# Uncomment to use Terminal instead of iTerm
|
54
|
+
# using Terminal
|
55
|
+
|
56
|
+
# This will launch Textmate from the project directory.
|
57
|
+
this_tab do |t|
|
58
|
+
t.cd project_dir
|
59
|
+
t.mate "."
|
60
|
+
end
|
61
|
+
|
62
|
+
# Then open a new tab, cd to the proj dir, and launch autotest.
|
63
|
+
create_tab do |t|
|
64
|
+
t.cd project_dir
|
65
|
+
t.exec "autotest --rails"
|
66
|
+
end
|
67
|
+
|
68
|
+
# Then open another new tab, cd to the proj dir, and start the server.
|
69
|
+
create_tab do |t|
|
70
|
+
t.cd project_dir
|
71
|
+
t.exec "script/server run"
|
72
|
+
end
|
data/bin/hurl
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'appscript'
|
5
|
+
include Appscript
|
6
|
+
|
7
|
+
class Project
|
8
|
+
attr_accessor :project_dir, :appscript
|
9
|
+
|
10
|
+
def initialize(dir)
|
11
|
+
@project_dir = dir
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Session
|
16
|
+
def initialize(sesh)
|
17
|
+
@session = sesh
|
18
|
+
end
|
19
|
+
|
20
|
+
def method_missing(command, *args)
|
21
|
+
cmd = command.to_s + args.inject('') do |opts, arg| opts += ' ' + arg.to_s end
|
22
|
+
exec(cmd)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class ITermSession < Session
|
27
|
+
def exec(command)
|
28
|
+
@session.write(:text => command)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class ITerm < Project
|
33
|
+
def initialize(dir)
|
34
|
+
@appscript = app('iTerm').current_terminal
|
35
|
+
super(dir)
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_tab
|
39
|
+
@appscript.launch_(:session => "Default Session")
|
40
|
+
yield ITermSession.new(@appscript.sessions.last) if block_given?
|
41
|
+
end
|
42
|
+
|
43
|
+
def this_tab
|
44
|
+
yield ITermSession.new(@appscript.current_session) if block_given?
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class TerminalSession < Session
|
49
|
+
def exec(command)
|
50
|
+
@session.do_script(command, :in => @session)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Terminal < Project
|
55
|
+
def initialize(dir)
|
56
|
+
@appscript = app('Terminal').windows[0]
|
57
|
+
super(dir)
|
58
|
+
end
|
59
|
+
|
60
|
+
def create_tab(&block)
|
61
|
+
@appscript.activate
|
62
|
+
app("System Events").keystroke("t", :using => :command_down)
|
63
|
+
yield TerminalSession.new(@appscript.tabs.last) if block_given?
|
64
|
+
end
|
65
|
+
|
66
|
+
def this_tab
|
67
|
+
@appscript.activate
|
68
|
+
yield TerminalSession.new(@appscript.tabs.first) if block_given?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
module Hurler
|
73
|
+
attr_accessor :project_dir
|
74
|
+
|
75
|
+
def using(klass)
|
76
|
+
@wrapper = klass.new(@project_dir)
|
77
|
+
end
|
78
|
+
|
79
|
+
def create_tab(&block)
|
80
|
+
@wrapper.create_tab(&block)
|
81
|
+
end
|
82
|
+
|
83
|
+
def this_tab(&block)
|
84
|
+
@wrapper.this_tab(&block)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
if __FILE__ == $0
|
89
|
+
include Hurler
|
90
|
+
project_dir = ARGV.shift
|
91
|
+
using ITerm
|
92
|
+
["", "/lib"].each do |path|
|
93
|
+
hurls = "#{project_dir}#{path}/hurls.rb"
|
94
|
+
puts hurls
|
95
|
+
require hurls if File.exist? hurls
|
96
|
+
end
|
97
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hurl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Marney
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-03-25 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rb-appscript
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.5.1
|
23
|
+
version:
|
24
|
+
description: Hurl is an ITerm Applescript wrapper built to make scripting in ITerm easy.
|
25
|
+
email: gotascii@gmail.com
|
26
|
+
executables:
|
27
|
+
- hurl
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README
|
32
|
+
files:
|
33
|
+
- bin/hurl
|
34
|
+
- README
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://gotascii.com
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
requirements: []
|
55
|
+
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 1.0.1
|
58
|
+
signing_key:
|
59
|
+
specification_version: 2
|
60
|
+
summary: ITerm Applescript
|
61
|
+
test_files: []
|
62
|
+
|