legworker 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +11 -2
- data/bin/legworker +80 -42
- data/legworker.gemspec +2 -2
- data/lib/legworker.rb +53 -1
- data/lib/legworker/utils.rb +20 -0
- data/lib/legworker/version.rb +1 -1
- metadata +12 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 21ac3c94c4b48a3abf19e30f8588b267f32f9163
|
4
|
+
data.tar.gz: b185d98f2c5d7cee00f20e5ab452346df6a361bb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0395cd901a2da47791ca7f5b4b45551da7e44de431fc0cd6af788563b1babc3c5036e2de573c353f425153da8c3d075049dead7cbd18ff9e0300d70b29845160
|
7
|
+
data.tar.gz: 58a33333b7b6cec13cfd11a7742ceca0c785cbc3b513ec6d7dd44bf39f0ed7890d054310abba8d440ad6bdec7bdae99191e9c61a989b1089e0945b1b65e685a6
|
data/README.md
CHANGED
@@ -2,15 +2,22 @@
|
|
2
2
|
|
3
3
|
A helper gem.
|
4
4
|
|
5
|
+
## Features
|
6
|
+
* vagrant - Provisions a vagrant box, using puppet creates your environment and databases.
|
7
|
+
* sequence - Base64 encodes a sequence of images and writes to a json file.
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
$ gem install legworker
|
8
12
|
|
9
|
-
##
|
10
|
-
|
13
|
+
## Vagrant
|
11
14
|
|
12
15
|
legworker vagrant -a APP_NAME --devUser DEV_USER --devPass DEV_PASS --prodUser PROD_USER --prodPass PROD_PASS --dd DEV_DATABASE --pd PROD_DATABASE
|
13
16
|
|
17
|
+
## Sequence
|
18
|
+
|
19
|
+
legworker sequence -i "DIRECTORY" -v "VARIABLE_NAME_FOR_DATA" -n "NAME_OF_OUTPUT_FILE" -o "DIRECTORY_FOR_OUTPUT_FILE"
|
20
|
+
|
14
21
|
|
15
22
|
##rock and roll.
|
16
23
|
|
@@ -25,3 +32,5 @@ A helper gem.
|
|
25
32
|
## Change log
|
26
33
|
|
27
34
|
9.17.13 - Added automatic vagrant up & provision to ensure everything is installed and setup properly.
|
35
|
+
3.27.14 - Added sequence to utils.
|
36
|
+
|
data/bin/legworker
CHANGED
@@ -12,6 +12,7 @@ opt_parser = OptionParser.new do |opt|
|
|
12
12
|
opt.separator ""
|
13
13
|
opt.separator "Commands"
|
14
14
|
opt.separator " vagrant: start new vagrant & puppet project"
|
15
|
+
opt.separator " sequence: base64 encode images into a json sequence"
|
15
16
|
opt.separator ""
|
16
17
|
opt.separator "Options"
|
17
18
|
|
@@ -19,56 +20,93 @@ opt_parser = OptionParser.new do |opt|
|
|
19
20
|
puts opt_parser
|
20
21
|
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
case ARGV[0]
|
24
|
+
when "vagrant"
|
25
|
+
#------------------------------------------------------------------------------
|
26
|
+
#
|
27
|
+
# Vagrant Options
|
28
|
+
#
|
29
|
+
#------------------------------------------------------------------------------
|
30
|
+
opt.on("-a","--application ","VAGRANT: Your Application Name") do |op|
|
31
|
+
puts "Application Name: #{op}"
|
32
|
+
options[:application_name] = op
|
33
|
+
end
|
26
34
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
35
|
+
opt.on("--du","--devUser ","VAGRANT: Your Development User") do |op|
|
36
|
+
puts "Development User: #{op}"
|
37
|
+
options[:dev_user] = op
|
38
|
+
end
|
31
39
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
40
|
+
opt.on("--dp","--devPass ","VAGRANT: Your Development Password") do |op|
|
41
|
+
puts "Development Password: #{op}"
|
42
|
+
options[:dev_pass] = op
|
43
|
+
end
|
36
44
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
45
|
+
opt.on("--pu","--prodUser ","VAGRANT: Your Production User") do |op|
|
46
|
+
puts "Production User: #{op}"
|
47
|
+
options[:prod_user] = op
|
48
|
+
end
|
41
49
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
50
|
+
opt.on("--pp","--prodPass ","VAGRANT: Your Production Password") do |op|
|
51
|
+
puts "Production Password: #{op}"
|
52
|
+
options[:prod_pass] = op
|
53
|
+
end
|
46
54
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
opt.on("--dd","--devDatabase ","VAGRANT: Your development database name") do |op|
|
56
|
+
puts "Development Database: #{op}"
|
57
|
+
options[:dev_database] = op
|
58
|
+
end
|
51
59
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
opt.on("--pd","--prodDatabase ","VAGRANT: Your production database name") do |op|
|
61
|
+
puts "Production Database: #{op}"
|
62
|
+
options[:prod_database] = op
|
63
|
+
end
|
56
64
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
65
|
+
## Vagrant
|
66
|
+
opt.on("vagrant") do
|
67
|
+
if options.size == 7
|
68
|
+
lw.vagrant(options)
|
69
|
+
else
|
70
|
+
puts "VAGRANT: Oops looks like you're missing some options."
|
71
|
+
end
|
72
|
+
end
|
64
73
|
|
65
|
-
|
74
|
+
when "sequence"
|
75
|
+
#------------------------------------------------------------------------------
|
76
|
+
#
|
77
|
+
# Sequence Options
|
78
|
+
#
|
79
|
+
#------------------------------------------------------------------------------
|
80
|
+
opt.on("-i","--input ", "SEQUENCE: Should be the path to the desired directory of images") do |op|
|
81
|
+
puts "Input Directory: #{op}"
|
82
|
+
options[:input_directory] = op
|
83
|
+
end
|
66
84
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
85
|
+
opt.on("-v","--variable ", "SEQUENCE: The variable you want to use to reference the encoded data") do |op|
|
86
|
+
puts "Variable: #{op}"
|
87
|
+
options[:variable] = op
|
88
|
+
end
|
89
|
+
|
90
|
+
opt.on("-n","--name ", "SEQUENCE: The file name you wish to save the output encoded data") do |op|
|
91
|
+
puts "Output File Name: #{op}"
|
92
|
+
options[:file_name] = op
|
93
|
+
end
|
73
94
|
|
95
|
+
opt.on("-o","--output ", "SEQUENCE: Where should this file be saved?") do |op|
|
96
|
+
puts "Output Directory: #{op}"
|
97
|
+
options[:output_directory] = op
|
98
|
+
end
|
99
|
+
|
100
|
+
## Sequence
|
101
|
+
opt.on("sequnce") do
|
102
|
+
if options.size == 4
|
103
|
+
lw.sequence(options)
|
104
|
+
else
|
105
|
+
puts "SEQUENCE: Oops looks like you're missing some options."
|
106
|
+
end
|
107
|
+
end
|
108
|
+
else
|
109
|
+
puts "You need to specify an action. enter legworker -h to see documentation"
|
110
|
+
end
|
111
|
+
end
|
74
112
|
opt_parser.parse!
|
data/legworker.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Legworker::VERSION
|
9
9
|
spec.authors = ["DrewDahlman"]
|
10
10
|
spec.email = ["info@drewdahlman.com"]
|
11
|
-
spec.description = %q{
|
12
|
-
spec.summary = %q{
|
11
|
+
spec.description = %q{A gem of handy utils from Legwork}
|
12
|
+
spec.summary = %q{A gem of handy utils from Legwork}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/lib/legworker.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "legworker/version"
|
2
|
+
require "legworker/utils"
|
2
3
|
require "optparse"
|
4
|
+
require 'base64'
|
3
5
|
|
4
6
|
module Legworker
|
5
7
|
class Legs
|
@@ -60,12 +62,62 @@ module Legworker
|
|
60
62
|
|
61
63
|
File.open(database_yml, "w") { |f| f.puts db_contents }
|
62
64
|
|
63
|
-
puts "Starting Vagrant...."
|
65
|
+
puts "Starting Vagrant....".green
|
64
66
|
|
65
67
|
system('vagrant up || exit')
|
66
68
|
|
67
69
|
system('vagrant provision')
|
68
70
|
end
|
69
71
|
|
72
|
+
#------------------------------------------------------------------------------
|
73
|
+
#
|
74
|
+
# Sequence
|
75
|
+
#
|
76
|
+
#------------------------------------------------------------------------------
|
77
|
+
def sequence(options)
|
78
|
+
input_directory = options[:input_directory]
|
79
|
+
output_directory = options[:output_directory]
|
80
|
+
file_name = options[:file_name]
|
81
|
+
variable_name = options[:variable]
|
82
|
+
file_count = 0
|
83
|
+
accepted_file_types = [".jpeg",".jpg",".JPEG",".JPG",".gif",".GIF",".png",".PNG"]
|
84
|
+
extension = "png"
|
85
|
+
encoded_data = ""
|
86
|
+
|
87
|
+
## Verify path is valid
|
88
|
+
if File.directory?(input_directory)
|
89
|
+
|
90
|
+
## Verify Output Directory Exists
|
91
|
+
if File.directory?(output_directory)
|
92
|
+
puts "Creating #{file_name} in #{output_directory}".green
|
93
|
+
if out_file = File.new("#{output_directory}/#{file_name}.json", "w")
|
94
|
+
encoded_data = "var #{variable_name} = ["
|
95
|
+
puts "//////////////////////////////////////////////////////////////////////////////////////".green
|
96
|
+
Dir.foreach("#{input_directory}") do |item|
|
97
|
+
if accepted_file_types.include? File.extname("#{item}")
|
98
|
+
puts "Encoding: #{item}".cyan
|
99
|
+
if Base64.encode64( open("#{input_directory}/#{item}").read)
|
100
|
+
encoded_string = Base64.encode64( open("#{input_directory}/#{item}").read).gsub("\n", '')
|
101
|
+
encoded_data << "'data:image/#{extension};base64,#{encoded_string}',"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
puts "//////////////////////////////////////////////////////////////////////////////////////".green
|
106
|
+
encoded_data << "]"
|
107
|
+
out_file.puts encoded_data.gsub("\n","")
|
108
|
+
out_file.close
|
109
|
+
|
110
|
+
else
|
111
|
+
puts "Failed to create #{file_name} in #{output_directory}".red
|
112
|
+
end
|
113
|
+
else
|
114
|
+
puts "Oops looks like your output directory doesn't exist.".red
|
115
|
+
end
|
116
|
+
|
117
|
+
else
|
118
|
+
puts "Oops looks like that directory is not valid.".red
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
70
122
|
end
|
71
123
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class String
|
2
|
+
def black; "\033[30m#{self}\033[0m" end
|
3
|
+
def red; "\033[31m#{self}\033[0m" end
|
4
|
+
def green; "\033[32m#{self}\033[0m" end
|
5
|
+
def brown; "\033[33m#{self}\033[0m" end
|
6
|
+
def blue; "\033[34m#{self}\033[0m" end
|
7
|
+
def magenta; "\033[35m#{self}\033[0m" end
|
8
|
+
def cyan; "\033[36m#{self}\033[0m" end
|
9
|
+
def gray; "\033[37m#{self}\033[0m" end
|
10
|
+
def bg_black; "\033[40m#{self}\0330m" end
|
11
|
+
def bg_red; "\033[41m#{self}\033[0m" end
|
12
|
+
def bg_green; "\033[42m#{self}\033[0m" end
|
13
|
+
def bg_brown; "\033[43m#{self}\033[0m" end
|
14
|
+
def bg_blue; "\033[44m#{self}\033[0m" end
|
15
|
+
def bg_magenta; "\033[45m#{self}\033[0m" end
|
16
|
+
def bg_cyan; "\033[46m#{self}\033[0m" end
|
17
|
+
def bg_gray; "\033[47m#{self}\033[0m" end
|
18
|
+
def bold; "\033[1m#{self}\033[22m" end
|
19
|
+
def reverse_color; "\033[7m#{self}\033[27m" end
|
20
|
+
end
|
data/lib/legworker/version.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legworker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- DrewDahlman
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-27 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,20 +27,18 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
|
-
description:
|
41
|
+
description: A gem of handy utils from Legwork
|
47
42
|
email:
|
48
43
|
- info@drewdahlman.com
|
49
44
|
executables:
|
@@ -59,30 +54,30 @@ files:
|
|
59
54
|
- bin/legworker
|
60
55
|
- legworker.gemspec
|
61
56
|
- lib/legworker.rb
|
57
|
+
- lib/legworker/utils.rb
|
62
58
|
- lib/legworker/version.rb
|
63
59
|
homepage: ''
|
64
60
|
licenses:
|
65
61
|
- MIT
|
62
|
+
metadata: {}
|
66
63
|
post_install_message:
|
67
64
|
rdoc_options: []
|
68
65
|
require_paths:
|
69
66
|
- lib
|
70
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
68
|
requirements:
|
73
|
-
- -
|
69
|
+
- - '>='
|
74
70
|
- !ruby/object:Gem::Version
|
75
71
|
version: '0'
|
76
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
73
|
requirements:
|
79
|
-
- -
|
74
|
+
- - '>='
|
80
75
|
- !ruby/object:Gem::Version
|
81
76
|
version: '0'
|
82
77
|
requirements: []
|
83
78
|
rubyforge_project:
|
84
|
-
rubygems_version:
|
79
|
+
rubygems_version: 2.0.3
|
85
80
|
signing_key:
|
86
|
-
specification_version:
|
87
|
-
summary:
|
81
|
+
specification_version: 4
|
82
|
+
summary: A gem of handy utils from Legwork
|
88
83
|
test_files: []
|