pastr_it 1.0.1 → 1.0.2
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.
- data/lib/pastr_it.rb +9 -8
- metadata +1 -1
data/lib/pastr_it.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "optparse"
|
2
2
|
class PastrIt
|
3
|
-
VERSION = '1.0.
|
3
|
+
VERSION = '1.0.2'
|
4
4
|
REALM = 'Pastr Registered User'
|
5
5
|
PastrHome = "http://pastr.it"
|
6
6
|
PastrNew = "%s/%s" % [PastrHome, :new]
|
@@ -64,13 +64,15 @@ class PastrIt
|
|
64
64
|
end
|
65
65
|
|
66
66
|
@filename = ARGV.shift if ARGV.size == 1 and File.file?(ARGV.first)
|
67
|
-
|
68
|
-
|
67
|
+
unless @paste_id
|
68
|
+
@title ||= File.basename(@filename) if @filename
|
69
|
+
@channel ||= @username
|
70
|
+
end
|
69
71
|
if @filename.nil? and STDIN.isatty
|
70
72
|
$stderr.puts "No Input on STDIN and no filename given, what am I supposed to paste?"
|
71
73
|
puts @opts
|
72
74
|
exit 1
|
73
|
-
end unless @pastr_id
|
75
|
+
end unless @pastr_id and @no_body
|
74
76
|
end
|
75
77
|
|
76
78
|
def annotate_it
|
@@ -82,11 +84,10 @@ class PastrIt
|
|
82
84
|
end
|
83
85
|
|
84
86
|
def edit_it
|
85
|
-
pid = "pastr_#{@
|
86
|
-
form = {"#{pid}[network]" => network, "#{pid}[channel]" => channel, "#{pid}[paste_body]" => paste_body}
|
87
|
+
pid = "pastr_#{@pastr_id}"
|
87
88
|
form = {}
|
88
89
|
form["#{pid}[network]"] = network if network
|
89
|
-
form["#{pid}[channel]"] = channel
|
90
|
+
form["#{pid}[channel]"] = channel.sub(/^_/,"#") if channel
|
90
91
|
form["#{pid}[title]"] = title if title
|
91
92
|
form["language"] = language if language
|
92
93
|
form["#{pid}[paste_body]"] = paste_body unless no_body
|
@@ -94,7 +95,7 @@ class PastrIt
|
|
94
95
|
end
|
95
96
|
|
96
97
|
def pastr_it
|
97
|
-
form = {'network' => network, 'channel' => channel, 'paste_body' => paste_body}
|
98
|
+
form = {'network' => network, 'channel' => channel.sub(/^_/,"#"), 'paste_body' => paste_body}
|
98
99
|
form["title"] = title if title
|
99
100
|
form["language"] = language if language
|
100
101
|
puts http_request(:form => form).content
|