terminitor 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/teststrap.rb CHANGED
@@ -11,6 +11,11 @@ end
11
11
  class Riot::Context
12
12
  end
13
13
 
14
+ # Checks to see if Ruby Platform matches designated platform
15
+ def platform?(platform)
16
+ RUBY_PLATFORM.downcase.include?(platform)
17
+ end
18
+
14
19
  class Object
15
20
  def capture(stream)
16
21
  begin
@@ -23,40 +28,4 @@ class Object
23
28
  end
24
29
  result
25
30
  end
26
- end
27
-
28
- class TestRunner
29
- include Terminitor::Runner
30
-
31
- def say(caption)
32
- puts caption
33
- end
34
- end
35
-
36
-
37
- class TestObject
38
- attr_accessor :test_item
39
-
40
- def initialize(test_item)
41
- @test_item = test_item
42
- end
43
-
44
- def windows
45
- [@test_item]
46
- end
47
- end
48
-
49
- class TestItem
50
- def do_script(prompt,hash)
51
- true
52
- end
53
-
54
- def get
55
- true
56
- end
57
-
58
- def keystroke(prompt,hash)
59
- true
60
- end
61
-
62
- end
31
+ end
data/test/yaml_test.rb ADDED
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../teststrap', __FILE__)
2
+
3
+ context "Yaml" do
4
+ setup { @path = File.expand_path('../fixtures/foo.yml', __FILE__)}
5
+ setup { @yaml = Terminitor::Yaml.new(@path) }
6
+ asserts_topic.assigns :file
7
+
8
+ context "to_hash" do
9
+ setup { @yaml.to_hash }
10
+ asserts_topic.equivalent_to({ :setup => nil, :windows => {'default' => {'tab1' => ['cd /foo/bar','gitx'], 'tab2' => ['ls','mate .']}}})
11
+ end
12
+
13
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminitor
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 5
10
- version: 0.0.5
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Arthur Chiu
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-09-16 00:00:00 -07:00
19
+ date: 2010-09-30 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -50,9 +50,23 @@ dependencies:
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency
53
- name: bundler
53
+ name: github
54
54
  prerelease: false
55
55
  requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :runtime
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: bundler
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
56
70
  none: false
57
71
  requirements:
58
72
  - - ~>
@@ -64,27 +78,27 @@ dependencies:
64
78
  - 0
65
79
  version: 1.0.0
66
80
  type: :development
67
- version_requirements: *id003
81
+ version_requirements: *id004
68
82
  - !ruby/object:Gem::Dependency
69
83
  name: riot
70
84
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
85
+ requirement: &id005 !ruby/object:Gem::Requirement
72
86
  none: false
73
87
  requirements:
74
88
  - - ~>
75
89
  - !ruby/object:Gem::Version
76
- hash: 39
90
+ hash: 51
77
91
  segments:
78
92
  - 0
79
- - 14
93
+ - 11
80
94
  - 0
81
- version: 0.14.0
95
+ version: 0.11.0
82
96
  type: :development
83
- version_requirements: *id004
97
+ version_requirements: *id005
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: rr
86
100
  prerelease: false
87
- requirement: &id005 !ruby/object:Gem::Requirement
101
+ requirement: &id006 !ruby/object:Gem::Requirement
88
102
  none: false
89
103
  requirements:
90
104
  - - ">="
@@ -94,11 +108,11 @@ dependencies:
94
108
  - 0
95
109
  version: "0"
96
110
  type: :development
97
- version_requirements: *id005
111
+ version_requirements: *id006
98
112
  - !ruby/object:Gem::Dependency
99
113
  name: fakefs
100
114
  prerelease: false
101
- requirement: &id006 !ruby/object:Gem::Requirement
115
+ requirement: &id007 !ruby/object:Gem::Requirement
102
116
  none: false
103
117
  requirements:
104
118
  - - ">="
@@ -108,7 +122,7 @@ dependencies:
108
122
  - 0
109
123
  version: "0"
110
124
  type: :development
111
- version_requirements: *id006
125
+ version_requirements: *id007
112
126
  description: Automate your development workflow
113
127
  email:
114
128
  - mr.arthur.chiu@gmail.com
@@ -122,23 +136,41 @@ extra_rdoc_files: []
122
136
  files:
123
137
  - .gitignore
124
138
  - Gemfile
139
+ - Gemfile.lock
125
140
  - README.md
126
141
  - Rakefile
127
142
  - Termfile
128
143
  - bin/terminitor
144
+ - lib/templates/example.term.tt
129
145
  - lib/templates/example.yml.tt
130
146
  - lib/terminitor.rb
147
+ - lib/terminitor/abstract_core.rb
148
+ - lib/terminitor/cli.rb
149
+ - lib/terminitor/cores/konsole_core.rb
150
+ - lib/terminitor/cores/mac_core.rb
151
+ - lib/terminitor/dsl.rb
131
152
  - lib/terminitor/runner.rb
