dougsko-pastebin 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ # Command line interface to http://pastebin.ca
2
+ # Copyright (C) 2009 dougsko
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
data/README.rdoc ADDED
@@ -0,0 +1,20 @@
1
+ = pastebin
2
+
3
+ paster.rb is a CLI to http://pastebin.ca
4
+ Usage: pastebin [options]
5
+ Examples: pastebin -f foo.rb -t ruby -e '1 d'
6
+ cat foo.pl | pastebin -f - -t perl
7
+
8
+ Options:
9
+ -f, --file <file> Use a file for input, use "-" for STDIN
10
+ -n, --name <name> Assign a name/title to your paste
11
+ -d, --desc <description> Give your paste a description
12
+ -e, --expire <time> These can be abbriviated, as long as they are unambigous. Defaults to '1 hour'
13
+ never, 5 minutes, 10 minutes, 15 minutes, 30 minutes, 45 minutes, 1 hour, 2 hours, 4 hours, 8 hours, 12 hours, 1 day, 2 days, 3 days, 1 week, 2 weeks, 3 weeks, 1 month, 2 months, 3 months, 4 months, 5 months, 6 months, 1 year
14
+ -t, --type <syntax> Syntax types can be abbriviated, as long as they are unambigous. Defaults to 'raw'
15
+ action, ada, apache configuration, assembly (nasm), asterisk configuration, bash, c, c#, c++, css, delphi, html 4.0 strict, java, lisp, lua, microprocessor asm, mirc , objective c, pascal, perl, php, pl/i, python, raw, ruby, scheme, sql statement, visual basic, visual basic .net, xml document
16
+ -h, --help Show this message
17
+
18
+ == Copyright
19
+
20
+ Copyright (c) 2009 dougsko. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "pastebin"
8
+ gem.summary = %Q{Command line interface to http://pastebin.ca}
9
+ gem.email = "dougtko@gmail.com"
10
+ gem.homepage = "http://github.com/dougsko/pastebin"
11
+ gem.authors = ["dougsko"]
12
+ gem.description = 'Command line interface to http://pastebin.ca'
13
+ gem.add_dependency 'httpclient'
14
+ gem.require_paths = ['/bin']
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
20
+ end
21
+
22
+ require 'spec/rake/spectask'
23
+ Spec::Rake::SpecTask.new(:spec) do |spec|
24
+ spec.libs << 'lib' << 'spec'
25
+ spec.spec_files = FileList['spec/**/*_spec.rb']
26
+ end
27
+
28
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.rcov = true
32
+ end
33
+
34
+
35
+ task :default => :spec
36
+
37
+ require 'rake/rdoctask'
38
+ Rake::RDocTask.new do |rdoc|
39
+ if File.exist?('VERSION.yml')
40
+ config = YAML.load(File.read('VERSION.yml'))
41
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
42
+ else
43
+ version = ""
44
+ end
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "pastebin #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
51
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
data/bin/pastebin ADDED
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # pastebin is a command line interface to pastebin.ca
4
+ # It can read from a file or from STDIN
5
+ #
6
+ # Copyright (C) 2007 Doug Prostko
7
+ #
8
+ # Requires the httpclient
9
+
10
+ require 'rubygems'
11
+ require 'yaml'
12
+ require 'optparse'
13
+ require 'httpclient'
14
+
15
+ CONFIG="#{ENV['HOME']}/.paster.yaml"
16
+
17
+ # set up all the options stuff
18
+ options = {"type" => "1"}
19
+ opts = OptionParser.new do |opts|
20
+ opts.banner = "paster.rb is a CLI to http://pastebin.ca
21
+ Usage: pastebin [options]
22
+ Examples: pastebin -f foo.rb -t ruby -e '1 d'
23
+ cat foo.pl | pastebin -f - -t perl"
24
+
25
+ opts.separator ""
26
+ opts.separator "Options:"
27
+
28
+ opts.on("-f <file>", "--file <file>", String,
29
+ "Use a file for input, use \"-\" for STDIN") do |f|
30
+ options["content"] = f
31
+ end
32
+
33
+ opts.on("-n", "--name <name>", String,
34
+ "Assign a name/title to your paste") do |n|
35
+ options["name"] = n
36
+ end
37
+
38
+ opts.on("-d", "--desc <description>", Array,
39
+ "Give your paste a description") do |d|
40
+ options["description"] = d
41
+ end
42
+
43
+ expire_array = [ "never",
44
+ "5 minutes",
45
+ "10 minutes",
46
+ "15 minutes",
47
+ "30 minutes",
48
+ "45 minutes",
49
+ "1 hour",
50
+ "2 hours",
51
+ "4 hours",
52
+ "8 hours",
53
+ "12 hours",
54
+ "1 day",
55
+ "2 days",
56
+ "3 days",
57
+ "1 week",
58
+ "2 weeks",
59
+ "3 weeks",
60
+ "1 month",
61
+ "2 months",
62
+ "3 months",
63
+ "4 months",
64
+ "5 months",
65
+ "6 months",
66
+ "1 year"
67
+ ]
68
+ expire_list = expire_array.join(", ")
69
+ opts.on("-e", "--expire <time>", expire_array, "These can be abbriviated, as long as they are unambigous. Defaults to '1 month'", "#{expire_list}" ) do |e|
70
+ options["expiry"] = e
71
+ end
72
+
73
+ syntax_hash = { "action" => "18",
74
+ "ada" => "19",
75
+ "apache configuration" => "20",
76
+ "assembly (nasm)" => "21",
77
+ "asterisk configuration" => "2",
78
+ "bash" => "23",
79
+ "c" => "3",
80
+ "c#" => "9",
81
+ "c++" => "4",
82
+ "css" => "24",
83
+ "delphi" => "25",
84
+ "html 4.0 strict" => "26",
85
+ "java" => "7",
86
+ "java" => "27",
87
+ "lisp" => "28",
88
+ "lua" => "29",
89
+ "microprocessor asm" => "30",
90
+ "objective c" => "31",
91
+ "php" => "5", "pl/i" => "14",
92
+ "pascal" => "12",
93
+ "perl" => "6",
94
+ "python" => "11",
95
+ "raw" => "1",
96
+ "ruby" => "10",
97
+ "sql statement" => "16",
98
+ "scheme" => "17",
99
+ "visual basic .net" => "32",
100
+ "visual basic" => "8",
101
+ "xml document" => "15",
102
+ "mirc " => "13"
103
+ }
104
+ code_list = syntax_hash.keys.sort.join(", ")
105
+ opts.on("-t", "--type <syntax>", syntax_hash, "Syntax types can be abbriviated, as long as they are unambigous. Defaults to 'raw'", " #{code_list}") do |encoding|
106
+ options["type"] = encoding
107
+ end
108
+
109
+ opts.on_tail("-h", "--help", "Show this message") do
110
+ puts opts
111
+ exit
112
+ end
113
+ end
114
+
115
+ # parse options
116
+ opts.parse(ARGV)
117
+
118
+ # check for config file and read in API key
119
+ if File.exists? CONFIG
120
+ config = YAML.load(File.open(CONFIG))
121
+ else
122
+ config = {}
123
+ puts "Please enter your API key. You'll only have to do this once."
124
+ print "You can get a key here: http://pastebin.ca/apikey.php \n "
125
+ config['key'] = gets.chomp
126
+ options["api"] = config['key']
127
+ open(CONFIG, 'w'){ |f| YAML.dump(config, f) }
128
+ puts "Thank you. Please run the script again. Run #{$0} --help to see all the options."
129
+ exit
130
+ end
131
+
132
+ # content
133
+ if options.has_key?("content")
134
+ if options["content"] == "-"
135
+ options["content"] = $stdin.read
136
+ else
137
+ File.open(options["content"]) do |file|
138
+ options["content"] = file.read
139
+ end
140
+ end
141
+ else
142
+ puts opts
143
+ end
144
+
145
+ clnt = HTTPClient.new("http://pastebin.ca/quiet-paste.php")
146
+ clnt.post("http://pastebin.ca/quiet-paste.php", options).content[/(\w+):([\w\s]+)/]
147
+ success_fail = $1
148
+ code_reason = $2
149
+ if success_fail == "SUCCESS"
150
+ puts "http://pastebin.ca/" + code_reason
151
+ elsif success_fail == "FAIL"
152
+ puts "#{$0} Error: #{$2}"
153
+ else
154
+ puts "#{$0} Error: Unknown Error"
155
+ end
data/pastebin.gemspec ADDED
@@ -0,0 +1,52 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{pastebin}
5
+ s.version = "0.0.3"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["dougsko"]
9
+ s.date = %q{2009-06-24}
10
+ s.default_executable = %q{pastebin}
11
+ s.description = %q{Command line interface to http://pastebin.ca}
12
+ s.email = %q{dougtko@gmail.com}
13
+ s.executables = ["pastebin"]
14
+ s.extra_rdoc_files = [
15
+ "LICENSE",
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "bin/pastebin",
26
+ "pastebin.gemspec",
27
+ "spec/pastebin_spec.rb",
28
+ "spec/spec_helper.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/dougsko/pastebin}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["/bin"]
33
+ s.rubygems_version = %q{1.3.4}
34
+ s.summary = %q{Command line interface to http://pastebin.ca}
35
+ s.test_files = [
36
+ "spec/pastebin_spec.rb",
37
+ "spec/spec_helper.rb"
38
+ ]
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<httpclient>, [">= 0"])
46
+ else
47
+ s.add_dependency(%q<httpclient>, [">= 0"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<httpclient>, [">= 0"])
51
+ end
52
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Pastebin" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require 'pastebin'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dougsko-pastebin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - dougsko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-24 00:00:00 -07:00
13
+ default_executable: pastebin
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httpclient
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Command line interface to http://pastebin.ca
26
+ email: dougtko@gmail.com
27
+ executables:
28
+ - pastebin
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - .document
36
+ - .gitignore
37
+ - LICENSE
38
+ - README.rdoc
39
+ - Rakefile
40
+ - VERSION
41
+ - bin/pastebin
42
+ - pastebin.gemspec
43
+ - spec/pastebin_spec.rb
44
+ - spec/spec_helper.rb
45
+ has_rdoc: false
46
+ homepage: http://github.com/dougsko/pastebin
47
+ post_install_message:
48
+ rdoc_options:
49
+ - --charset=UTF-8
50
+ require_paths:
51
+ - /bin
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.2.0
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Command line interface to http://pastebin.ca
71
+ test_files:
72
+ - spec/pastebin_spec.rb
73
+ - spec/spec_helper.rb