privatepaste 0.0.1

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
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ gem "httpclient"
9
+ group :development do
10
+ gem "rake", "0.8.7"
11
+ gem "rspec", "~> 2.3.0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.6.3"
14
+ gem "rcov", ">= 0"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,31 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ git (1.2.5)
6
+ httpclient (2.2.1)
7
+ jeweler (1.6.3)
8
+ bundler (~> 1.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ rake (0.8.7)
12
+ rcov (0.9.9)
13
+ rspec (2.3.0)
14
+ rspec-core (~> 2.3.0)
15
+ rspec-expectations (~> 2.3.0)
16
+ rspec-mocks (~> 2.3.0)
17
+ rspec-core (2.3.1)
18
+ rspec-expectations (2.3.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.3.0)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ bundler (~> 1.0.0)
27
+ httpclient
28
+ jeweler (~> 1.6.3)
29
+ rake (= 0.8.7)
30
+ rcov
31
+ rspec (~> 2.3.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,14 @@
1
+ Copyright (c) 2011 Doug P.
2
+
3
+ This program is free software: you can redistribute it and/or modify
4
+ it under the terms of the GNU General Public License as published by
5
+ the Free Software Foundation, either version 3 of the License, or
6
+ (at your option) any later version.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ GNU General Public License for more details.
12
+
13
+ You should have received a copy of the GNU General Public License
14
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = privatepaste
2
+
3
+ A CLI client for privatepaste.com
4
+
5
+ == Contributing to privatepaste
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Doug P. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "privatepaste"
18
+ gem.homepage = "http://github.com/dougsko/privatepaste"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A CLI for privatepaste.com}
21
+ gem.description = %Q{A CLI for privatepaste.com}
22
+ gem.email = "dougtko@gmail.com"
23
+ gem.authors = ["Doug P."]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "privatepaste #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/privatepaste ADDED
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Command line interface for privatepaste.com
4
+ #
5
+
6
+ require 'rubygems'
7
+ require 'optparse'
8
+ require 'lib/privatepaste'
9
+
10
+ options = {}
11
+ options["secure_paste_key"] = ""
12
+ opts = OptionParser.new do |opts|
13
+ opts.banner = "privatepaste is a CLI to https://privatepaste.com
14
+ Usage: privatepaste <options>
15
+ Example: privatepaste -f foo.rb -t ruby -e '5 min'"
16
+
17
+ opts.separator ""
18
+ opts.separator "Options:"
19
+
20
+ opts.on("-f <file>",
21
+ "--file <file>",
22
+ String,
23
+ "Use a file for input, use \"-\" for STDIN") do |f|
24
+ options["paste_content"] = f
25
+ end
26
+
27
+ syntax_array = ['ActionScript',
28
+ 'AppleScript',
29
+ 'Apache',
30
+ 'Bash',
31
+ 'BBCode',
32
+ 'Boo',
33
+ 'C',
34
+ 'Clojure',
35
+ 'CSS',
36
+ 'C++',
37
+ 'C#',
38
+ 'Delphi',
39
+ 'Diff',
40
+ 'Erlang',
41
+ 'Fortran',
42
+ 'Haskell',
43
+ 'HTML',
44
+ 'INI',
45
+ 'IRC',
46
+ 'Java',
47
+ 'JavaScript',
48
+ 'JSP',
49
+ 'Lighthttpd',
50
+ 'LUA',
51
+ 'Makefile',
52
+ 'Matlab',
53
+ 'NASM',
54
+ 'Nginx',
55
+ 'Objective C',
56
+ 'OCaml',
57
+ 'Pascal',
58
+ 'Perl',
59
+ 'PHP',
60
+ 'Python',
61
+ 'Rst',
62
+ 'Ruby',
63
+ 'Scheme',
64
+ 'Smalltalk',
65
+ 'Smarty',
66
+ 'Squid',
67
+ 'SQL',
68
+ 'TeX',
69
+ 'TCL',
70
+ 'Wiki',
71
+ 'VBNet',
72
+ 'VimL',
73
+ 'XML',
74
+ 'XSLT',
75
+ 'YAML'
76
+ ]
77
+
78
+ syntax_list = syntax_array.join(", ")
79
+ opts.on("-l",
80
+ "--language <syntax>",
81
+ syntax_array,
82
+ "Syntax types can be abbriviated, as long as they are unambigous.",
83
+ " #{syntax_list}") do |encoding|
84
+ options["formatting"] = encoding
85
+ end
86
+
87
+ opts.on("-l", "--lines", "Show line numbers.") do
88
+ options["line_numbers"] = "on"
89
+ end
90
+
91
+ expire_hash = {'5 min' => '360',
92
+ '15 min' => '900',
93
+ '30 min' => '1800',
94
+ '1 hour' => '3600',
95
+ '1 day' => '86400',
96
+ '5 days' => '432000',
97
+ '1 week' => '604800',
98
+ '1 month' => '2592000',
99
+ '3 months' => '7776000',
100
+ '6 months' => '15552000',
101
+ '1 year' => '31536000'
102
+ }
103
+
104
+ expire_array = []
105
+ expire_hash.each do |k,v|
106
+ expire_array << k
107
+ end
108
+ expire_list = expire_array.join(", ")
109
+ opts.on("-e",
110
+ "--expire <time>",
111
+ expire_array,
112
+ "These can be abbriviated, as long as they are unambigous.",
113
+ "#{expire_list}" ) do |e|
114
+ options["expire"] = expire_hash[e]
115
+ end
116
+
117
+ opts.on("-k",
118
+ "--key <password>",
119
+ String,
120
+ "Protect your paste with a password.") do |k|
121
+ options["secure_paste"] = "on"
122
+ options["secure_paste_key"] = k
123
+ end
124
+
125
+ opts.on("-r",
126
+ "--raw <link>",
127
+ String,
128
+ "Return the text of a paste.") do |r|
129
+ options["link"] = r
130
+ end
131
+
132
+ opts.on_tail("-h", "--help", "Show this message") do
133
+ puts opts
134
+ exit
135
+ end
136
+ end
137
+
138
+ opts.parse(ARGV)
139
+ privpaste = Privatepaste.new(options)
140
+ if options["link"]
141
+ puts privpaste.get_raw
142
+ else
143
+ puts privpaste.paste
144
+ end
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Command line interface for privatepaste.com
4
+ #
5
+
6
+ require 'rubygems'
7
+ require 'httpclient'
8
+ require 'rexml/document'
9
+
10
+ class Privatepaste
11
+ include REXML
12
+
13
+ def initialize(options)
14
+ @options = options
15
+ end
16
+
17
+ def paste
18
+ if @options.has_key?("paste_content")
19
+ if @options["paste_content"] == "-"
20
+ @options["paste_content"] = $stdin.read
21
+ else
22
+ File.open(@options["paste_content"]) do |file|
23
+ @options["paste_content"] = file.read
24
+ end
25
+ end
26
+ end
27
+ clnt = HTTPClient.new
28
+ clnt.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
29
+ res = clnt.post("https://privatepaste.com/save", @options).header['location'][0]
30
+ "https://privatepaste.com" + res
31
+ end
32
+
33
+ def get_raw
34
+ @options["secure_paste_key"] = "" if ! @options["secure_paste_key"]
35
+ url = "https://privatepaste.com/" +
36
+ "download/" +
37
+ @options["link"].split("/")[3] +
38
+ "/" +
39
+ @options["secure_paste_key"]
40
+ clnt = HTTPClient.new(:agent_name => 'ruby privatepaste gem')
41
+ clnt.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
42
+ clnt.get_content(url)
43
+ end
44
+
45
+
46
+ end
@@ -0,0 +1,68 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{privatepaste}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Doug P."]
12
+ s.date = %q{2011-07-06}
13
+ s.description = %q{A CLI for privatepaste.com}
14
+ s.email = %q{dougtko@gmail.com}
15
+ s.executables = ["privatepaste"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".rspec",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bin/privatepaste",
30
+ "lib/privatepaste.rb",
31
+ "privatepaste.gemspec",
32
+ "spec/privatepaste_spec.rb",
33
+ "spec/spec_helper.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/dougsko/privatepaste}
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.7.2}
39
+ s.summary = %q{A CLI for privatepaste.com}
40
+
41
+ if s.respond_to? :specification_version then
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<httpclient>, [">= 0"])
46
+ s.add_development_dependency(%q<rake>, ["= 0.8.7"])
47
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
50
+ s.add_development_dependency(%q<rcov>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<httpclient>, [">= 0"])
53
+ s.add_dependency(%q<rake>, ["= 0.8.7"])
54
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
55
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
57
+ s.add_dependency(%q<rcov>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<httpclient>, [">= 0"])
61
+ s.add_dependency(%q<rake>, ["= 0.8.7"])
62
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
65
+ s.add_dependency(%q<rcov>, [">= 0"])
66
+ end
67
+ end
68
+
@@ -0,0 +1,37 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Privatepaste" do
4
+ before do
5
+ `echo "hello world" > /tmp/hw.txt`
6
+ options = {"paste_content" => "/tmp/hw.txt",
7
+ "line_numbers" => "on",
8
+ "expire" => "300",
9
+ "secure_paste" => "on",
10
+ "secure_paste_key" => "foo"
11
+ }
12
+ @pbin = Privatepaste.new(options)
13
+ end
14
+
15
+ after do
16
+ `rm /tmp/hw.txt`
17
+ end
18
+
19
+ it "tests that @pbin is indeed a Privatepasteobject" do
20
+ @pbin.class.to_s.should == "Privatepaste"
21
+ end
22
+
23
+ it "should paste some text and return a link" do
24
+ @link = @pbin.paste
25
+ @link.should match(/https:.*\/[\d\w]+/)
26
+ end
27
+
28
+ it "should return raw text from a paste link" do
29
+ options = {}
30
+ options["secure_paste_key"] = "foo"
31
+ options["link"] = @pbin.paste
32
+ @pbin = Privatepaste.new(options)
33
+ text = @pbin.get_raw
34
+ text.should match(/hello world/)
35
+ end
36
+
37
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'privatepaste'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: privatepaste
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Doug P.
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-07-06 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ name: httpclient
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ prerelease: false
36
+ name: rake
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - "="
41
+ - !ruby/object:Gem::Version
42
+ hash: 49
43
+ segments:
44
+ - 0
45
+ - 8
46
+ - 7
47
+ version: 0.8.7
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ prerelease: false
52
+ name: rspec
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 2
61
+ - 3
62
+ - 0
63
+ version: 2.3.0
64
+ type: :development
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ prerelease: false
68
+ name: bundler
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 23
75
+ segments:
76
+ - 1
77
+ - 0
78
+ - 0
79
+ version: 1.0.0
80
+ type: :development
81
+ version_requirements: *id004
82
+ - !ruby/object:Gem::Dependency
83
+ prerelease: false
84
+ name: jeweler
85
+ requirement: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ hash: 9
91
+ segments:
92
+ - 1
93
+ - 6
94
+ - 3
95
+ version: 1.6.3
96
+ type: :development
97
+ version_requirements: *id005
98
+ - !ruby/object:Gem::Dependency
99
+ prerelease: false
100
+ name: rcov
101
+ requirement: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ type: :development
111
+ version_requirements: *id006
112
+ description: A CLI for privatepaste.com
113
+ email: dougtko@gmail.com
114
+ executables:
115
+ - privatepaste
116
+ extensions: []
117
+
118
+ extra_rdoc_files:
119
+ - LICENSE.txt
120
+ - README.rdoc
121
+ files:
122
+ - .document
123
+ - .rspec
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - LICENSE.txt
127
+ - README.rdoc
128
+ - Rakefile
129
+ - VERSION
130
+ - bin/privatepaste
131
+ - lib/privatepaste.rb
132
+ - privatepaste.gemspec
133
+ - spec/privatepaste_spec.rb
134
+ - spec/spec_helper.rb
135
+ homepage: http://github.com/dougsko/privatepaste
136
+ licenses:
137
+ - MIT
138
+ post_install_message:
139
+ rdoc_options: []
140
+
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ hash: 3
149
+ segments:
150
+ - 0
151
+ version: "0"
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ hash: 3
158
+ segments:
159
+ - 0
160
+ version: "0"
161
+ requirements: []
162
+
163
+ rubyforge_project:
164
+ rubygems_version: 1.7.2
165
+ signing_key:
166
+ specification_version: 3
167
+ summary: A CLI for privatepaste.com
168
+ test_files: []
169
+