132
153
  - lib/terminitor/version.rb
154
+ - lib/terminitor/yaml.rb
155
+ - templates/example.yml.tt
133
156
  - terminitor.gemspec
157
+ - test.watchr
158
+ - test/abstract_core_test.rb
159
+ - test/cli_test.rb
160
+ - test/cores/konsole_core_test.rb
161
+ - test/cores/mac_core_test.rb
162
+ - test/dsl_test.rb
163
+ - test/fixtures/bar.term
164
+ - test/fixtures/foo.term
134
165
  - test/fixtures/foo.yml
135
- - test/terminitor_test.rb
166
+ - test/runner_test.rb
136
167
  - test/teststrap.rb
168
+ - test/yaml_test.rb
137
169
  has_rdoc: true
138
170
  homepage: http://rubygems.org/gems/terminitor
139
171
  licenses: []
140
172
 
141
- post_install_message: "********************************************************************************\n\n Terminitor is installed! \n Please run 'terminitor setup'. \n This will create a directory at ~/.terminitor which will hold all your global scripts.\n Thanks!\n\n\
173
+ post_install_message: "********************************************************************************\n\n Terminitor is installed! \n Please run 'terminitor init'. \n This will create a directory at ~/.terminitor which will hold all your global scripts.\n Thanks!\n\n\
142
174
  ********************************************************************************\n "
143
175
  rdoc_options: []
144
176
 
