vermic 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +30 -0
- data/Rakefile +8 -0
- data/bin/vermic +3 -0
- data/lib/vermic.rb +63 -0
- data/lib/vermic/pastebin.rb +70 -0
- data/lib/vermic/validator.rb +285 -0
- data/lib/vermic/version.rb +3 -0
- data/spec/files/empty_file +0 -0
- data/spec/files/file +2 -0
- data/spec/pastebin_spec.rb +23 -0
- data/spec/validator_spec.rb +50 -0
- data/vermic.gemspec +25 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
Vermic
|
2
|
+
======
|
3
|
+
|
4
|
+
Command line utility for publishing your code on pastebin.com
|
5
|
+
Current version - 0.1.2
|
6
|
+
|
7
|
+
I often ask questions on irc and forums. So, I had to paste my code into public accessible places such as pastebin.com. This process was pretty much boring - you go to the text editor, you copy everything, you go to the website, you paste it.
|
8
|
+
I've decided to create a little utility to make this process easier.
|
9
|
+
Now it copies the url of the paste to the system clipboard using the clipboard gem.
|
10
|
+
|
11
|
+
As soon as this is my first gem please let me know if you notice some ugly code or architecture.
|
12
|
+
|
13
|
+
TODO:
|
14
|
+
|
15
|
+
1. + Handle missing mandatory arguments
|
16
|
+
2. + Copy URL to the system clipboard(tested for linux only)
|
17
|
+
3. Add file extension recognizer
|
18
|
+
|
19
|
+
Why?
|
20
|
+
----
|
21
|
+
|
22
|
+
This gem is quite useless because it cannot be used by many people since there's a restriction for pastes from one developer API a day. However, even from this simple project I've learned a lot of things and this is the first gem I've ever created, yupi.
|
23
|
+
I feel that there're tons of design and other trivial errors here so if you can admit any mistakes here please let me know.
|
24
|
+
|
25
|
+
Why vermic?
|
26
|
+
-----------
|
27
|
+
|
28
|
+
Well, we all know about spaghetti code. Let me give you my association row:
|
29
|
+
|
30
|
+
pastebin.com -> a lot of code -> huh, a lot of spaghetti code -> Italian cuisine -> vermicelli??? -> vermic
|
data/Rakefile
ADDED
data/bin/vermic
ADDED
data/lib/vermic.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'clipboard'
|
3
|
+
require_relative "vermic/version"
|
4
|
+
require_relative "vermic/pastebin"
|
5
|
+
require_relative "vermic/validator"
|
6
|
+
|
7
|
+
# This module parses command line options
|
8
|
+
# for vermic command line utility.
|
9
|
+
#
|
10
|
+
module Vermic
|
11
|
+
options = Hash.new
|
12
|
+
|
13
|
+
parser = OptionParser.new do |opts|
|
14
|
+
opts.banner = "This is command line utility which pastes your code on pastebin"
|
15
|
+
|
16
|
+
opts.on("-v", "--version", "shows the current version") do |v|
|
17
|
+
puts Vermic::VERSION
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-n", "--name N", "sets the name of the paste") do |n|
|
22
|
+
options[:paste_name] = name
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("-f", "--format F", "sets the format of the paste") do |format|
|
26
|
+
options[:paste_format] = format
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("-p", "--private", "makes the paste private(public is default)") do |private|
|
30
|
+
options[:paste_private] = 1
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("-e", "--expire E", "sets the expire date of the paste") do |expire_date|
|
34
|
+
options[:paste_expire_date] = expire_date
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
begin parser.parse!
|
40
|
+
rescue OptionParser::InvalidOption
|
41
|
+
puts "Invalid option, see --help for list of options"
|
42
|
+
exit
|
43
|
+
|
44
|
+
rescue OptionParser::MissingArgument => e
|
45
|
+
puts e
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
|
49
|
+
options[:file_name] = ARGV[0]
|
50
|
+
|
51
|
+
Validator::validate_options(options)
|
52
|
+
|
53
|
+
if Validator::any_errors?
|
54
|
+
Validator::print_errors
|
55
|
+
else
|
56
|
+
result = PastebinWrapper::paste_file(options)
|
57
|
+
puts result
|
58
|
+
if result =~ /^https?:\/\//
|
59
|
+
Clipboard::copy(result)
|
60
|
+
puts "This URL has been copied to your clipboard"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
# This module works with pastebin.com API.
|
5
|
+
#
|
6
|
+
module PastebinWrapper
|
7
|
+
POST_URL = "http://pastebin.com/api/api_post.php"
|
8
|
+
API_DEV_KEY = "7fe7c0c1814042eb9f0288d93d954fe9"
|
9
|
+
|
10
|
+
API_OPTION = 'paste'
|
11
|
+
PASTE_NAME = 'Vermicelli code'
|
12
|
+
PASTE_FORMAT = 'c'
|
13
|
+
PASTE_PRIVATE = 0
|
14
|
+
PASTE_EXPIRE_DATE = '1H'
|
15
|
+
|
16
|
+
# Pastes plain code to the pastebin.com with
|
17
|
+
# the given parameters
|
18
|
+
#
|
19
|
+
def self.paste_code(code, params = {})
|
20
|
+
initialize_parameters(code)
|
21
|
+
@@params.merge(params)
|
22
|
+
paste
|
23
|
+
end
|
24
|
+
|
25
|
+
# Pastes file to the pastebin.com site with the
|
26
|
+
# given parameters
|
27
|
+
#
|
28
|
+
def self.paste_file(params = {})
|
29
|
+
code = ""
|
30
|
+
filename = params[:file_name]
|
31
|
+
File.foreach(filename) do |line|
|
32
|
+
code += line
|
33
|
+
end
|
34
|
+
initialize_parameters(code)
|
35
|
+
@@params.merge!(params)
|
36
|
+
paste
|
37
|
+
end
|
38
|
+
|
39
|
+
# Private helper methods for the Pastebin module
|
40
|
+
private
|
41
|
+
|
42
|
+
# Pastes the code to the pastebin.com site
|
43
|
+
# with the given parameters and returns either
|
44
|
+
# the link to the pasted code in case of a
|
45
|
+
# successful paste or error message which starts
|
46
|
+
# by "Bad API request..."
|
47
|
+
#
|
48
|
+
def self.paste
|
49
|
+
Net::HTTP.post_form(URI.parse(POST_URL),
|
50
|
+
{'api_dev_key' => API_DEV_KEY,
|
51
|
+
'api_option' => API_OPTION,
|
52
|
+
'api_paste_code' => @@params[:paste_code],
|
53
|
+
'api_paste_name' => @@params[:paste_name],
|
54
|
+
'api_paste_format' => @@params[:paste_format],
|
55
|
+
'api_paste_private' => @@params[:paste_private],
|
56
|
+
'api_paste_expire_date' => @@params[:paste_expire_date]}).body
|
57
|
+
end
|
58
|
+
|
59
|
+
# Initializes paste parameters with the default
|
60
|
+
# values except for the paste code which is
|
61
|
+
# passed as a method parameter
|
62
|
+
#
|
63
|
+
def self.initialize_parameters(code)
|
64
|
+
@@params = {paste_name: PASTE_NAME,
|
65
|
+
paste_format: PASTE_FORMAT,
|
66
|
+
paste_private: PASTE_PRIVATE,
|
67
|
+
paste_expire_date: PASTE_EXPIRE_DATE,
|
68
|
+
paste_code: code}
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,285 @@
|
|
1
|
+
# This module validates the parameters' values
|
2
|
+
# for the correctness
|
3
|
+
#
|
4
|
+
module Validator
|
5
|
+
|
6
|
+
# Hash of possible code formats
|
7
|
+
FORMATS_HASH = {
|
8
|
+
"4cs" => "4CS",
|
9
|
+
"6502acme" => "6502 ACME Cross Assembler",
|
10
|
+
"6502kickass" => "6502 Kick Assembler",
|
11
|
+
"6502tasm" => "6502 TASM/64TASS",
|
12
|
+
"abap" => "ABAP",
|
13
|
+
"actionscript" => "ActionScript",
|
14
|
+
"actionscript3" => "ActionScript 3",
|
15
|
+
"ada" => "Ada",
|
16
|
+
"algol68" => "ALGOL 68",
|
17
|
+
"apache" => "Apache Log",
|
18
|
+
"applescript" => "AppleScript",
|
19
|
+
"apt_sources" => "APT Sources",
|
20
|
+
"asm" => "ASM (NASM)",
|
21
|
+
"asp" => "ASP",
|
22
|
+
"autoconf" => "autoconf",
|
23
|
+
"autohotkey" => "Autohotkey",
|
24
|
+
"autoit" => "AutoIt",
|
25
|
+
"avisynth" => "Avisynth",
|
26
|
+
"awk" => "Awk",
|
27
|
+
"bascomavr" => "BASCOM AVR",
|
28
|
+
"bash" => "Bash",
|
29
|
+
"basic4gl" => "Basic4GL",
|
30
|
+
"bibtex" => "BibTeX",
|
31
|
+
"blitzbasic" => "Blitz Basic",
|
32
|
+
"bnf" => "BNF",
|
33
|
+
"boo" => "BOO",
|
34
|
+
"bf" => "BrainFuck",
|
35
|
+
"c" => "C",
|
36
|
+
"c_mac" => "C for Macs",
|
37
|
+
"cil" => "C Intermediate Language",
|
38
|
+
"csharp" => "C#",
|
39
|
+
"cpp" => "C++",
|
40
|
+
"cpp-qt" => "C++ (with QT extensions)",
|
41
|
+
"c_loadrunner" => "C: Loadrunner",
|
42
|
+
"caddcl" => "CAD DCL",
|
43
|
+
"cadlisp" => "CAD Lisp",
|
44
|
+
"cfdg" => "CFDG",
|
45
|
+
"chaiscript" => "ChaiScript",
|
46
|
+
"clojure" => "Clojure",
|
47
|
+
"klonec" => "Clone C",
|
48
|
+
"klonecpp" => "Clone C++",
|
49
|
+
"cmake" => "CMake",
|
50
|
+
"cobol" => "COBOL",
|
51
|
+
"coffeescript" => "CoffeeScript",
|
52
|
+
"cfm" => "ColdFusion",
|
53
|
+
"css" => "CSS",
|
54
|
+
"cuesheet" => "Cuesheet",
|
55
|
+
"d" => "D",
|
56
|
+
"dcs" => "DCS",
|
57
|
+
"delphi" => "Delphi",
|
58
|
+
"oxygene" => "Delphi Prism (Oxygene)",
|
59
|
+
"diff" => "Diff",
|
60
|
+
"div" => "DIV",
|
61
|
+
"dos" => "DOS",
|
62
|
+
"dot" => "DOT",
|
63
|
+
"e" => "E",
|
64
|
+
"ecmascript" => "ECMAScript",
|
65
|
+
"eiffel" => "Eiffel",
|
66
|
+
"email" => "Email",
|
67
|
+
"epc" => "EPC",
|
68
|
+
"erlang" => "Erlang",
|
69
|
+
"fsharp" => "F#",
|
70
|
+
"falcon" => "Falcon",
|
71
|
+
"fo" => "FO Language",
|
72
|
+
"f1" => "Formula One",
|
73
|
+
"fortran" => "Fortran",
|
74
|
+
"freebasic" => "FreeBasic",
|
75
|
+
"freeswitch" => "FreeSWITCH",
|
76
|
+
"gambas" => "GAMBAS",
|
77
|
+
"gml" => "Game Maker",
|
78
|
+
"gdb" => "GDB",
|
79
|
+
"genero" => "Genero",
|
80
|
+
"genie" => "Genie",
|
81
|
+
"gettext" => "GetText",
|
82
|
+
"go" => "Go",
|
83
|
+
"groovy" => "Groovy",
|
84
|
+
"gwbasic" => "GwBasic",
|
85
|
+
"haskell" => "Haskell",
|
86
|
+
"hicest" => "HicEst",
|
87
|
+
"hq9plus" => "HQ9 Plus",
|
88
|
+
"html4strict" => "HTML",
|
89
|
+
"html5" => "HTML 5",
|
90
|
+
"icon" => "Icon",
|
91
|
+
"idl" => "IDL",
|
92
|
+
"ini" => "INI file",
|
93
|
+
"inno" => "Inno Script",
|
94
|
+
"intercal" => "INTERCAL",
|
95
|
+
"io" => "IO",
|
96
|
+
"j" => "J",
|
97
|
+
"java" => "Java",
|
98
|
+
"java5" => "Java 5",
|
99
|
+
"javascript" => "JavaScript",
|
100
|
+
"jquery" => "jQuery",
|
101
|
+
"kixtart" => "KiXtart",
|
102
|
+
"latex" => "Latex",
|
103
|
+
"lb" => "Liberty BASIC",
|
104
|
+
"lsl2" => "Linden Scripting",
|
105
|
+
"lisp" => "Lisp",
|
106
|
+
"llvm" => "LLVM",
|
107
|
+
"locobasic" => "Loco Basic",
|
108
|
+
"logtalk" => "Logtalk",
|
109
|
+
"lolcode" => "LOL Code",
|
110
|
+
"lotusformulas" => "Lotus Formulas",
|
111
|
+
"lotusscript" => "Lotus Script",
|
112
|
+
"lscript" => "LScript",
|
113
|
+
"lua" => "Lua",
|
114
|
+
"m68k" => "M68000 Assembler",
|
115
|
+
"magiksf" => "MagikSF",
|
116
|
+
"make" => "Make",
|
117
|
+
"mapbasic" => "MapBasic",
|
118
|
+
"matlab" => "MatLab",
|
119
|
+
"mirc" => "mIRC",
|
120
|
+
"mmix" => "MIX Assembler",
|
121
|
+
"modula2" => "Modula 2",
|
122
|
+
"modula3" => "Modula 3",
|
123
|
+
"68000devpac" => "Motorola 68000 HiSoft Dev",
|
124
|
+
"mpasm" => "MPASM",
|
125
|
+
"mxml" => "MXML",
|
126
|
+
"mysql" => "MySQL",
|
127
|
+
"newlisp" => "newLISP",
|
128
|
+
"text" => "None",
|
129
|
+
"nsis" => "NullSoft Installer",
|
130
|
+
"oberon2" => "Oberon 2",
|
131
|
+
"objeck" => "Objeck Programming Langua",
|
132
|
+
"objc" => "Objective C",
|
133
|
+
"ocaml-brief" => "OCalm Brief",
|
134
|
+
"ocaml" => "OCaml",
|
135
|
+
"pf" => "OpenBSD PACKET FILTER",
|
136
|
+
"glsl" => "OpenGL Shading",
|
137
|
+
"oobas" => "Openoffice BASIC",
|
138
|
+
"oracle11" => "Oracle 11",
|
139
|
+
"oracle8" => "Oracle 8",
|
140
|
+
"oz" => "Oz",
|
141
|
+
"pascal" => "Pascal",
|
142
|
+
"pawn" => "PAWN",
|
143
|
+
"pcre" => "PCRE",
|
144
|
+
"per" => "Per",
|
145
|
+
"perl" => "Perl",
|
146
|
+
"perl6" => "Perl 6",
|
147
|
+
"php" => "PHP",
|
148
|
+
"php-brief" => "PHP Brief",
|
149
|
+
"pic16" => "Pic 16",
|
150
|
+
"pike" => "Pike",
|
151
|
+
"pixelbender" => "Pixel Bender",
|
152
|
+
"plsql" => "PL/SQL",
|
153
|
+
"postgresql" => "PostgreSQL",
|
154
|
+
"povray" => "POV-Ray",
|
155
|
+
"powershell" => "Power Shell",
|
156
|
+
"powerbuilder" => "PowerBuilder",
|
157
|
+
"proftpd" => "ProFTPd",
|
158
|
+
"progress" => "Progress",
|
159
|
+
"prolog" => "Prolog",
|
160
|
+
"properties" => "Properties",
|
161
|
+
"providex" => "ProvideX",
|
162
|
+
"purebasic" => "PureBasic",
|
163
|
+
"pycon" => "PyCon",
|
164
|
+
"python" => "Python",
|
165
|
+
"q" => "q/kdb+",
|
166
|
+
"qbasic" => "QBasic",
|
167
|
+
"rsplus" => "R",
|
168
|
+
"rails" => "Rails",
|
169
|
+
"rebol" => "REBOL",
|
170
|
+
"reg" => "REG",
|
171
|
+
"robots" => "Robots",
|
172
|
+
"rpmspec" => "RPM Spec",
|
173
|
+
"ruby" => "Ruby",
|
174
|
+
"gnuplot" => "Ruby Gnuplot",
|
175
|
+
"sas" => "SAS",
|
176
|
+
"scala" => "Scala",
|
177
|
+
"scheme" => "Scheme",
|
178
|
+
"scilab" => "Scilab",
|
179
|
+
"sdlbasic" => "SdlBasic",
|
180
|
+
"smalltalk" => "Smalltalk",
|
181
|
+
"smarty" => "Smarty",
|
182
|
+
"sql" => "SQL",
|
183
|
+
"systemverilog" => "SystemVerilog",
|
184
|
+
"tsql" => "T-SQL",
|
185
|
+
"tcl" => "TCL",
|
186
|
+
"teraterm" => "Tera Term",
|
187
|
+
"thinbasic" => "thinBasic",
|
188
|
+
"typoscript" => "TypoScript",
|
189
|
+
"unicon" => "Unicon",
|
190
|
+
"uscript" => "UnrealScript",
|
191
|
+
"vala" => "Vala",
|
192
|
+
"vbnet" => "VB.NET",
|
193
|
+
"verilog" => "VeriLog",
|
194
|
+
"vhdl" => "VHDL",
|
195
|
+
"vim" => "VIM",
|
196
|
+
"visualprolog" => "Visual Pro Log",
|
197
|
+
"vb" => "VisualBasic",
|
198
|
+
"visualfoxpro" => "VisualFoxPro",
|
199
|
+
"whitespace" => "WhiteSpace",
|
200
|
+
"whois" => "WHOIS",
|
201
|
+
"winbatch" => "Winbatch",
|
202
|
+
"xbasic" => "XBasic",
|
203
|
+
"xml" => "XML",
|
204
|
+
"xorg_conf" => "Xorg Config",
|
205
|
+
"xpp" => "XPP",
|
206
|
+
"yaml" => "YAML",
|
207
|
+
"z80" => "Z80 Assembler",
|
208
|
+
"zxbasic" => "ZXBasic"
|
209
|
+
}
|
210
|
+
|
211
|
+
# Hash of possible expire date values
|
212
|
+
EXPIRE_DATE_HASH = {
|
213
|
+
"N" => "Never",
|
214
|
+
"10M" => "10 Minutes",
|
215
|
+
"1H" => "1 Hour",
|
216
|
+
"1D" => "1 Day",
|
217
|
+
"1M" => "1 Month"
|
218
|
+
}
|
219
|
+
|
220
|
+
# Validates all the options which exist in the
|
221
|
+
# options array(defined by the user)
|
222
|
+
#
|
223
|
+
def self.validate_options(options = {})
|
224
|
+
@errors = []
|
225
|
+
validate_name(options[:paste_name]) if options.has_key?(:paste_name)
|
226
|
+
validate_format(options[:paste_format]) if options.has_key?(:paste_format)
|
227
|
+
validate_expire_date(options[:paste_expire_date]) if options.has_key?(:paste_expire_date)
|
228
|
+
validate_file(options[:file_name])
|
229
|
+
end
|
230
|
+
|
231
|
+
# Checks if the options have any errors
|
232
|
+
#
|
233
|
+
def self.any_errors?
|
234
|
+
!@errors.empty?
|
235
|
+
end
|
236
|
+
|
237
|
+
# Prints all the errors of all options
|
238
|
+
# to the shell
|
239
|
+
#
|
240
|
+
def self.print_errors
|
241
|
+
@errors.each do |e|
|
242
|
+
puts e
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
private
|
247
|
+
|
248
|
+
# Validates the name of the paste
|
249
|
+
#
|
250
|
+
def self.validate_name(name)
|
251
|
+
@errors << "Name can't be empty" if name.empty?
|
252
|
+
end
|
253
|
+
|
254
|
+
# Validates the format of the paste
|
255
|
+
#
|
256
|
+
def self.validate_format(format)
|
257
|
+
if !FORMATS_HASH.has_key?(format)
|
258
|
+
@errors << "Wrong format"
|
259
|
+
FORMATS_HASH.keys.each do |key|
|
260
|
+
@errors << "\t#{key} -> #{FORMATS_HASH[key]}"
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
# Validates the expire date of the paste
|
266
|
+
#
|
267
|
+
def self.validate_expire_date(expire_date)
|
268
|
+
if !EXPIRE_DATE_HASH.has_key?(expire_date)
|
269
|
+
@errors << "Wrong format of expire date, you should use the following arguments:"
|
270
|
+
EXPIRE_DATE_HASH.keys.each do |key|
|
271
|
+
@errors << "\t#{key.to_s} -> #{EXPIRE_DATE_HASH[key]}"
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
# Validates the file
|
277
|
+
#
|
278
|
+
def self.validate_file(filename)
|
279
|
+
if filename.nil?
|
280
|
+
@errors << "But you didn't provide the file"
|
281
|
+
else
|
282
|
+
@errors << "There's no such file" if !File.exists?(filename)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
File without changes
|
data/spec/files/file
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require_relative '../lib/vermic/pastebin'
|
4
|
+
|
5
|
+
# Tests PastebinWrapper module
|
6
|
+
#
|
7
|
+
describe PastebinWrapper do
|
8
|
+
|
9
|
+
it "shouldn't post empty code" do
|
10
|
+
# PastebinWrapper::paste_code('').must_match(/Bad API request.*/)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return url when no params" do
|
14
|
+
# PastebinWrapper::paste_code('some code').must_match(/http:\/\/pastebin.com\/\w+/)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "shouldn't paste empty file" do
|
18
|
+
options = {
|
19
|
+
file_name: File.expand_path('spec/files/empty_file')
|
20
|
+
}
|
21
|
+
# PastebinWrapper::paste_file(options).must_match(/Bad API request.*/)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require_relative '../lib/vermic/validator'
|
4
|
+
|
5
|
+
# Tests Validator
|
6
|
+
#
|
7
|
+
describe "Validator" do
|
8
|
+
|
9
|
+
it "should fail if empty name" do
|
10
|
+
options = {paste_name: "", paste_format: "c", paste_expire_date: "1M"}
|
11
|
+
Validator::validate_options(options)
|
12
|
+
Validator::any_errors?.must_equal(true)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should fail if empty format" do
|
16
|
+
options = {paste_name: "Some code", paste_format: "", paste_expire_date: "1H"}
|
17
|
+
Validator::validate_options(options)
|
18
|
+
Validator::any_errors?.must_equal(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should fail if empty expire date" do
|
22
|
+
options = {paste_name: "Some code", paste_format: "yaml", paste_expire_date: ""}
|
23
|
+
Validator::validate_options(options)
|
24
|
+
Validator::any_errors?.must_equal(true)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should fail if wrong format" do
|
28
|
+
options = {paste_name: "Some code", paste_format: "cee", paste_expire_date: "1D"}
|
29
|
+
Validator::validate_options(options)
|
30
|
+
Validator::any_errors?.must_equal(true)
|
31
|
+
options[:paste_name] = "z801"
|
32
|
+
Validator::validate_options(options)
|
33
|
+
Validator::any_errors?.must_equal(true)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should fail if wrong expire date" do
|
37
|
+
options = {paste_name: "Some code", paste_format: "vim", paste_expire_date: "10m"}
|
38
|
+
Validator::validate_options(options)
|
39
|
+
Validator::any_errors?.must_equal(true)
|
40
|
+
options[:paste_expire_date] = "n"
|
41
|
+
Validator::validate_options(options)
|
42
|
+
Validator::any_errors?.must_equal(true)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should fail if file is not given" do
|
46
|
+
options = {paste_name: "Some code", paste_format: "yaml", paste_expire_date: "10M", file_name: nil}
|
47
|
+
Validator::validate_options(options)
|
48
|
+
Validator::any_errors?.must_equal(true)
|
49
|
+
end
|
50
|
+
end
|
data/vermic.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "vermic/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "vermic"
|
7
|
+
s.version = Vermic::VERSION
|
8
|
+
s.authors = ["Sergey Kim"]
|
9
|
+
s.email = ["skim1776@gmail.com"]
|
10
|
+
s.homepage = "http://www.github.com/skim1776/vermic"
|
11
|
+
s.summary = %q{Pastes your code to the pastebin.com}
|
12
|
+
s.description = %q{I often need to paste my code to some place with public access in order to ask questions.
|
13
|
+
This utility makes this process easier.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "vermic"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
# specify any dependencies here; for example:
|
23
|
+
# s.add_development_dependency "rspec"
|
24
|
+
s.add_runtime_dependency "clipboard"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vermic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sergey Kim
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-18 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: clipboard
|
16
|
+
requirement: &22159340 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *22159340
|
25
|
+
description: ! "I often need to paste my code to some place with public access in
|
26
|
+
order to ask questions.\n This utility makes this process easier."
|
27
|
+
email:
|
28
|
+
- skim1776@gmail.com
|
29
|
+
executables:
|
30
|
+
- vermic
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- bin/vermic
|
39
|
+
- lib/vermic.rb
|
40
|
+
- lib/vermic/pastebin.rb
|
41
|
+
- lib/vermic/validator.rb
|
42
|
+
- lib/vermic/version.rb
|
43
|
+
- spec/files/empty_file
|
44
|
+
- spec/files/file
|
45
|
+
- spec/pastebin_spec.rb
|
46
|
+
- spec/validator_spec.rb
|
47
|
+
- vermic.gemspec
|
48
|
+
homepage: http://www.github.com/skim1776/vermic
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project: vermic
|
68
|
+
rubygems_version: 1.8.10
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Pastes your code to the pastebin.com
|
72
|
+
test_files:
|
73
|
+
- spec/files/empty_file
|
74
|
+
- spec/files/file
|
75
|
+
- spec/pastebin_spec.rb
|
76
|
+
- spec/validator_spec.rb
|