Skip to content

Commit

Permalink
Support --no-private
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed May 3, 2013
1 parent bd69d87 commit 3831471
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions bin/gist
Expand Up @@ -59,8 +59,12 @@ Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-d DESC] -a] [-u URL] [-P] [-f N
options[:filename] = "foo.#{extension}"
end

opts.on("-p", "--private", "Makes your gist private.") do |private|
options[:private] = private
opts.on("-p", "--private", "Makes your gist private.") do
options[:private] = true
end

opts.on("--no-private") do
options[:private] = false
end

opts.on("-d", "--description DESCRIPTION", "Adds a description to your gist.") do |description|
Expand Down
6 changes: 5 additions & 1 deletion lib/gist.rb
Expand Up @@ -350,6 +350,10 @@ def legacy_private_gister?
end

def should_be_public?(options={})
!(options[:private] || Gist.legacy_private_gister?)
if options.key? :private
!options[:private]
else
!Gist.legacy_private_gister?
end
end
end
5 changes: 5 additions & 0 deletions spec/gist_spec.rb
Expand Up @@ -10,6 +10,11 @@
Gist.should_be_public?.should be_false
end

it "should return true if --no-private is specified" do
Gist.stub(:legacy_private_gister?).and_return(true)
Gist.should_be_public?(private: false).should be_true
end

it "should return true by default" do
Gist.should_be_public?.should be_true
end
Expand Down

0 comments on commit 3831471

Please sign in to comment.