pasting 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/bin/pasting +10 -4
- data/lib/pasting.rb +7 -4
- data/lib/pasting/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f10d2aa2ce3cd9847b55ba6c4f94d2c3110a43a9
|
4
|
+
data.tar.gz: 95fda021190e8974d3520949676444f8b6f17f0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11c627a0032476745ad07af3a1504806e7a5850a2d06732217180a9e40e3e32c58889b1c6932806bc4c0fc600fb25adc36df1be4af61189dbf721ff8ba9f36b4
|
7
|
+
data.tar.gz: 79dfcb7380b62bd61bafc717e75942586e1abb653c226765cd684b6d4b443740715523ad84875ae55d0a8f7acc4af895724361699dffe68a490db9927992882e
|
data/bin/pasting
CHANGED
@@ -46,10 +46,16 @@ Usage: cat file.txt | #{executable_name}
|
|
46
46
|
end.parse!
|
47
47
|
|
48
48
|
begin
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
if not File.file?(Pasting::AuthTokenFile.filename)
|
50
|
+
puts "Please login first"
|
51
|
+
puts "Run: \n\tpasting --login"
|
52
|
+
exit(1)
|
53
|
+
else
|
54
|
+
$stderr.puts "(type a Pasting. <ctrl-c> to cancel, <ctrl-d> when done)" if $stdin.tty?
|
55
|
+
stdin = ARGF.read
|
56
|
+
|
57
|
+
Pasting.paste(stdin,options)
|
58
|
+
end
|
53
59
|
|
54
60
|
rescue Pasting::Error => e
|
55
61
|
puts "Error: #{e.message}"
|
data/lib/pasting.rb
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
module Pasting
|
12
12
|
extend self
|
13
13
|
|
14
|
-
VERSION = '0.0.
|
14
|
+
VERSION = '0.0.5'
|
15
15
|
|
16
16
|
PASTING_API_URL = URI.encode("http://api.pasting.io/".strip)
|
17
17
|
|
@@ -19,13 +19,12 @@ module Pasting
|
|
19
19
|
|
20
20
|
USER_AGENT = "pasting/#{VERSION} (Net::HTTP, #{RUBY_DESCRIPTION})"
|
21
21
|
|
22
|
-
# Exception tag for errors raised while
|
22
|
+
# Exception tag for errors raised while pasting.
|
23
23
|
module Error;
|
24
24
|
def self.exception(*args)
|
25
25
|
RuntimeError.new(*args).extend(self)
|
26
26
|
end
|
27
27
|
end
|
28
|
-
class ClipboardError < RuntimeError; include Error end
|
29
28
|
|
30
29
|
# helper module for authentication token actions
|
31
30
|
module AuthTokenFile
|
@@ -51,6 +50,7 @@ module Pasting
|
|
51
50
|
@token ||= AuthTokenFile.read rescue nil
|
52
51
|
end
|
53
52
|
|
53
|
+
#
|
54
54
|
def pasting_post(post_uri, body)
|
55
55
|
uri = URI.parse(api_url)
|
56
56
|
http = Net::HTTP.new(uri.host, uri.port)
|
@@ -61,6 +61,8 @@ module Pasting
|
|
61
61
|
response
|
62
62
|
end
|
63
63
|
|
64
|
+
# Create token to pasting
|
65
|
+
# @see http://pasting.io/
|
64
66
|
def login
|
65
67
|
print "Pasting username: "
|
66
68
|
username = $stdin.gets.strip
|
@@ -72,8 +74,9 @@ module Pasting
|
|
72
74
|
json = JSON.parse(response.body)
|
73
75
|
if json['st'] == 'error'
|
74
76
|
puts json['msg']
|
75
|
-
|
77
|
+
elsif json['st'] == 'ok'
|
76
78
|
AuthTokenFile.write(json['console_key'])
|
79
|
+
puts "Login Success"
|
77
80
|
end
|
78
81
|
else
|
79
82
|
puts "Fail to register"
|
data/lib/pasting/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pasting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Facundo Guerrero
|
@@ -51,10 +51,10 @@ files:
|
|
51
51
|
- LICENSE.txt
|
52
52
|
- README.md
|
53
53
|
- Rakefile
|
54
|
+
- bin/pasting
|
54
55
|
- lib/pasting.rb
|
55
56
|
- lib/pasting/version.rb
|
56
57
|
- pasting.gemspec
|
57
|
-
- bin/pasting
|
58
58
|
homepage: http://pasting.io
|
59
59
|
licenses:
|
60
60
|
- MIT
|