@@ -1,152 +0,0 @@
1
- require File.expand_path('../teststrap',__FILE__)
2
-
3
- context "Terminitor" do
4
- setup { @yaml = File.read(File.expand_path('../fixtures/foo.yml', __FILE__)) }
5
- setup { @template = File.read(File.expand_path('../../lib/templates/example.yml.tt', __FILE__)) }
6
- setup { FakeFS.activate! }
7
- teardown { FakeFS.deactivate! }
8
-
9
- context "shows the help" do
10
- setup { capture(:stdout) { Terminitor::Cli.start(['-h']) } }
11
- asserts_topic.matches %r{start PROJECT_NAME}
12
- asserts_topic.matches %r{setup}
13
- asserts_topic.matches %r{open PROJECT_NAME}
14
- end
15
-
16
- context "list" do
17
- setup { @path = "#{ENV['HOME']}/.terminitor/" }
18
- setup { File.open(File.join(@path,'foo.yml'),"w") { |f| f.puts @template } }
19
- setup { File.open(File.join(@path,'bar.yml'),"w") { |f| f.puts @template } }
20
- setup { capture(:stdout) { Terminitor::Cli.start(['list']) } }
21
- asserts_topic.matches %r{foo - COMMENT OF SCRIPT HERE}
22
- asserts_topic.matches %r{bar - COMMENT OF SCRIPT HERE}
23
- end
24
-
25
- context "setup" do
26
- setup { capture(:stdout) { Terminitor::Cli.start(['setup']) } }
27
- asserts("creates .terminitor") { File.exists?("#{ENV['HOME']}/.terminitor") }
28
- end
29
-
30
- context "open" do
31
- setup { FakeFS.deactivate! }
32
- setup { `rm -rf #{ENV['HOME']}/.terminitor/test_foo_bar2.yml`}
33
-
34
- teardown { `rm -rf /tmp/sample_project` }
35
-
36
- context "for project yaml" do
37
- setup { mock.instance_of(Terminitor::Cli).open_in_editor("#{ENV['HOME']}/.terminitor/test_foo_bar2.yml",nil) { true }.once }
38
- setup { capture(:stdout) { Terminitor::Cli.start(['open','test_foo_bar2']) } }
39
- asserts_topic.matches %r{create}
40
- asserts_topic.matches %r{test_foo_bar2.yml}
41
- end
42
-
43
- context "for Termfile" do
44
- context "with open" do
45
- setup { mock.instance_of(Terminitor::Cli).open_in_editor("/tmp/sample_project/Termfile",nil) { true }.once }
46
- setup { capture(:stdout) { Terminitor::Cli.start(['open','-r=/tmp/sample_project']) } }
47
- asserts_topic.matches %r{create}
48
- asserts_topic.matches %r{Termfile}
49
- end
50
-
51
- context "with create" do
52
- setup { mock.instance_of(Terminitor::Cli).invoke(:open, [], :root => '/tmp/sample_project') { true }.once }
53
- asserts('calls open') { capture(:stdout) { Terminitor::Cli.start(['create','-r=/tmp/sample_project']) } }
54
- end
55
-
56
- context "with editors" do
57
- setup { @test_runner = TestRunner.new }
58
- context "using $EDITOR" do
59
- setup { ENV['EDITOR'] = 'mate' }
60
- setup { mock(@test_runner).system("mate /tmp/sample_project/foo.yml").returns {true}.once }
61
- asserts("calls") { capture(:stdout) { @test_runner.open_in_editor("/tmp/sample_project/foo.yml") } }
62
- end
63
-
64
- context "using $TERM_EDITOR" do
65
- setup { ENV['TERM_EDITOR'] = 'vim' }
66
- setup { ENV['EDITOR'] = 'jack' }
67
- setup { mock(@test_runner).system("vim /tmp/sample_project/foo.yml").returns {true}.once }
68
- asserts("calls") { capture(:stdout) { @test_runner.open_in_editor("/tmp/sample_project/foo.yml")} }
69
- end
70
-
71
- context "without any editor" do
72
- setup { ENV['TERM_EDITOR'] = nil }
73
- setup { ENV['EDITOR'] = nil }
74
- setup { mock(@test_runner).system("open /tmp/sample_project/foo.yml").returns {true}.once }
75
- setup { capture(:stdout) { @test_runner.open_in_editor("/tmp/sample_project/foo.yml")} }
76
- asserts_topic.matches %r{please set}
77
- end
78
-
79
- context "with editor flag" do
80
- context "open_in_editor takes flag" do
81
- setup { ENV['TERM_EDITOR'] = 'vim' }
82
- setup { ENV['EDITOR'] = 'jack' }
83
- setup { mock(@test_runner).system("nano /tmp/sample_project/foo.yml").returns {true}.once }
84
- asserts("calls") { capture(:stdout) { @test_runner.open_in_editor("/tmp/sample_project/foo.yml","nano")} }
85
- end
86
-
87
- context "thor accepts open -c(editor) flag" do
88
- setup { FileUtils.mkdir_p('/tmp/sample_project') }
89
- setup { @path = '/tmp/sample_project/Termfile' }
90
- setup { File.open(@path,"w") { |f| f.puts @yaml } }
91
- setup { mock.instance_of(Terminitor::Cli).open_in_editor(@path,'nano') { true }.once }
92
- asserts("runs nano") { capture(:stdout) { Terminitor::Cli.start(['open','-r=/tmp/sample_project','-c=nano']) } }
93
- end
94
- end
95
-
96
- end
97
-
98
- end
99
-
100
- context "delete" do
101
-
102
- context "directory Termfile" do
103
- setup { FileUtils.mkdir_p('/tmp/sample_project')}
104
- setup { FileUtils.touch("/tmp/sample_project/Termfile") }
105
- setup { capture(:stdout) { Terminitor::Cli.start(['delete',"-r=/tmp/sample_project"]) } }
106
- asserts("Termfile") { File.exists?("/tmp/sample_project/Termfile") }.not!
107
- end
108
-
109
- context "global script" do
110
- setup { FileUtils.touch("#{ENV['HOME']}/.terminitor/delete_this.yml") }
111
- setup { capture(:stdout) { Terminitor::Cli.start(['delete','delete_this']) } }
112
- asserts(" script") { File.exists?("#{ENV['HOME']}/.terminitor/delete_this.yml") }.not!
113
- end
114
- end
115
-
116
-
117
- end
118
-
119
- context "start" do
120
-
121
- context "for project yaml" do
122
- setup do
123
- @test_item = TestItem.new
124
- @test_runner = TestRunner.new
125
- stub(@test_runner).open_tab(anything) { true }.twice
126
- mock(@test_item).do_script('cd /foo/bar', anything) { true }.once
127
- mock(@test_item).do_script('gitx', anything) { true }.once
128
- mock(@test_item).do_script('ls', anything) { true }.once
129
- mock(@test_item).do_script('mate .', anything) { true }.once
130
- stub(@test_runner).app('Terminal') { TestObject.new(@test_item) }
131
- end
132
- setup { capture(:stdout) { Terminitor::Cli.start(['setup']) } }
133
- setup { @path = "#{ENV['HOME']}/.terminitor/foo.yml" }
134
- setup { File.open(@path,"w") { |f| f.puts @yaml } }
135
- asserts("runs project") { @test_runner.do_project(@path) }
136
- end
137
-
138
- context "for Termfile" do
139
- setup { FileUtils.mkdir_p('/tmp/sample_project') }
140
- setup { @path = '/tmp/sample_project/Termfile' }
141
- setup { File.open(@path,"w") { |f| f.puts @yaml } }
142
- setup { mock.instance_of(Terminitor::Cli).do_project(@path) { true }.once }
143
- asserts("runs .terminit") { capture(:stdout) { Terminitor::Cli.start(['start','-r=/tmp/sample_project']) } }
144
- end
145
-
146
- context "with invalid project" do
147
- setup { capture(:stdout) { Terminitor::Cli.start(['start','nonono']) } }
148
- asserts_topic.matches %r{'nonono.yml' doesn't exist! Please run 'terminitor open nonono'}
149
- end
150
-
151
- end
152
- end