drakkon 0.0.3

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.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +50 -0
  3. data/bin/drakkon +16 -0
  4. data/lib/drakkon/build.rb +126 -0
  5. data/lib/drakkon/cli.rb +64 -0
  6. data/lib/drakkon/gem/bundle.rb +116 -0
  7. data/lib/drakkon/gem/cli.rb +46 -0
  8. data/lib/drakkon/gem/configure.rb +73 -0
  9. data/lib/drakkon/gem/gem.rb +56 -0
  10. data/lib/drakkon/gem/helpers/check.rb +110 -0
  11. data/lib/drakkon/gem/helpers/files.rb +57 -0
  12. data/lib/drakkon/gem/helpers/general.rb +21 -0
  13. data/lib/drakkon/gem/helpers/modules.rb +51 -0
  14. data/lib/drakkon/gem/helpers/source.rb +43 -0
  15. data/lib/drakkon/gem/install.rb +24 -0
  16. data/lib/drakkon/init.rb +85 -0
  17. data/lib/drakkon/lib/hub.rb +112 -0
  18. data/lib/drakkon/lib/images/biggest.rb +43 -0
  19. data/lib/drakkon/lib/images/blur.rb +76 -0
  20. data/lib/drakkon/lib/images/bulk_rename.rb +86 -0
  21. data/lib/drakkon/lib/images/canvas.rb +74 -0
  22. data/lib/drakkon/lib/images/cli.rb +78 -0
  23. data/lib/drakkon/lib/images/desaturate.rb +58 -0
  24. data/lib/drakkon/lib/images/flip_flop.rb +76 -0
  25. data/lib/drakkon/lib/images/gif.rb +61 -0
  26. data/lib/drakkon/lib/images/index.rb +185 -0
  27. data/lib/drakkon/lib/images/list.rb +56 -0
  28. data/lib/drakkon/lib/images/modulate.rb +69 -0
  29. data/lib/drakkon/lib/images/resize.rb +83 -0
  30. data/lib/drakkon/lib/images/roll.rb +68 -0
  31. data/lib/drakkon/lib/images/rotate.rb +60 -0
  32. data/lib/drakkon/lib/images/scale.rb +86 -0
  33. data/lib/drakkon/lib/images/sepia.rb +64 -0
  34. data/lib/drakkon/lib/images/shift.rb +89 -0
  35. data/lib/drakkon/lib/images/split.rb +93 -0
  36. data/lib/drakkon/lib/images/spritesheet.rb +85 -0
  37. data/lib/drakkon/lib/images/trim.rb +56 -0
  38. data/lib/drakkon/lib/images/white.rb +56 -0
  39. data/lib/drakkon/lib/logbot.rb +86 -0
  40. data/lib/drakkon/lib/manifest.rb +74 -0
  41. data/lib/drakkon/lib/pastel.rb +49 -0
  42. data/lib/drakkon/lib/settings.rb +130 -0
  43. data/lib/drakkon/lib/shims.rb +8 -0
  44. data/lib/drakkon/lib/version.rb +79 -0
  45. data/lib/drakkon/release.rb +3 -0
  46. data/lib/drakkon/run/commands/images.rb +14 -0
  47. data/lib/drakkon/run/commands/log.rb +57 -0
  48. data/lib/drakkon/run/commands/restart.rb +14 -0
  49. data/lib/drakkon/run/helpers.rb +60 -0
  50. data/lib/drakkon/run/reader_shim.rb +110 -0
  51. data/lib/drakkon/run/tty.rb +119 -0
  52. data/lib/drakkon/run.rb +80 -0
  53. data/lib/drakkon/setup.rb +31 -0
  54. data/lib/drakkon/skeleton/cli.rb +46 -0
  55. data/lib/drakkon/skeleton/deploy.rb +105 -0
  56. data/lib/drakkon/skeleton/helpers/check.rb +143 -0
  57. data/lib/drakkon/skeleton/helpers/general.rb +21 -0
  58. data/lib/drakkon/skeleton/helpers/source.rb +43 -0
  59. data/lib/drakkon/skeleton/install.rb +31 -0
  60. data/lib/drakkon/skeleton/template.rb +14 -0
  61. data/lib/drakkon/web.rb +68 -0
  62. data/lib/drakkon.rb +43 -0
  63. metadata +302 -0
