gist 3.1.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ describe '...' do
2
+ before do
3
+ @saved_path = ENV['PATH']
4
+ @bobo_url = 'http://example.com'
5
+ end
6
+
7
+ after do
8
+ ENV['PATH'] = @saved_path
9
+ end
10
+
11
+ def ask_for_copy
12
+ Gist.on_success({'html_url' => @bobo_url}.to_json, :copy => true, :output => :html_url)
13
+ end
14
+ def gist_but_dont_ask_for_copy
15
+ Gist.on_success({'html_url' => 'http://example.com/'}.to_json, :output => :html_url)
16
+ end
17
+
18
+ it 'should try to copy the url when the clipboard option is passed' do
19
+ Gist.should_receive(:copy).with(@bobo_url)
20
+ ask_for_copy
21
+ end
22
+
23
+ it 'should try to copy the embed url when the clipboard-js option is passed' do
24
+ js_link = %Q{<script src="#{@bobo_url}.js"></script>}
25
+ Gist.should_receive(:copy).with(js_link)
26
+ Gist.on_success({'html_url' => @bobo_url}.to_json, :copy => true, :output => :javascript)
27
+ end
28
+
29
+ it "should not copy when not asked to" do
30
+ Gist.should_not_receive(:copy).with(@bobo_url)
31
+ gist_but_dont_ask_for_copy
32
+ end
33
+
34
+ it "should raise an error if no copying mechanisms are available" do
35
+ ENV['PATH'] = ''
36
+ lambda{
37
+ ask_for_copy
38
+ }.should raise_error(/Could not find copy command.*http/m)
39
+ end
40
+ end
@@ -0,0 +1,80 @@
1
+ describe '...' do
2
+
3
+ MOCK_GHE_HOST = 'ghe.example.com'
4
+ MOCK_GHE_PROTOCOL = 'http'
5
+ MOCK_USER = 'foo'
6
+ MOCK_PASSWORD = 'bar'
7
+
8
+ MOCK_AUTHZ_GHE_URL = "#{MOCK_GHE_PROTOCOL}://#{MOCK_USER}:#{MOCK_PASSWORD}@#{MOCK_GHE_HOST}/api/v3/"
9
+ MOCK_GHE_URL = "#{MOCK_GHE_PROTOCOL}://#{MOCK_GHE_HOST}/api/v3/"
10
+ MOCK_AUTHZ_GITHUB_URL = "https://#{MOCK_USER}:#{MOCK_PASSWORD}@api.github.com/"
11
+ MOCK_GITHUB_URL = "https://api.github.com/"
12
+
13
+ before do
14
+ @saved_env = ENV[Gist::URL_ENV_NAME]
15
+
16
+ # stub requests for /gists
17
+ stub_request(:post, /#{MOCK_GHE_URL}gists/).to_return(:body => %[{"html_url": "http://#{MOCK_GHE_HOST}"}])
18
+ stub_request(:post, /#{MOCK_GITHUB_URL}gists/).to_return(:body => '{"html_url": "http://github.com/"}')
19
+
20
+ # stub requests for /authorizations
21
+ stub_request(:post, /#{MOCK_AUTHZ_GHE_URL}authorizations/).
22
+ to_return(:status => 201, :body => '{"token": "asdf"}')
23
+ stub_request(:post, /#{MOCK_AUTHZ_GITHUB_URL}authorizations/).
24
+ to_return(:status => 201, :body => '{"token": "asdf"}')
25
+ end
26
+
27
+ after do
28
+ ENV[Gist::URL_ENV_NAME] = @saved_env
29
+ end
30
+
31
+ describe :login! do
32
+ before do
33
+ @saved_stdin = $stdin
34
+
35
+ # stdin emulation
36
+ $stdin = StringIO.new "#{MOCK_USER}\n#{MOCK_PASSWORD}\n"
37
+
38
+ # intercept for updating ~/.gist
39
+ File.stub(:open)
40
+ end
41
+
42
+ after do
43
+ $stdin = @saved_stdin
44
+ end
45
+
46
+ it "should access to api.github.com when $#{Gist::URL_ENV_NAME} wasn't set" do
47
+ ENV.delete Gist::URL_ENV_NAME
48
+
49
+ Gist.login!
50
+
51
+ assert_requested(:post, /#{MOCK_AUTHZ_GITHUB_URL}authorizations/)
52
+ end
53
+
54
+ it "should access to #{MOCK_GHE_HOST} when $#{Gist::URL_ENV_NAME} was set" do
55
+ ENV[Gist::URL_ENV_NAME] = MOCK_GHE_URL
56
+
57
+ Gist.login!
58
+
59
+ assert_requested(:post, /#{MOCK_AUTHZ_GHE_URL}authorizations/)
60
+ end
61
+ end
62
+
63
+ describe :gist do
64
+ it "should access to api.github.com when $#{Gist::URL_ENV_NAME} wasn't set" do
65
+ ENV.delete Gist::URL_ENV_NAME
66
+
67
+ Gist.gist "test gist"
68
+
69
+ assert_requested(:post, /#{MOCK_GITHUB_URL}gists/)
70
+ end
71
+
72
+ it "should access to #{MOCK_GHE_HOST} when $#{Gist::URL_ENV_NAME} was set" do
73
+ ENV[Gist::URL_ENV_NAME] = MOCK_GHE_URL
74
+
75
+ Gist.gist "test gist"
76
+
77
+ assert_requested(:post, /#{MOCK_GHE_URL}gists/)
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,23 @@
1
+ describe Gist do
2
+
3
+ describe "should_be_public?" do
4
+ it "should return false if -p is specified" do
5
+ Gist.should_be_public?(private: true).should be_false
6
+ end
7
+
8
+ it "should return false if legacy_private_gister?" do
9
+ Gist.should_receive(:legacy_private_gister?).and_return(true)
10
+ Gist.should_be_public?.should be_false
11
+ end
12
+
13
+ it "should return true if --no-private is specified" do
14
+ Gist.stub(:legacy_private_gister?).and_return(true)
15
+ Gist.should_be_public?(private: false).should be_true
16
+ end
17
+
18
+ it "should return true by default" do
19
+ Gist.should_be_public?.should be_true
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,21 @@
1
+ describe '...' do
2
+ before do
3
+ @saved_env = ENV['HTTP_PROXY']
4
+ end
5
+
6
+ after do
7
+ ENV['HTTP_PROXY'] = @saved_env
8
+ end
9
+
10
+ FOO_URL = URI('http://ddg.gg/')
11
+
12
+ it "should be Net::HTTP when $HTTP_PROXY wasn't set" do
13
+ ENV['HTTP_PROXY'] = ''
14
+ Gist.http_connection(FOO_URL).should be_an_instance_of(Net::HTTP)
15
+ end
16
+
17
+ it "should be Net::HTTP::Proxy when $HTTP_PROXY was set" do
18
+ ENV['HTTP_PROXY'] = 'http://proxy.example.com:8080'
19
+ Gist.http_connection(FOO_URL).should_not be_an_instance_of(Net::HTTP)
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ describe '...' do
2
+ before do
3
+ stub_request(:post, /api\.github.com\/gists/).to_return(:body => '{"html_url": "http://github.com/"}')
4
+ stub_request(:post, "http://git.io/").to_return(:status => 201, :headers => { 'Location' => 'http://git.io/XXXXXX' })
5
+ end
6
+
7
+ it "should return a shortened version of the URL" do
8
+ Gist.gist("Test gist", :output => :short_url, :anonymous => true).should == "http://git.io/XXXXXX"
9
+ end
10
+ end
11
+
@@ -0,0 +1,15 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper.rb"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+ end
12
+
13
+ require 'webmock/rspec'
14
+ require_relative '../lib/gist'
15
+
metadata CHANGED
@@ -1,41 +1,124 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gist
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 4.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Chris Wanstrath
9
- - André Arko
8
+ - Conrad Irwin
9
+ - ☈king
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-20 00:00:00.000000000 Z
14
- dependencies: []
15
- description: ! " Creates Gists (pastes) on gist.github.com from standard input or\n
16
- \ arbitrary files. Can link to your GitHub account, create private gists,\n and
17
- enable syntax highlighting.\n"
18
- email: andre@arko.net
13
+ date: 2013-05-03 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: json
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rake
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: webmock
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: ronn
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ description: Provides a single function (Gist.gist) that uploads a gist.
96
+ email:
97
+ - conrad.irwin@gmail.com
98
+ - rkingist@sharpsaw.org
19
99
  executables:
20
100
  - gist
21
101
  extensions: []
22
102
  extra_rdoc_files: []
23
103
  files:
24
- - README.markdown
104
+ - .gitignore
105
+ - .rspec
106
+ - Gemfile
107
+ - LICENSE.MIT
108
+ - README.md
25
109
  - Rakefile
26
- - LICENSE
27
- - lib/gist/cacert.pem
28
- - lib/gist/json.rb
29
- - lib/gist/manpage.rb
30
- - lib/gist/standalone.rb
31
- - lib/gist/version.rb
32
- - lib/gist.rb
33
110
  - bin/gist
34
- - man/gist.1
35
- - man/gist.1.html
36
- - man/gist.1.ron
37
- homepage: http://github.com/defunkt/gist
38
- licenses: []
111
+ - gist.gemspec
112
+ - lib/gist.rb
113
+ - spec/clipboard_spec.rb
114
+ - spec/ghe_spec.rb
115
+ - spec/gist_spec.rb
116
+ - spec/proxy_spec.rb
117
+ - spec/shorten_spec.rb
118
+ - spec/spec_helper.rb
119
+ homepage: https://github.com/defunkt/gist
120
+ licenses:
121
+ - MIT
39
122
  post_install_message:
40
123
  rdoc_options: []
41
124
  require_paths:
@@ -54,9 +137,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
137
  version: '0'
55
138
  requirements: []
56
139
  rubyforge_project:
57
- rubygems_version: 1.8.24
140
+ rubygems_version: 1.8.23
58
141
  signing_key:
59
142
  specification_version: 3
60
- summary: Creates Gists from STDIN or files.
143
+ summary: Just allows you to upload gists
61
144
  test_files: []
62
- has_rdoc: false
145
+ has_rdoc:
data/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2008 Chris Wanstrath
2
- json-pure Copyright Genki Takiuchi
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of
5
- this software and associated documentation files (the "Software"), to deal in
6
- the Software without restriction, including without limitation the rights to
7
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
- the Software, and to permit persons to whom the Software is furnished to do so,
9
- subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all
12
- copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,121 +0,0 @@
1
- Gist: The Script
2
- ================
3
-
4
- Works great with Gist: The Website.
5
-
6
- Installation
7
- ------------
8
-
9
- [homebrew](http://mxcl.github.com/homebrew/):
10
-
11
- ```bash
12
- $ brew install gist
13
- $ gist -h
14
- ```
15
-
16
- RubyGems:
17
-
18
- ```bash
19
- $ gem install gist
20
- $ gist -h
21
- ```
22
-
23
- Old school:
24
-
25
- ```bash
26
- $ curl -s https://raw.github.com/defunkt/gist/master/gist > gist &&
27
- $ chmod 755 gist &&
28
- $ mv gist /usr/local/bin/gist
29
- ```
30
-
31
- Ubuntu:
32
-
33
- ```bash
34
- $ sudo apt-get install ruby
35
- $ sudo apt-get install rubygems
36
- $ sudo apt-get install libopenssl-ruby
37
- $ sudo gem install gist
38
- $ sudo cp /var/lib/gems/1.8/bin/gist /usr/local/bin/
39
- $ gist -h
40
- ```
41
-
42
- Use
43
- ---
44
-
45
- ```bash
46
- $ gist < file.txt
47
- $ echo secret | gist --private # or -p
48
- $ echo "puts :hi" | gist -t rb
49
- $ gist script.py
50
- $ gist script.js notes.txt
51
- $ pbpaste | gist -p # Copy from clipboard - OSX Only
52
- $ gist -
53
- the quick brown fox jumps over the lazy dog
54
- ^D
55
- ```
56
-
57
- Authentication
58
- --------------
59
- There are two ways to set GitHub user and password info:
60
-
61
- Using env vars GITHUB_USER and GITHUB_PASSWORD:
62
-
63
- ```bash
64
- $ export GITHUB_USER="your-github-username"
65
- $ export GITHUB_PASSWORD="your-github-password"
66
- $ gist ~/example
67
- ```
68
-
69
- Or by having your git config set up with your GitHub username and password.
70
-
71
- ```bash
72
- git config --global github.user "your-github-username"
73
- git config --global github.password "your-github-password"
74
- ```
75
-
76
- You can also define github.password to be a command which returns the
77
- actual password on stdout by setting the variable to a command string
78
- prefixed with `!`. For example, the following command fetches the
79
- password from an item named "github.password" on the Mac OS
80
- Keychain:
81
-
82
- ```bash
83
- password = !security find-generic-password -gs github.password -w | tr -d '\n'
84
- ```
85
-
86
- Defaults
87
- --------
88
-
89
- You can set a few options in your git config (using git-config(1)) to
90
- control the default behavior of gist(1).
91
-
92
- * gist.private - boolean (yes or no) - Determines whether to make a gist
93
- private by default
94
-
95
- * gist.extension - string - Default extension for gists you create.
96
-
97
- * gist.browse - boolean (yes or no) - Whether to open the gist in your
98
- browser after creation. Default: yes
99
-
100
- Proxies
101
- -------
102
-
103
- Set the HTTP_PROXY env variable to use a proxy.
104
-
105
- ```bash
106
- $ HTTP_PROXY=host:port gist file.rb
107
- ```
108
-
109
- Manual
110
- ------
111
-
112
- Visit <http://defunkt.github.com/gist/> or use:
113
-
114
- ```bash
115
- $ gist -m
116
- ```
117
-
118
- Bugs
119
- ----
120
-
121
- <https://github.com/defunkt/gist/issues>