Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add template for consularc

  • Loading branch information...
commit b521b056b34614db6cfac2a205f3f0c81123a23b 1 parent 2f1d8f1
Arthur Chiu authored
1  lib/consular/cli.rb
View
@@ -82,6 +82,7 @@ def list
desc 'init', 'create consular directory'
def init
empty_directory Consular.global_path
+ template 'templates/consularc.tt', File.join(ENV['HOME'],'.consularc'), :skip => true
end
# Edit the specified global script or Termfile.
9 lib/templates/consularc.tt
View
@@ -0,0 +1,9 @@
+# You can require your additional core gems here.
+# require 'some_core_gem'
+
+# You can set specific Consular configurations
+# here.
+Consular.configure do |c|
+ # c.global_path = '~/.config/consular'
+ # c.default_editor = 'vim'
+end
39 spec/cli_spec.rb
View
@@ -12,17 +12,16 @@ def setup!; puts('setup'); end
describe Consular::CLI do
- def root_path(path = nil)
- File.join ENV['HOME'], '.config', 'consular', path
- end
-
before do
@template = File.read File.expand_path('../../lib/templates/example.yml.tt', __FILE__)
FakeFS.activate!
- FileUtils.mkdir_p root_path
+ FileUtils.mkdir_p Consular.global_path
end
- after { FakeFS.deactivate! }
+ after do
+ FakeFS.deactivate!
+ Consular.instance_variable_set(:@global_path, nil)
+ end
it "displays help" do
output = capture_io { Consular::CLI.start ['-h'] }.join('')
@@ -33,9 +32,9 @@ def root_path(path = nil)
end
it "lists out all global scripts" do
- File.open(root_path('foo.yml'), "w") { |f| f.puts @template }
- File.open(root_path('bar.term'), "w") { |f| f.puts @template }
- File.open(root_path('bar.term~'), "w") { |f| f.puts @template }
+ File.open(Consular.global_path('foo.yml'), "w") { |f| f.puts @template }
+ File.open(Consular.global_path('bar.term'), "w") { |f| f.puts @template }
+ File.open(Consular.global_path('bar.term~'), "w") { |f| f.puts @template }
output = capture_io { Consular::CLI.start ['list'] }.join('')
assert_match /foo\.yml - COMMENT OF SCRIPT HERE/, output
@@ -48,8 +47,8 @@ def root_path(path = nil)
before do
FileUtils.mkdir_p '/tmp'
FileUtils.touch '/tmp/Termfile'
- FileUtils.touch root_path('foo.term')
- FileUtils.touch root_path('foo.yml')
+ FileUtils.touch Consular.global_path('foo.term')
+ FileUtils.touch Consular.global_path('foo.yml')
Consular.add_core FakeCore
end
@@ -75,8 +74,8 @@ def root_path(path = nil)
before do
FileUtils.mkdir_p '/tmp'
FileUtils.touch '/tmp/Termfile'
- FileUtils.touch root_path('foo.term')
- FileUtils.touch root_path('foo.yml')
+ FileUtils.touch Consular.global_path('foo.term')
+ FileUtils.touch Consular.global_path('foo.yml')
Consular.add_core FakeCore
end
@@ -96,11 +95,11 @@ def root_path(path = nil)
end
end
- it "creates a new global script directory" do
- FileUtils.rm_rf root_path
+ it "init creates a new global script directory and consularc" do
+ FileUtils.rm_rf Consular.global_path
capture_io { Consular::CLI.start ['init'] }.join('')
- assert File.exists?(root_path), "global script directory exists"
+ assert File.exists?(Consular.global_path), "global script directory exists"
end
describe "delete command" do
@@ -114,17 +113,17 @@ def root_path(path = nil)
end
it "removes .yml files" do
- FileUtils.touch root_path('foo.yml')
+ FileUtils.touch Consular.global_path('foo.yml')
capture_io { Consular::CLI.start ['delete','foo.yml'] }
- refute File.exists?(root_path('foo.yml')), 'deletes .yml files'
+ refute File.exists?(Consular.global_path('foo.yml')), 'deletes .yml files'
end
it "removes .term file" do
- FileUtils.touch root_path('delete_this.term')
+ FileUtils.touch Consular.global_path('delete_this.term')
capture_io { Consular::CLI.start ['delete','delete_this'] }
- refute File.exists?(root_path('delete_this.term')), 'deletes .term file'
+ refute File.exists?(Consular.global_path('delete_this.term')), 'deletes .term file'
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.