@@ -0,0 +1,68 @@
1
+ module Drakkon
2
+ module Images
3
+ # Roll Images like an old TV
4
+ # https://imagemagick.org/Usage/warping/#roll
5
+ module Roll
6
+ def self.run!(args = [])
7
+ # Amount
8
+ amount = if args.empty?
9
+ prompt.ask('Roll Amount(+-LR+-UD)? (e.g. -10+0): ')
10
+ else
11
+ args.shift
12
+ end
13
+
14
+ puts <<~HELP
15
+ Usage [WxH] [gravity]
16
+ - Run in the directory you wish to modify the images
17
+ - Rolls the images via MiniMagick
18
+
19
+ Roll: Amount: #{amount}
20
+ Current Directory;
21
+ #{Dir.pwd.pastel(:yellow)}
22
+
23
+ Images:
24
+ HELP
25
+
26
+ images.sort.each do |img|
27
+ img_s = img.gsub("#{Dir.pwd}/", '').pastel(:yellow)
28
+ puts " - #{img_s}"
29
+ end
30
+ puts
31
+
32
+ exit unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} Roll!? #{'(Destructive)'.pastel(:red)}"
33
+
34
+ start(amount)
35
+ end
36
+
37
+ def self.start(amount)
38
+ images.each do |img|
39
+ LogBot.info('Image Roll', img)
40
+ process(img, amount)
41
+ end
42
+ end
43
+
44
+ def self.process(file, amount)
45
+ image = MiniMagick::Image.open(file)
46
+
47
+ LogBot.info('Image Roll', "Rolling: #{file}")
48
+
49
+ img = image.combine_options do |cmd|
50
+ cmd.background 'transparent'
51
+ cmd.roll amount
52
+ end
53
+
54
+ img.write file
55
+ end
56
+
57
+ def self.images
58
+ Dir["#{Dir.pwd}/**/*.png"]
59
+ end
60
+
61
+ def self.prompt
62
+ TTY::Prompt.new(active_color: :cyan)
63
+ end
64
+ # =========================================================
65
+ end
66
+ # =========================================================
67
+ end
68
+ end
@@ -0,0 +1,60 @@
1
+ module Drakkon
2
+ module Images
3
+ # General Image Index Helper
4
+ module Rotate
5
+ def self.run!(args = [])
6
+ # Rotate
7
+ angle = if args.empty?
8
+ prompt.ask('Rotate Angle? (e.g. 90,180,45): ')
9
+ else
10
+ args.shift
11
+ end
12
+
13
+ puts <<~HELP
14
+ Usage [angle]
15
+ - Run in the directory you wish to modify the images
16
+ - Rotate the images via MiniMagick
17
+ - y / yes / Y / Yes for affirmative args
18
+
19
+ Angle: #{angle}
20
+
21
+ Images:
22
+ HELP
23
+
24
+ images.sort.each do |img|
25
+ img_s = img.gsub("#{Dir.pwd}/", '').pastel(:yellow)
26
+ puts " - #{img_s}"
27
+ end
28
+ puts
29
+
30
+ exit unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} Rotate!? #{'(Destructive)'.pastel(:red)}"
31
+
32
+ start(angle)
33
+ end
34
+
35
+ def self.start(angle)
36
+ images.each do |img|
37
+ LogBot.info('Image Rotate', img)
38
+ process(img, angle)
39
+ end
40
+ end
41
+
42
+ def self.process(file, angle)
43
+ image = MiniMagick::Image.open(file)
44
+
45
+ image.rotate(angle)
46
+ image.write file
47
+ end
48
+
49
+ def self.images
50
+ Dir["#{Dir.pwd}/**/*.png"]
51
+ end
52
+
53
+ def self.prompt
54
+ TTY::Prompt.new(active_color: :cyan)
55
+ end
56
+ # =========================================================
57
+ end
58
+ # =========================================================
59
+ end
60
+ end
@@ -0,0 +1,86 @@
1
+ module Drakkon
2
+ module Images
3
+ # General Image Index Helper
4
+ module Scale
5
+ def self.run!(args = [])
6
+ # Sizing
7
+ scale = if args.empty?
8
+ prompt.ask('Target Scale? (e.g. 100,50,25): ')
9
+ else
10
+ args.shift
11
+ end
12
+
13
+ scale = scale.to_f / 100
14
+ LogBot.info('Image Scale', "Scale: #{scale}")
15
+
16
+ # Recommend as Options?
17
+ # image.filter 'Sinc'
18
+ # image.filter 'Gaussian'
19
+
20
+ # Potentially Support Custom Filters?
21
+ filter = if args.empty?
22
+ 'Lanczos2'
23
+ else
24
+ args.shift
25
+ end
26
+
27
+ puts <<~HELP
28
+ Usage [size] [filter = Lanczos2]
29
+ - Run in the directory you wish to modify the images
30
+ - Resizes the images via MiniMagick
31
+ - Each image sizing values scaled by (value / 100)
32
+
33
+ #{'Note: this will be best fit! This will retain aspect ratio!'.pastel(:bright_blue)}
34
+
35
+ Filter: #{filter} to Size: #{scale}
36
+ Current Directory;
37
+ #{Dir.pwd.pastel(:yellow)}
38
+
39
+ Images:
40
+ HELP
41
+
42
+ images.sort.each do |img|
43
+ img_s = img.gsub("#{Dir.pwd}/", '').pastel(:yellow)
44
+ puts " - #{img_s}"
45
+ end
46
+ puts
47
+
48
+ unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} Scale Images!? #{'(Destructive)'.pastel(:red)}"
49
+ exit
50
+ end
51
+
52
+ start(filter, scale)
53
+ end
54
+
55
+ def self.start(filter, scale)
56
+ images.each do |img|
57
+ resize(img, filter, scale)
58
+ end
59
+ end
60
+
61
+ def self.resize(file, filter, scale)
62
+ image = MiniMagick::Image.open(file)
63
+
64
+ # Calculate Size / Width Primpt
65
+ width = (image.width * scale).round
66
+ height = (image.height * scale).round
67
+ size = "#{width}x#{height}"
68
+
69
+ LogBot.info('Image Scale', "#{File.basename file} => #{scale}: #{size}")
70
+ image.filter filter
71
+ image.resize size
72
+ image.write file
73
+ end
74
+
75
+ def self.images
76
+ Dir["#{Dir.pwd}/**/*.png"]
77
+ end
78
+
79
+ def self.prompt
80
+ TTY::Prompt.new(active_color: :cyan)
81
+ end
82
+ # =========================================================
83
+ end
84
+ # =========================================================
85
+ end
86
+ end
@@ -0,0 +1,64 @@
1
+ module Drakkon
2
+ module Images
3
+ # General Image Index Helper
4
+ # https://imagemagick.org/script/command-line-options.php#sepia-tone
5
+ module Sepia
6
+ def self.run!(args = [])
7
+ # Amount
8
+ amount = if args.empty?
9
+ prompt.ask('Sepia Threshold? (e.g. 80): ')
10
+ else
11
+ args.shift
12
+ end
13
+
14
+ puts <<~HELP
15
+ Usage
16
+ - Run in the directory you wish to modify the images
17
+ - Applies a special effect to the image, similar to the effect achieved in a photo darkroom by sepia toning.
18
+
19
+ Sepia: Amount: #{amount}
20
+ Current Directory;
21
+ #{Dir.pwd.pastel(:yellow)}
22
+
23
+ Images:
24
+ HELP
25
+
26
+ images.sort.each do |img|
27
+ img_s = img.gsub("#{Dir.pwd}/", '').pastel(:yellow)
28
+ puts " - #{img_s}"
29
+ end
30
+ puts
31
+
32
+ exit unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} Sepia!? #{'(Destructive)'.pastel(:red)}"
33
+
34
+ start(amount)
35
+ end
36
+
37
+ def self.start(amount)
38
+ images.each do |img|
39
+ LogBot.info('Image Sepia', img)
40
+ process(img, amount)
41
+ end
42
+ end
43
+
44
+ def self.process(file, amount)
45
+ convert = MiniMagick::Tool::Convert.new
46
+ convert << file
47
+ convert.colorspace('RGB')
48
+ convert.sepia_tone("#{amount}%")
49
+ convert << file
50
+ convert.call
51
+ end
52
+
53
+ def self.images
54
+ Dir["#{Dir.pwd}/**/*.png"]
55
+ end
56
+
57
+ def self.prompt
58
+ TTY::Prompt.new(active_color: :cyan)
59
+ end
60
+ # =========================================================
61
+ end
62
+ # =========================================================
63
+ end
64
+ end
@@ -0,0 +1,89 @@
1
+ module Drakkon
2
+ module Images
3
+ # General Image Index Helper
4
+ module Shift
5
+ # TODO: Deprecate / Fix / Remove?
6
+ # This isn't behaving like I expected it to getting a canvas shift
7
+ def self.run!(args = [])
8
+ # Sizing
9
+ size = if args.empty?
10
+ prompt.ask('Shift Amount(LRxUD)? (e.g. -10x0): ')
11
+ else
12
+ args.shift
13
+ end
14
+
15
+ gravity = if args.empty?
16
+ prompt.ask('Gravity? (west,east,north,south): ', default: 'west')
17
+ else
18
+ args.shift
19
+ end
20
+
21
+ puts <<~HELP
22
+ Usage [WxH] [gravity]
23
+ - Run in the directory you wish to modify the images
24
+ - Shifts the images via MiniMagick
25
+ #{' '}
26
+
27
+ Shift: Size: #{size}, Gravity: #{gravity}
28
+ Current Directory;
29
+ #{Dir.pwd.pastel(:yellow)}
30
+
31
+ Images:
32
+ HELP
33
+
34
+ images.sort.each do |img|
35
+ img_s = img.gsub("#{Dir.pwd}/", '').pastel(:yellow)
36
+ puts " - #{img_s}"
37
+ end
38
+ puts
39
+
40
+ exit unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} Shift!? #{'(Destructive)'.pastel(:red)}"
41
+
42
+ start(size, gravity)
43
+ end
44
+
45
+ def self.start(size, gravity)
46
+ images.each do |img|
47
+ LogBot.info('Image Shift', img)
48
+ process(img, gravity, size)
49
+ end
50
+ end
51
+
52
+ def self.process(file, gravity, size)
53
+ image = MiniMagick::Image.open(file)
54
+ # image << file
55
+ # convert.colorspace('sRGB')
56
+ # convert.fill('white')
57
+ # convert.colorize(100)
58
+ # convert << file
59
+ # convert.call
60
+
61
+ LogBot.info('Image Shift', "Shifting: #{file}")
62
+
63
+ img = image.combine_options do |cmd|
64
+ cmd.gravity gravity
65
+ cmd.background 'transparent'
66
+ cmd.splice size
67
+ end
68
+
69
+ img.write file
70
+
71
+ # image.gravity gravity
72
+ # image.background 'transparent'
73
+ # image.splice size
74
+ # image.call
75
+ # image.write file
76
+ end
77
+
78
+ def self.images
79
+ Dir["#{Dir.pwd}/**/*.png"]
80
+ end
81
+
82
+ def self.prompt
83
+ TTY::Prompt.new(active_color: :cyan)
84
+ end
85
+ # =========================================================
86
+ end
87
+ # =========================================================
88
+ end
89
+ end
@@ -0,0 +1,93 @@
1
+ module Drakkon
2
+ module Images
3
+ # General Image Index Helper
4
+ module SplitSpriteSheet
5
+ def self.run!(args = [])
6
+ image = if args.empty?
7
+ prompt.select('What image to split?', images, filter: true)
8
+ else
9
+ args.first
10
+ end
11
+
12
+ image = "#{Dir.pwd}/#{image}.png"
13
+
14
+ unless File.exist?(image)
15
+ LogBot.fatal('Split', "Unable to find: '#{image}'")
16
+ exit 1
17
+ end
18
+
19
+ sizing = dimensions(image)
20
+
21
+ LogBot.info('Split', "Image Size: #{sizing[:w]}, #{sizing[:h]}")
22
+
23
+ # Columns
24
+ columns = if args.empty?
25
+ prompt.ask('Columns: ', default: 5, convert: :int)
26
+ else
27
+ args.shift
28
+ end
29
+
30
+ # Rows
31
+ rows = if args.empty?
32
+ prompt.ask('Rows: ', default: 5, convert: :int)
33
+ else
34
+ args.shift
35
+ end
36
+
37
+ width = sizing[:w] / columns
38
+ height = sizing[:h] / rows
39
+
40
+ puts <<~HELP
41
+ Usage [file]
42
+ - Modify one file into a directory of split images
43
+
44
+
45
+ Split:
46
+ Rows: #{rows}, Columns: #{columns}
47
+ Size: #{width} x #{height}
48
+ Current Directory: #{Dir.pwd.pastel(:yellow)}
49
+
50
+ Image to Modify: #{image}
51
+ HELP
52
+
53
+ puts
54
+
55
+ exit unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} Split!? #{'(Destructive)'.pastel(:red)}"
56
+
57
+ process(image, width, height)
58
+ rescue TTY::Reader::InputInterrupt
59
+ exit 0
60
+ end
61
+
62
+ def self.process(file, width, height)
63
+ LogBot.info('Image Split', file)
64
+ convert = MiniMagick::Tool::Convert.new
65
+ convert << file
66
+ convert.crop("#{width}x#{height}")
67
+ convert << file
68
+ convert.call
69
+ end
70
+
71
+ def self.images
72
+ Dir["#{Dir.pwd}/*.png"].map do |x|
73
+ File.basename(x, '.png')
74
+ end.sort
75
+ end
76
+
77
+ def self.dimensions(file)
78
+ img = MiniMagick::Image.open(file)
79
+
80
+ {
81
+ w: img.width,
82
+ h: img.height
83
+ }
84
+ end
85
+
86
+ def self.prompt
87
+ TTY::Prompt.new(active_color: :cyan)
88
+ end
89
+ # =========================================================
90
+ end
91
+ # =========================================================
92
+ end
93
+ end
@@ -0,0 +1,85 @@
1
+ module Drakkon
2
+ module Images
3
+ # General Image Index Helper
4
+ module SpriteSheetCombine
5
+ def self.run!(args = [])
6
+ img_name = if args.empty?
7
+ prompt.ask('New File Name? (e.g. rawr): ')
8
+ else
9
+ args.shift
10
+ end
11
+
12
+ puts <<~HELP
13
+ Usage [size] [filter = Lanczos2]
14
+ - Run in the directory you wish to modify the images
15
+ - Resizes the images via MiniMagick
16
+ - Each image sizing values scaled by (value / 100)
17
+
18
+
19
+ Image Target: #{img_name}
20
+ Current Directory;
21
+ #{Dir.pwd.pastel(:yellow)}
22
+
23
+ Images:
24
+ HELP
25
+
26
+ images.each do |img|
27
+ img_s = img.gsub("#{Dir.pwd}/", '').pastel(:yellow)
28
+ puts " - #{img_s}"
29
+ end
30
+ puts
31
+
32
+ exit unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} Combine?'"
33
+
34
+ process(img_name)
35
+ rescue TTY::Reader::InputInterrupt
36
+ exit 0
37
+ end
38
+
39
+ def self.process(img_name)
40
+ LogBot.info('Image Spritesheet', img_name)
41
+
42
+ img = dimensions(images.first)
43
+ img_name += '.png'
44
+
45
+ montage = MiniMagick::Tool::Montage.new
46
+ images.each do |imgn|
47
+ montage << imgn
48
+ end
49
+
50
+ montage.geometry "#{img.w}x#{img.h}+0+0"
51
+ montage.background 'none'
52
+ montage << "#{Dir.pwd}/#{img_name}"
53
+
54
+ montage.call
55
+ end
56
+
57
+ def self.dimensions(file)
58
+ img = MiniMagick::Image.open(file)
59
+
60
+ {
61
+ w: img.width,
62
+ h: img.height
63
+ }
64
+ end
65
+
66
+ def self.images
67
+ @images ||= sorted_images
68
+ end
69
+
70
+ def self.sorted_images
71
+ numbers = Dir["#{Dir.pwd}/*.png"].map do |x|
72
+ File.basename(x, '.png').to_i
73
+ end
74
+
75
+ numbers.sort.map { |x| "#{x}.png" }
76
+ end
77
+
78
+ def self.prompt
79
+ TTY::Prompt.new(active_color: :cyan)
80
+ end
81
+ # =========================================================
82
+ end
83
+ # =========================================================
84
+ end
85
+ end
@@ -0,0 +1,56 @@
1
+ module Drakkon
2
+ module Images
3
+ # General Image Index Helper
4
+ module Trim
5
+ def self.run!(_args = [])
6
+ puts <<~HELP
7
+ Usage
8
+ - Run in the directory you wish to modify the images
9
+ - Trim/Repage the images via MiniMagick
10
+ #{' '}
11
+ Current Directory;
12
+ #{Dir.pwd.pastel(:yellow)}
13
+
14
+ Images:
15
+ HELP
16
+
17
+ images.sort.each do |img|
18
+ img_s = img.gsub("#{Dir.pwd}/", '').pastel(:yellow)
19
+ puts " - #{img_s}"
20
+ end
21
+ puts
22
+
23
+ unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} Scale Images!? #{'(Destructive)'.pastel(:red)}"
24
+ exit
25
+ end
26
+
27
+ start
28
+ end
29
+
30
+ def self.start
31
+ images.each do |img|
32
+ process(img)
33
+ end
34
+ end
35
+
36
+ def self.process(file)
37
+ image = MiniMagick::Image.open(file)
38
+
39
+ LogBot.info('Image Trim', File.basename(file).to_s)
40
+ image.trim
41
+ image.repage
42
+ image.write output_file
43
+ end
44
+
45
+ def self.images
46
+ Dir["#{Dir.pwd}/**/*.png"]
47
+ end
48
+
49
+ def self.prompt
50
+ TTY::Prompt.new(active_color: :cyan)
51
+ end
52
+ # =========================================================
53
+ end
54
+ # =========================================================
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ module Drakkon
2
+ module Images
3
+ # General Image Index Helper
4
+ module White
5
+ def self.run!(_args = [])
6
+ puts <<~HELP
7
+ Usage
8
+ - Run in the directory you wish to modify the images
9
+ - Changes the colorspace to 100% white via MiniMagick
10
+
11
+ Current Directory;
12
+ #{Dir.pwd.pastel(:yellow)}
13
+
14
+ Images:
15
+ HELP
16
+
17
+ images.sort.each do |img|
18
+ img_s = img.gsub("#{Dir.pwd}/", '').pastel(:yellow)
19
+ puts " - #{img_s}"
20
+ end
21
+ puts
22
+
23
+ exit unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} All White!? #{'(Destructive)'.pastel(:red)}"
24
+
25
+ start
26
+ end
27
+
28
+ def self.start
29
+ images.each do |img|
30
+ LogBot.info('Image White', img)
31
+ process(img)
32
+ end
33
+ end
34
+
35
+ def self.process(file)
36
+ convert = MiniMagick::Tool::Convert.new
37
+ convert << file
38
+ convert.colorspace('sRGB')
39
+ convert.fill('white')
40
+ convert.colorize(100)
41
+ convert << file
42
+ convert.call
43
+ end
44
+
45
+ def self.images
46
+ Dir["#{Dir.pwd}/**/*.png"]
47
+ end
48
+
49
+ def self.prompt
50
+ TTY::Prompt.new(active_color: :cyan)
51
+ end
52
+ # =========================================================
53
+ end
54
+ # =========================================================
55
+ end
56
+ end