pastr_it 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/pastr_it.rb +9 -8
  2. 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.1'
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
- @title ||= File.basename(@filename) if @filename
68
- @channel ||= @username
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_#{@paste_id}"
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 if 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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pastr_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jayson Vaughn