rubyhexagon 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/e621_search +116 -0
- data/bin/e621_server +158 -0
- data/bin/fav-sync +82 -0
- data/bin/set-sync +225 -0
- data/lib/api.rb +123 -0
- data/lib/config.rb +46 -0
- data/lib/container.rb +43 -0
- data/lib/pool.rb +50 -0
- data/lib/post.rb +106 -0
- data/lib/rubyhexagon.rb +34 -0
- data/lib/search.rb +73 -0
- data/lib/set.rb +43 -0
- data/lib/standard/error.rb +24 -0
- data/lib/standard/hash.rb +29 -0
- data/lib/standard/http.rb +83 -0
- data/lib/standard/int.rb +36 -0
- data/lib/standard/string.rb +84 -0
- data/lib/standard/time.rb +30 -0
- metadata +67 -0
data/lib/standard/int.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright 2014 Maxine Red <maxine_red1@yahoo.com>
|
3
|
+
|
4
|
+
This file is part of rubyhexagon.
|
5
|
+
|
6
|
+
rubyhexagon is free software: you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU General Public License as published by
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
rubyhexagon is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with rubyhexagon. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
=end
|
19
|
+
|
20
|
+
class Fixnum
|
21
|
+
def to_kb
|
22
|
+
(self/1024.0).round(2)
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_mb
|
26
|
+
(self/(1024*1024.0)).round(2)
|
27
|
+
end
|
28
|
+
|
29
|
+
def days
|
30
|
+
60*60*24*self
|
31
|
+
end
|
32
|
+
|
33
|
+
def pad(c,s=0)
|
34
|
+
"#{s}"*(c-self.to_s.length)+self.to_s
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright 2014 Maxine Red <maxine_red1@yahoo.com>
|
3
|
+
|
4
|
+
This file is part of rubyhexagon.
|
5
|
+
|
6
|
+
rubyhexagon is free software: you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU General Public License as published by
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
rubyhexagon is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with rubyhexagon. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
=end
|
19
|
+
|
20
|
+
require "json"
|
21
|
+
|
22
|
+
class String
|
23
|
+
# Make json parsing a lot easier and less to write.
|
24
|
+
def parse
|
25
|
+
JSON.parser.new(self).parse
|
26
|
+
end
|
27
|
+
# Remove all tags inside of a string.
|
28
|
+
def clean
|
29
|
+
self.gsub(/<.+?>/,"")
|
30
|
+
end
|
31
|
+
# Trim or expand a string to a certain length.
|
32
|
+
def pad(c,s=" ")
|
33
|
+
if self.length > c then
|
34
|
+
self[0,c-3]+"..."
|
35
|
+
elsif self.length < c then
|
36
|
+
self+s.to_s*(c-self.length)
|
37
|
+
else
|
38
|
+
self
|
39
|
+
end
|
40
|
+
end
|
41
|
+
# Make a string bold and colorful, with colors a user can understand. Not
|
42
|
+
# those cryptic numbers.
|
43
|
+
def bold(color=nil)
|
44
|
+
c = case color
|
45
|
+
when "black" then "\e[30;1m"
|
46
|
+
when "red" then "\e[31;1m"
|
47
|
+
when "green" then "\e[32;1m"
|
48
|
+
when "yellow" then "\e[33;1m"
|
49
|
+
when "blue" then "\e[34;1m"
|
50
|
+
when "purple" then "\e[35;1m"
|
51
|
+
when "cyan" then "\e[36;1m"
|
52
|
+
else "\e[37;1m"
|
53
|
+
end
|
54
|
+
c+self+"\e[0m"
|
55
|
+
end
|
56
|
+
# Same as bold, but just make a string colorful.
|
57
|
+
def color(color=nil)
|
58
|
+
c = case color
|
59
|
+
when "black" then "\e[30;0m"
|
60
|
+
when "red" then "\e[31;0m"
|
61
|
+
when "green" then "\e[32;0m"
|
62
|
+
when "yellow" then "\e[33;0m"
|
63
|
+
when "blue" then "\e[34;0m"
|
64
|
+
when "purple" then "\e[35;0m"
|
65
|
+
when "cyan" then "\e[36;0m"
|
66
|
+
else "\e[37;0m"
|
67
|
+
end
|
68
|
+
c+self+"\e[0m"
|
69
|
+
end
|
70
|
+
# indent a string and all lines that belong to it
|
71
|
+
def indent(indent)
|
72
|
+
s = self.split("#$/")
|
73
|
+
" "*indent+s.join("#$/"+" "*indent)
|
74
|
+
end
|
75
|
+
# It is just convenient to have a custom to_bool function. Only "true" gets
|
76
|
+
# turned into true, anything else is false.
|
77
|
+
def to_bool
|
78
|
+
if self.downcase == "true" then
|
79
|
+
true
|
80
|
+
else
|
81
|
+
false
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright 2014 Maxine Red <maxine_red1@yahoo.com>
|
3
|
+
|
4
|
+
This file is part of rubyhexagon.
|
5
|
+
|
6
|
+
rubyhexagon is free software: you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU General Public License as published by
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
rubyhexagon is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with rubyhexagon. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
=end
|
19
|
+
class Time
|
20
|
+
# A general to_s function for Time objects.
|
21
|
+
def to_s
|
22
|
+
self.strftime("%b %e,%Y %I:%M %p")
|
23
|
+
end
|
24
|
+
# This methods takes a block and returns how long it took to execute that block.
|
25
|
+
def self.measure
|
26
|
+
s = Time.now
|
27
|
+
yield
|
28
|
+
return Time.now-s
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyhexagon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Maxine Red
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-02-15 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Rubyhexagon provides Ruby bindings for the e621 [dot] net API.
|
15
|
+
email: maxine_red1@yahoo.com
|
16
|
+
executables:
|
17
|
+
- fav-sync
|
18
|
+
- set-sync
|
19
|
+
- e621_search
|
20
|
+
- e621_server
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- lib/pool.rb
|
25
|
+
- lib/rubyhexagon.rb
|
26
|
+
- lib/standard/hash.rb
|
27
|
+
- lib/standard/http.rb
|
28
|
+
- lib/standard/error.rb
|
29
|
+
- lib/standard/string.rb
|
30
|
+
- lib/standard/time.rb
|
31
|
+
- lib/standard/int.rb
|
32
|
+
- lib/post.rb
|
33
|
+
- lib/search.rb
|
34
|
+
- lib/container.rb
|
35
|
+
- lib/config.rb
|
36
|
+
- lib/api.rb
|
37
|
+
- lib/set.rb
|
38
|
+
- bin/fav-sync
|
39
|
+
- bin/set-sync
|
40
|
+
- bin/e621_search
|
41
|
+
- bin/e621_server
|
42
|
+
homepage: https://github.com/maxine-red/rubyhexagon
|
43
|
+
licenses:
|
44
|
+
- GPL-3.0
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.9.2
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.8.23
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Rubyhexagon, Ruby bindings for e621[dot]net.
|
67
|
+
test_files: []
|