scide 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,103 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "scide"
8
- s.version = "0.1.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Simon Oulevay (AlphaHydrae)"]
12
- s.date = "2013-05-02"
13
- s.description = "GNU screen wrapper to open projects with a .screenrc file."
14
- s.email = "hydrae.alpha@gmail.com"
15
- s.executables = ["scide"]
16
- s.extra_rdoc_files = [
17
- "LICENSE.txt",
18
- "README.md"
19
- ]
20
- s.files = [
21
- ".rspec",
22
- ".ruby-version",
23
- ".screenrc",
24
- ".travis.yml",
25
- "Gemfile",
26
- "Gemfile.lock",
27
- "LICENSE.txt",
28
- "README.md",
29
- "Rakefile",
30
- "VERSION",
31
- "bin/scide",
32
- "lib/scide.rb",
33
- "lib/scide/auto.rb",
34
- "lib/scide/list.rb",
35
- "lib/scide/open.rb",
36
- "lib/scide/program.rb",
37
- "lib/scide/setup.rb",
38
- "scide.gemspec",
39
- "spec/auto_spec.rb",
40
- "spec/cli/list_spec.rb",
41
- "spec/cli/open_spec.rb",
42
- "spec/cli/setup_spec.rb",
43
- "spec/helper.rb",
44
- "spec/list_spec.rb",
45
- "spec/open_spec.rb",
46
- "spec/setup_spec.rb",
47
- "spec/version_spec.rb"
48
- ]
49
- s.homepage = "http://github.com/AlphaHydrae/scide"
50
- s.licenses = ["MIT"]
51
- s.require_paths = ["lib"]
52
- s.rubygems_version = "1.8.25"
53
- s.summary = "GNU Screen IDE"
54
-
55
- if s.respond_to? :specification_version then
56
- s.specification_version = 3
57
-
58
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
- s.add_runtime_dependency(%q<commander>, ["~> 4.1.3"])
60
- s.add_runtime_dependency(%q<paint>, ["~> 0.8.6"])
61
- s.add_runtime_dependency(%q<which_works>, ["~> 1.0.0"])
62
- s.add_development_dependency(%q<bundler>, [">= 0"])
63
- s.add_development_dependency(%q<rake>, [">= 0"])
64
- s.add_development_dependency(%q<rspec>, [">= 0"])
65
- s.add_development_dependency(%q<fakefs>, [">= 0"])
66
- s.add_development_dependency(%q<jeweler>, [">= 0"])
67
- s.add_development_dependency(%q<gemcutter>, [">= 0"])
68
- s.add_development_dependency(%q<gem-release>, [">= 0"])
69
- s.add_development_dependency(%q<rake-version>, [">= 0"])
70
- s.add_development_dependency(%q<simplecov>, [">= 0"])
71
- s.add_development_dependency(%q<travis-lint>, [">= 0"])
72
- else
73
- s.add_dependency(%q<commander>, ["~> 4.1.3"])
74
- s.add_dependency(%q<paint>, ["~> 0.8.6"])
75
- s.add_dependency(%q<which_works>, ["~> 1.0.0"])
76
- s.add_dependency(%q<bundler>, [">= 0"])
77
- s.add_dependency(%q<rake>, [">= 0"])
78
- s.add_dependency(%q<rspec>, [">= 0"])
79
- s.add_dependency(%q<fakefs>, [">= 0"])
80
- s.add_dependency(%q<jeweler>, [">= 0"])
81
- s.add_dependency(%q<gemcutter>, [">= 0"])
82
- s.add_dependency(%q<gem-release>, [">= 0"])
83
- s.add_dependency(%q<rake-version>, [">= 0"])
84
- s.add_dependency(%q<simplecov>, [">= 0"])
85
- s.add_dependency(%q<travis-lint>, [">= 0"])
86
- end
87
- else
88
- s.add_dependency(%q<commander>, ["~> 4.1.3"])
89
- s.add_dependency(%q<paint>, ["~> 0.8.6"])
90
- s.add_dependency(%q<which_works>, ["~> 1.0.0"])
91
- s.add_dependency(%q<bundler>, [">= 0"])
92
- s.add_dependency(%q<rake>, [">= 0"])
93
- s.add_dependency(%q<rspec>, [">= 0"])
94
- s.add_dependency(%q<fakefs>, [">= 0"])
95
- s.add_dependency(%q<jeweler>, [">= 0"])
96
- s.add_dependency(%q<gemcutter>, [">= 0"])
97
- s.add_dependency(%q<gem-release>, [">= 0"])
98
- s.add_dependency(%q<rake-version>, [">= 0"])
99
- s.add_dependency(%q<simplecov>, [">= 0"])
100
- s.add_dependency(%q<travis-lint>, [">= 0"])
101
- end
102
- end
103
-
@@ -1,72 +0,0 @@
1
- require 'helper'
2
- require 'fileutils'
3
-
4
- describe Scide do
5
- include FakeFS::SpecHelpers
6
-
7
- before :each do
8
- FileUtils.mkdir_p '/tmp'
9
- end
10
-
11
- context ".auto_config_file" do
12
-
13
- before(:each){ Scide.stub auto_config: 'foo' }
14
-
15
- it "should create a temporary configuration file" do
16
- Scide.auto_config_file do |auto_file|
17
- expect(auto_file).to be_a_kind_of(Tempfile)
18
- end
19
- end
20
-
21
- it "should create a file containing the results of ::auto_config" do
22
- Scide.auto_config_file do |auto_file|
23
- expect(File.read(auto_file)).to eq('foo')
24
- end
25
- end
26
- end
27
-
28
- context ".auto_config" do
29
-
30
- let(:expected_config){ %|screen -t editor 0\nstuff "\\${PROJECT_EDITOR-\\$EDITOR}\\012"\nscreen -t shell 1\nselect editor| }
31
- subject{ Scide.auto_config }
32
-
33
- it{ should eq(expected_config) }
34
-
35
- context "with a .screenrc file in the home directory" do
36
- let(:expected_config){ %|source $HOME/.screenrc\n\n#{super()}| }
37
- before(:each){ setup '~' }
38
- it{ should eq(expected_config) }
39
- end
40
- end
41
-
42
- context ".auto?" do
43
-
44
- let(:options){ {} }
45
- let(:env_auto){ nil }
46
- subject{ Scide.auto? options }
47
- it{ should be_false }
48
-
49
- before :each do
50
- ENV['SCIDE_AUTO'] = env_auto if env_auto
51
- end
52
-
53
- context "with the auto option" do
54
- let(:options){ { auto: true } }
55
- it{ should be_true }
56
- end
57
-
58
- [ '1', 'y', 'yes', 't', 'true' ].each do |valid|
59
- context "with $SCIDE_AUTO set to #{valid}" do
60
- let(:env_auto){ valid }
61
- it{ should be_true }
62
- end
63
- end
64
- end
65
-
66
- def setup dir, config = true
67
- dir = File.expand_path dir
68
- FileUtils.mkdir_p dir
69
- FileUtils.touch File.join(dir, '.screenrc') if config
70
- dir
71
- end
72
- end
@@ -1,81 +0,0 @@
1
- require 'helper'
2
-
3
- describe 'scide list' do
4
-
5
- let(:argv){ [ 'list' ] }
6
- let(:expected_options){ {} }
7
-
8
- before :each do
9
- Scide.stub :list
10
- Scide.stub(:open).and_raise(StandardError.new('open should not be called'))
11
- Scide.stub(:setup).and_raise(StandardError.new('setup should not be called'))
12
- end
13
-
14
- shared_examples_for "list" do
15
-
16
- it "should output nothing if there are no projects" do
17
- Scide.stub list: []
18
- expect_success "\n"
19
- end
20
-
21
- it "should output the list of projects" do
22
- Scide.stub list: [ '.', 'a', 'b', 'c' ]
23
- expect_success ".\na\nb\nc\n"
24
- end
25
-
26
- context "if it fails" do
27
-
28
- before :each do
29
- Scide.stub(:list).and_raise(Scide::Error.new('fubar'))
30
- end
31
-
32
- it "should output the error to stderr" do
33
- expect_failure "fubar#{Scide::Program::BACKTRACE_NOTICE}"
34
- end
35
-
36
- context "with the trace option" do
37
-
38
- let(:argv){ super().unshift '--trace' }
39
-
40
- it "should raise the error" do
41
- expect_failure "fubar", true
42
- end
43
- end
44
- end
45
- end
46
-
47
- it_behaves_like "list"
48
-
49
- [ '-p', '--projects' ].each do |opt|
50
- context "with the #{opt} option" do
51
- let(:projects_dir){ '~/Projects' }
52
- let(:expected_options){ { projects: projects_dir } }
53
- let(:argv){ super() + [ opt, projects_dir ] }
54
- it_behaves_like "list"
55
- end
56
- end
57
-
58
- def expect_success output
59
- Scide.should_receive(:list).with expected_options
60
- program = Scide::Program.new argv
61
- stdout, stderr = StringIO.new, StringIO.new
62
- $stdout, $stderr = stdout, stderr
63
- expect{ program.run! }.to_not raise_error
64
- $stdout, $stderr = STDOUT, STDERR
65
- expect(stdout.string).to eq(output)
66
- expect(stderr.string).to be_empty
67
- end
68
-
69
- def expect_failure message, expect_raise = false, code = 1, &block
70
- program = Scide::Program.new argv
71
- if expect_raise
72
- expect{ program.run! }.to raise_error(Scide::Error){ |e| expect(e.message).to eq(message) }
73
- else
74
- stderr = StringIO.new
75
- $stderr = stderr
76
- expect{ program.run! }.to raise_error(SystemExit){ |e| expect(e.status).to eq(code) }
77
- $stderr = STDERR
78
- expect(Paint.unpaint(stderr.string.strip)).to eq(message)
79
- end
80
- end
81
- end
@@ -1,131 +0,0 @@
1
- require 'helper'
2
-
3
- describe 'scide open' do
4
-
5
- let(:argv){ [] }
6
- let(:expected_args){ [] }
7
- let(:expected_options){ {} }
8
- let(:expected_output){ expected_options[:noop] ? fake_command : '' }
9
- let(:fake_command){ 'foo' }
10
-
11
- before :each do
12
- Scide.stub :open
13
- Scide.stub(:list).and_raise(StandardError.new('list should not be called'))
14
- Scide.stub(:setup).and_raise(StandardError.new('setup should not be called'))
15
- end
16
-
17
- shared_examples_for "open" do
18
-
19
- before :each do
20
- Scide.stub open: fake_command
21
- end
22
-
23
- it "should open the current directory" do
24
- expect_success
25
- end
26
-
27
- context "with a project name" do
28
- let(:argv){ super().push 'a' }
29
- let(:expected_args){ [ 'a' ] }
30
-
31
- it "should open the project" do
32
- expect_success
33
- end
34
- end
35
-
36
- context "if it fails" do
37
-
38
- before :each do
39
- Scide.stub(:open).and_raise(Scide::Error.new('fubar'))
40
- end
41
-
42
- it "should output the error to stderr" do
43
- expect_failure "fubar#{Scide::Program::BACKTRACE_NOTICE}"
44
- end
45
-
46
- context "with the trace option" do
47
-
48
- let(:argv){ super().unshift '--trace' }
49
-
50
- it "should raise the error" do
51
- expect_failure "fubar", true
52
- end
53
- end
54
- end
55
- end
56
-
57
- it_behaves_like "open"
58
-
59
- [ '-p', '--projects' ].each do |opt|
60
- context "with the #{opt} option" do
61
- let(:projects_dir){ '~/Projects' }
62
- let(:expected_options){ { projects: projects_dir } }
63
- let(:argv){ [ opt, projects_dir ] }
64
- it_behaves_like "open"
65
- end
66
- end
67
-
68
- [ '-a', '--auto' ].each do |opt|
69
- context "with the #{opt} option" do
70
- let(:expected_options){ { auto: true } }
71
- let(:argv){ [ opt ] }
72
- it_behaves_like "open"
73
- end
74
- end
75
-
76
- [ '-n', '--noop' ].each do |opt|
77
- context "with the #{opt} option" do
78
- let(:expected_options){ { noop: true } }
79
- let(:argv){ [ opt ] }
80
- it_behaves_like "open"
81
- end
82
- end
83
-
84
- [ '-b', '--bin' ].each do |opt|
85
- context "with the #{opt} option" do
86
- let(:expected_options){ { bin: '/bin/custom-screen' } }
87
- let(:argv){ [ opt, '/bin/custom-screen' ] }
88
- it_behaves_like "open"
89
- end
90
- end
91
-
92
- [ '-s', '--screen' ].each do |opt|
93
- context "with the #{opt} option" do
94
- let(:expected_options){ { screen: '-a' } }
95
- let(:argv){ [ opt, "-a" ] }
96
- it_behaves_like "open"
97
- end
98
- end
99
-
100
- context "with all options" do
101
- let(:projects_dir){ '~/Projects' }
102
- let(:expected_options){ { projects: projects_dir, auto: true, bin: '/bin/custom-screen', screen: '-r -x', noop: true } }
103
- let(:argv){ [ '--projects', projects_dir, '--auto', '--bin', '/bin/custom-screen', '--screen', '-r -x', '--noop' ] }
104
- it_behaves_like "open"
105
- end
106
-
107
- def expect_success *args
108
- args = args.empty? ? expected_args + (expected_options.empty? ? [] : [ expected_options ]) : args
109
- Scide.should_receive(:open).with *args
110
- program = Scide::Program.new argv
111
- stdout, stderr = StringIO.new, StringIO.new
112
- $stdout, $stderr = stdout, stderr
113
- expect{ program.run! }.to_not raise_error
114
- $stdout, $stderr = STDOUT, STDERR
115
- expect(Paint.unpaint(stdout.string.chomp "\n")).to eq(expected_output)
116
- expect(stderr.string).to be_empty
117
- end
118
-
119
- def expect_failure message, expect_raise = false, code = 1, &block
120
- program = Scide::Program.new argv
121
- if expect_raise
122
- expect{ program.run! }.to raise_error(Scide::Error){ |e| expect(e.message).to eq(message) }
123
- else
124
- stderr = StringIO.new
125
- $stderr = stderr
126
- expect{ program.run! }.to raise_error(SystemExit){ |e| expect(e.status).to eq(code) }
127
- expect(Paint.unpaint(stderr.string.strip)).to eq(message)
128
- $stderr = STDERR
129
- end
130
- end
131
- end
@@ -1,82 +0,0 @@
1
- require 'helper'
2
-
3
- describe 'scide setup' do
4
-
5
- let(:argv){ [ 'setup' ] }
6
- let(:expected_args){ [] }
7
- let(:expected_options){ {} }
8
- let(:expected_output){ '' }
9
-
10
- before :each do
11
- Scide.stub :setup
12
- Scide.stub(:list).and_raise(StandardError.new('list should not be called'))
13
- Scide.stub(:open).and_raise(StandardError.new('open should not be called'))
14
- end
15
-
16
- shared_examples_for "setup" do
17
-
18
- let(:config_file){ '~/some/.screenrc' }
19
- let(:expected_output){ config_file }
20
-
21
- it "should output the path to the created file" do
22
- Scide.stub setup: '~/some/.screenrc'
23
- expect_success
24
- end
25
-
26
- context "if it fails" do
27
-
28
- before :each do
29
- Scide.stub(:setup).and_raise(Scide::Error.new('fubar'))
30
- end
31
-
32
- it "should output the error to stderr" do
33
- expect_failure "fubar#{Scide::Program::BACKTRACE_NOTICE}"
34
- end
35
-
36
- context "with the trace option" do
37
-
38
- let(:argv){ super().unshift '--trace' }
39
-
40
- it "should raise the error" do
41
- expect_failure "fubar", true
42
- end
43
- end
44
- end
45
- end
46
-
47
- it_behaves_like "setup"
48
-
49
- [ '-p', '--projects' ].each do |opt|
50
- context "with the #{opt} option" do
51
- let(:projects_dir){ '~/Projects' }
52
- let(:expected_options){ { projects: projects_dir } }
53
- let(:argv){ super() + [ opt, projects_dir ] }
54
- it_behaves_like "setup"
55
- end
56
- end
57
-
58
- def expect_success output = nil
59
- args = expected_args + (expected_options.empty? ? [] : [ expected_options ])
60
- Scide.should_receive(:setup).with *args
61
- program = Scide::Program.new argv
62
- stdout, stderr = StringIO.new, StringIO.new
63
- $stdout, $stderr = stdout, stderr
64
- expect{ program.run! }.to_not raise_error
65
- $stdout, $stderr = STDOUT, STDERR
66
- expect(Paint.unpaint(stdout.string.chomp "\n")).to eq(output || expected_output)
67
- expect(stderr.string).to be_empty
68
- end
69
-
70
- def expect_failure message, expect_raise = false, code = 1, &block
71
- program = Scide::Program.new argv
72
- if expect_raise
73
- expect{ program.run! }.to raise_error(Scide::Error){ |e| expect(e.message).to eq(message) }
74
- else
75
- stderr = StringIO.new
76
- $stderr = stderr
77
- expect{ program.run! }.to raise_error(SystemExit){ |e| expect(e.status).to eq(code) }
78
- $stderr = STDERR
79
- expect(Paint.unpaint(stderr.string.strip)).to eq(message)
80
- end
81
- end
82
- end