Skip to content

Commit 7af8848

Browse files
committed
Commit to move to Github from local
1 parent c107661 commit 7af8848

4 files changed

Lines changed: 70 additions & 0 deletions

File tree

lib/buff.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
require "buff/datastructure"
1616
require "buff/info"
1717
require "buff/client"
18+
require "buff/setup"
1819

1920
module Buff
2021
end

lib/buff/error.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
module Buff
2+
#TODO: refactor errors into Error Module and fix references
23
InvalidIdLength = Class.new(ArgumentError)
34
InvalidIdContent = Class.new(ArgumentError)
45
MissingStatus = Class.new(ArgumentError)
56
APIError = Class.new(StandardError)
67
UnauthorizeRequest = Class.new(StandardError)
8+
9+
module Error
10+
ConfigFileMissing = Class.new(StandardError)
11+
end
712
end

lib/buff/setup.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module Buff
2+
RC_VERSION = "0.0.1"
3+
class Setup
4+
5+
def initialize(args="~/.bufferapprc")
6+
@path = Pathname.new(args)
7+
if exists?
8+
@content = YAML.load_file(File.expand_path path)
9+
else
10+
raise Buff::Error::ConfigFileMissing
11+
end
12+
end
13+
14+
def path
15+
@path.to_s
16+
end
17+
18+
def exists?
19+
File.exists?(File.expand_path path)
20+
end
21+
22+
end
23+
end

spec/lib/buff/setup_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
require "spec_helper"
2+
3+
describe Buff::Setup do
4+
5+
let(:bad_config_setup) { Buff::Setup.new "~/notpresentexample" }
6+
let(:setup) { Buff::Setup.new }
7+
8+
context "pathname" do
9+
it "sets the default path" do
10+
expect(setup.path).to eq("~/.bufferapprc")
11+
end
12+
it "fails with error when specified file not found" do
13+
lambda { bad_config_setup.path }.should
14+
raise_error(Buff::Error::ConfigFileMissing)
15+
end
16+
end
17+
context "verifies whether rc file exists" do
18+
it "documents when rc file not present" do
19+
expect(bad_config_setup.exists?).to eq(false)
20+
end
21+
it "documents when rc file is present" do
22+
expect(setup.exists?).to eq(true)
23+
end
24+
end
25+
context "determines if rc file is the most current version" do
26+
it "checks current RC_VERSION" do
27+
expect( Buff::RC_VERSION ).to_not eq(nil)
28+
end
29+
30+
it "reports error when file is out of date" do
31+
end
32+
it "returns true when current"
33+
end
34+
context "when rc file is current"
35+
it "exits without altering state"
36+
context "when rc file is not present"
37+
it "verifies that rc file doesn't exist"
38+
it "creates an rc file and prompts for authorization"
39+
40+
context "when rc file is out of date"
41+
end

0 commit comments

Comments
 (0)