togist 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in togist.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Mike Splain
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # ToGist
2
+ A simple app that will send command line output into a private or public gist, copy the url to your clipboard, and (if requested) open that url in your browser.
3
+
4
+ ## Requirements
5
+ This gem is designed for use on Mac OSX.
6
+
7
+
8
+ ## Installation
9
+
10
+ Run this command in your terminal:
11
+
12
+ gem 'togist'
13
+
14
+ Or install it yourself:
15
+
16
+ $ rake install togist
17
+
18
+ ###Rbenv
19
+ You'll probably need to run:
20
+ rbenv rehash
21
+
22
+ ## Usage
23
+
24
+ Output files or commands and pipe them into either shortcut:
25
+ echo 'foo' | 2g
26
+ cat foo.rb | 2g
27
+ ###Shortcuts:
28
+ 2g : Uploads to private gist and copies gist url to mac clipboard
29
+ 2gpub : Same as above except public
30
+ ###Tips:
31
+ Add an 'o' to the end of a shortcut to make it open your browser to the gist
32
+ echo 'foo' | 2go # Will open to the private gist url
33
+ echo 'foo' | 2gpubo # Will open to the public gist url
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => [:install]
data/bin/2g ADDED
@@ -0,0 +1,6 @@
1
+ require 'togist'
2
+
3
+ run2g
4
+
5
+
6
+
data/bin/2go ADDED
@@ -0,0 +1,8 @@
1
+ require 'togist'
2
+
3
+ @open=true
4
+
5
+ run2g
6
+
7
+
8
+
data/bin/2gpub ADDED
@@ -0,0 +1,3 @@
1
+ require 'togist'
2
+
3
+ run2gpub
data/bin/2gpubo ADDED
@@ -0,0 +1,5 @@
1
+ require 'togist'
2
+
3
+ @open = true
4
+
5
+ run2gpub
data/bin/2pub ADDED
@@ -0,0 +1,3 @@
1
+ require 'togist'
2
+
3
+ run2gpub
data/bin/togist ADDED
@@ -0,0 +1,3 @@
1
+ require 'togist'
2
+
3
+ togist
@@ -0,0 +1,3 @@
1
+ module Togist
2
+ VERSION = "1.0"
3
+ end
data/lib/togist.rb ADDED
@@ -0,0 +1,62 @@
1
+ require "togist/version"
2
+
3
+ module Togist
4
+
5
+ end
6
+
7
+ def togist
8
+ if checkIfPiped
9
+ run2g
10
+ else
11
+ help
12
+ end
13
+
14
+ end
15
+
16
+ def help
17
+ puts "ToGist #{Togist::VERSION}, the simple way to gist\n\n"
18
+ puts "Usage:"
19
+ puts " Output files or commands and pipe them into either shortcut"
20
+ puts " e.g.:"
21
+ puts " echo 'foo' | 2g"
22
+ puts " cat foo.rb | 2g\n\n"
23
+ puts "Shortcuts:"
24
+ puts " 2g : Uploads to private gist and copies gist url to mac clipboard"
25
+ puts " 2gpub : Same as above except public\n\n"
26
+ puts "Tips:"
27
+ puts " Add an 'o' to the end of a shortcut to make it open your browser to the gist"
28
+ puts " e.g.:"
29
+ puts " echo 'foo' | 2go # Will open to the private gist url"
30
+ puts " echo 'foo' | 2gpubo # Will open to the public gist url"
31
+
32
+ end
33
+
34
+ def run2g
35
+ out = `gist -p`
36
+
37
+ checkoutput(out)
38
+ end
39
+
40
+ def run2gpub
41
+ out = `gist`
42
+
43
+ checkoutput(out)
44
+ end
45
+
46
+ def checkoutput(out)
47
+ if STDIN.tty? || out.include?("Usage: gist [options]")
48
+ puts "Oops, you forgot to pipe something to ToGist\n\n"
49
+ help
50
+ elsif out.include?("getaddrinfo") || out.include?("Error")
51
+ puts "There was an unknown error. Are you sure you can connect to github? \n\n"
52
+ help
53
+ else
54
+ final = `echo '#{out}' | pbcopy`
55
+ puts "Gist: #{out} (copied to clipboard)"
56
+ `open #{out}` if @open
57
+ end
58
+ end
59
+
60
+ def checkIfPiped
61
+ return !STDIN.tty?
62
+ end
data/togist.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'togist/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "togist"
8
+ gem.version = Togist::VERSION
9
+ gem.authors = ["Mike Splain"]
10
+ gem.email = ["mike.splain@gmail.com"]
11
+ gem.description = %q{A simple wrapper to send something to gist & copy to clipboard on mac}
12
+ gem.summary = %q{A simple wrapper to send something to gist & copy to clipboard on mac}
13
+ gem.homepage = "http://github.com/mikesplain/togist"
14
+
15
+ gem.add_development_dependency "rake"
16
+ gem.add_development_dependency "gist"
17
+
18
+ gem.files = `git ls-files`.split($/)
19
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
20
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
+ gem.require_paths = ["lib","bin"]
22
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: togist
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: '1.0'
6
+ platform: ruby
7
+ authors:
8
+ - Mike Splain
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ type: :development
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ name: rake
23
+ prerelease: false
24
+ requirement: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ type: :development
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ name: gist
39
+ prerelease: false
40
+ requirement: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: A simple wrapper to send something to gist & copy to clipboard on mac
47
+ email:
48
+ - mike.splain@gmail.com
49
+ executables:
50
+ - 2g
51
+ - 2go
52
+ - 2gpub
53
+ - 2gpubo
54
+ - 2pub
55
+ - togist
56
+ extensions: []
57
+ extra_rdoc_files: []
58
+ files:
59
+ - .gitignore
60
+ - Gemfile
61
+ - LICENSE.txt
62
+ - README.md
63
+ - Rakefile
64
+ - bin/2g
65
+ - bin/2go
66
+ - bin/2gpub
67
+ - bin/2gpubo
68
+ - bin/2pub
69
+ - bin/togist
70
+ - lib/togist.rb
71
+ - lib/togist/version.rb
72
+ - togist.gemspec
73
+ homepage: http://github.com/mikesplain/togist
74
+ licenses: []
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ - bin
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ segments:
86
+ - 0
87
+ hash: -3309757754023245034
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ segments:
95
+ - 0
96
+ hash: -3309757754023245034
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 1.8.23
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: A simple wrapper to send something to gist & copy to clipboard on mac
104
+ test_files: []