scripto 0.0.3 → 1.0.0

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.
@@ -17,13 +17,7 @@ module Scripto
17
17
 
18
18
  # Return the md5 checksum for the file at +path+.
19
19
  def md5_file(path)
20
- File.open(path) do |f|
21
- digest, buf = Digest::MD5.new, ""
22
- while f.read(4096, buf)
23
- digest.update(buf)
24
- end
25
- digest.hexdigest
26
- end
20
+ Digest::MD5.file(path).hexdigest
27
21
  end
28
22
 
29
23
  # Return the md5 checksum for +str+.
@@ -44,4 +38,4 @@ module Scripto
44
38
  (1..len).map { BASE_62.sample }.join
45
39
  end
46
40
  end
47
- end
41
+ end
@@ -4,19 +4,17 @@ require "shellwords"
4
4
  module Scripto
5
5
  module RunCommands
6
6
  # The error thrown by #run, #run_capture and #run_quietly on failure.
7
- class Error < StandardError
7
+ class RunError < StandardError
8
8
  end
9
9
 
10
- # Run an external command. Raise Error if something goes wrong. The
10
+ # Run an external command. Raise RunError if something goes wrong. The
11
11
  # command will be echoed if verbose?.
12
12
  #
13
13
  # Usage is similar to Kernel#system. If +args+ is nil, +command+ will be
14
- # passed to the shell. If +args+ are included, the +command+ and +args+
15
- # will be run directly without the shell.
14
+ # passed to the shell. If +args+ are included, the +command+ and +args+ will
15
+ # be run directly without the shell.
16
16
  def run(command, args = nil)
17
- cmd = CommandLine.new(command, args)
18
- vputs(cmd)
19
- cmd.run
17
+ CommandLine.new(command, args).run
20
18
  end
21
19
 
22
20
  # Run a command and capture the output like backticks. See #run
@@ -34,12 +32,10 @@ module Scripto
34
32
 
35
33
  # Returns true if the command succeeds. See #run for details.
36
34
  def run_succeeds?(command, args = nil)
37
- begin
38
- run_quietly(command, args)
39
- true
40
- rescue Error
41
- false
42
- end
35
+ run_quietly(command, args)
36
+ true
37
+ rescue RunError
38
+ false
43
39
  end
44
40
 
45
41
  # Returns true if the command fails. See #run for details.
@@ -52,18 +48,18 @@ module Scripto
52
48
  Shellwords.escape(str)
53
49
  end
54
50
 
55
- protected
56
-
57
51
  # :nodoc:
58
52
  class CommandLine
59
53
  attr_accessor :command, :args
60
54
 
61
55
  def initialize(command, args)
62
56
  self.command = command
63
- self.args = if args
64
- args.map(&:to_s)
65
- else
66
- [ ]
57
+ self.args = begin
58
+ if args
59
+ args.map(&:to_s)
60
+ else
61
+ []
62
+ end
67
63
  end
68
64
  end
69
65
 
@@ -74,9 +70,9 @@ module Scripto
74
70
 
75
71
  def capture
76
72
  begin
77
- captured = `#{to_s}`
73
+ captured = `#{self}`
78
74
  rescue Errno::ENOENT
79
- raise Error, "#{self} failed : ENOENT (No such file or directory)"
75
+ raise RunError, "#{self} failed : ENOENT (No such file or directory)"
80
76
  end
81
77
  raise!($CHILD_STATUS) if $CHILD_STATUS != 0
82
78
  captured
@@ -86,12 +82,13 @@ module Scripto
86
82
  if status.termsig == Signal.list["INT"]
87
83
  raise "#{self} interrupted"
88
84
  end
89
- raise Error, "#{self} failed : #{status.to_i / 256}"
85
+
86
+ raise RunError, "#{self} failed : #{status.to_i / 256}"
90
87
  end
91
88
 
92
89
  def to_s
93
- if args.length > 0
94
- escaped = args.map { |i| Shellwords.escape(i) }
90
+ if !args.empty?
91
+ escaped = args.map { Shellwords.escape(_1) }
95
92
  "#{command} #{escaped.join(" ")}"
96
93
  else
97
94
  command
@@ -99,4 +96,4 @@ module Scripto
99
96
  end
100
97
  end
101
98
  end
102
- end
99
+ end
@@ -1,4 +1,4 @@
1
1
  module Scripto
2
2
  # current Scripto version
3
- VERSION = "0.0.3"
3
+ VERSION = "1.0.0".freeze
4
4
  end
data/lib/scripto.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "scripto/csv_commands"
2
2
  require "scripto/file_commands"
3
+ require "scripto/log_commands"
3
4
  require "scripto/misc_commands"
4
- require "scripto/print_commands"
5
5
  require "scripto/run_commands"
6
6
  require "scripto/version"
7
7
  require "scripto/main"
@@ -9,7 +9,7 @@ require "scripto/main"
9
9
  module Scripto
10
10
  extend CsvCommands
11
11
  extend FileCommands
12
+ extend LogCommands
12
13
  extend MiscCommands
13
- extend PrintCommands
14
14
  extend RunCommands
15
15
  end
data/logo.svg ADDED
@@ -0,0 +1,12 @@
1
+ <svg width="520" height="200" viewBox="0 0 520 200" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="520" height="200" fill="#B3ECFF"/>
3
+ <path d="M148.586 111.08C148.586 115.944 146.762 119.752 143.114 122.504C139.466 125.256 134.09 126.632 126.986 126.632C124.298 126.632 121.802 126.44 119.498 126.056C117.194 125.672 115.21 125.096 113.546 124.328C111.946 123.496 110.666 122.472 109.706 121.256C108.81 120.04 108.362 118.6 108.362 116.936C108.362 115.4 108.682 114.12 109.322 113.096C109.962 112.008 110.73 111.112 111.626 110.408C113.482 111.432 115.594 112.36 117.962 113.192C120.394 113.96 123.178 114.344 126.314 114.344C128.298 114.344 129.802 114.056 130.826 113.48C131.914 112.904 132.458 112.136 132.458 111.176C132.458 110.28 132.074 109.576 131.306 109.064C130.538 108.552 129.258 108.136 127.466 107.816L124.586 107.24C119.018 106.152 114.858 104.456 112.106 102.152C109.418 99.784 108.074 96.424 108.074 92.072C108.074 89.704 108.586 87.56 109.61 85.64C110.634 83.72 112.074 82.12 113.93 80.84C115.786 79.56 117.994 78.568 120.554 77.864C123.178 77.16 126.058 76.808 129.194 76.808C131.562 76.808 133.77 77 135.818 77.384C137.93 77.704 139.754 78.216 141.29 78.92C142.826 79.624 144.042 80.552 144.938 81.704C145.834 82.792 146.282 84.104 146.282 85.64C146.282 87.112 145.994 88.392 145.418 89.48C144.906 90.504 144.234 91.368 143.402 92.072C142.89 91.752 142.122 91.432 141.098 91.112C140.074 90.728 138.954 90.408 137.738 90.152C136.522 89.832 135.274 89.576 133.994 89.384C132.778 89.192 131.658 89.096 130.634 89.096C128.522 89.096 126.89 89.352 125.738 89.864C124.586 90.312 124.01 91.048 124.01 92.072C124.01 92.776 124.33 93.352 124.97 93.8C125.61 94.248 126.826 94.664 128.618 95.048L131.594 95.72C137.738 97.128 142.09 99.08 144.65 101.576C147.274 104.008 148.586 107.176 148.586 111.08ZM183.249 89.768C181.649 89.768 180.113 90.024 178.641 90.536C177.233 91.048 175.985 91.816 174.897 92.84C173.873 93.8 173.041 95.016 172.401 96.488C171.761 97.96 171.441 99.688 171.441 101.672C171.441 105.64 172.561 108.616 174.801 110.6C177.105 112.584 179.889 113.576 183.153 113.576C185.073 113.576 186.737 113.352 188.145 112.904C189.553 112.456 190.801 111.976 191.889 111.464C193.169 112.36 194.129 113.352 194.769 114.44C195.409 115.464 195.729 116.712 195.729 118.184C195.729 120.808 194.481 122.856 191.985 124.328C189.489 125.736 186.033 126.44 181.617 126.44C177.585 126.44 173.937 125.864 170.673 124.712C167.409 123.496 164.593 121.832 162.225 119.72C159.921 117.544 158.129 114.952 156.849 111.944C155.569 108.936 154.929 105.608 154.929 101.96C154.929 97.736 155.601 94.056 156.945 90.92C158.353 87.72 160.241 85.096 162.609 83.048C164.977 81 167.697 79.464 170.769 78.44C173.905 77.416 177.201 76.904 180.657 76.904C185.265 76.904 188.817 77.736 191.313 79.4C193.809 81.064 195.057 83.208 195.057 85.832C195.057 87.048 194.769 88.2 194.193 89.288C193.617 90.312 192.945 91.208 192.177 91.976C191.089 91.464 189.777 90.984 188.241 90.536C186.705 90.024 185.041 89.768 183.249 89.768ZM220.234 124.904C219.594 125.096 218.57 125.288 217.162 125.48C215.818 125.672 214.41 125.768 212.938 125.768C211.53 125.768 210.25 125.672 209.098 125.48C208.01 125.288 207.082 124.904 206.314 124.328C205.546 123.752 204.938 122.984 204.49 122.024C204.106 121 203.914 119.688 203.914 118.088V89.288C203.914 87.816 204.17 86.568 204.682 85.544C205.258 84.456 206.058 83.496 207.082 82.664C208.106 81.832 209.354 81.096 210.826 80.456C212.362 79.752 213.994 79.144 215.722 78.632C217.45 78.12 219.242 77.736 221.098 77.48C222.954 77.16 224.81 77 226.666 77C229.738 77 232.17 77.608 233.962 78.824C235.754 79.976 236.65 81.896 236.65 84.584C236.65 85.48 236.522 86.376 236.266 87.272C236.01 88.104 235.69 88.872 235.306 89.576C233.962 89.576 232.586 89.64 231.178 89.768C229.77 89.896 228.394 90.088 227.05 90.344C225.706 90.6 224.426 90.888 223.21 91.208C222.058 91.464 221.066 91.784 220.234 92.168V124.904ZM242.999 65.384C242.999 62.952 243.799 60.904 245.399 59.24C247.063 57.576 249.239 56.744 251.927 56.744C254.615 56.744 256.759 57.576 258.359 59.24C260.023 60.904 260.855 62.952 260.855 65.384C260.855 67.816 260.023 69.864 258.359 71.528C256.759 73.192 254.615 74.024 251.927 74.024C249.239 74.024 247.063 73.192 245.399 71.528C243.799 69.864 242.999 67.816 242.999 65.384ZM260.087 124.904C259.383 125.032 258.327 125.192 256.919 125.384C255.575 125.64 254.199 125.768 252.791 125.768C251.383 125.768 250.103 125.672 248.951 125.48C247.863 125.288 246.935 124.904 246.167 124.328C245.399 123.752 244.791 122.984 244.343 122.024C243.959 121 243.767 119.688 243.767 118.088V79.016C244.471 78.888 245.495 78.728 246.839 78.536C248.247 78.28 249.655 78.152 251.063 78.152C252.471 78.152 253.719 78.248 254.807 78.44C255.959 78.632 256.919 79.016 257.687 79.592C258.455 80.168 259.031 80.968 259.415 81.992C259.863 82.952 260.087 84.232 260.087 85.832V124.904ZM291.884 76.904C295.724 76.904 299.276 77.416 302.54 78.44C305.868 79.4 308.716 80.904 311.084 82.952C313.452 85 315.308 87.592 316.652 90.728C317.996 93.8 318.668 97.48 318.668 101.768C318.668 105.864 318.092 109.448 316.94 112.52C315.788 115.592 314.156 118.184 312.044 120.296C309.932 122.344 307.372 123.88 304.364 124.904C301.42 125.928 298.124 126.44 294.476 126.44C291.724 126.44 289.164 126.024 286.796 125.192V141.128C286.156 141.32 285.132 141.512 283.724 141.704C282.316 141.96 280.876 142.088 279.404 142.088C277.996 142.088 276.716 141.992 275.564 141.8C274.476 141.608 273.548 141.224 272.78 140.648C272.012 140.072 271.436 139.272 271.052 138.248C270.668 137.288 270.476 136.008 270.476 134.408V88.328C270.476 86.6 270.828 85.192 271.532 84.104C272.3 83.016 273.324 82.024 274.604 81.128C276.588 79.848 279.052 78.824 281.996 78.056C284.94 77.288 288.236 76.904 291.884 76.904ZM292.076 113.576C298.668 113.576 301.964 109.64 301.964 101.768C301.964 97.672 301.132 94.632 299.468 92.648C297.868 90.664 295.532 89.672 292.46 89.672C291.244 89.672 290.156 89.832 289.196 90.152C288.236 90.408 287.404 90.728 286.7 91.112V112.232C287.468 112.616 288.3 112.936 289.196 113.192C290.092 113.448 291.052 113.576 292.076 113.576ZM342.953 108.968C342.953 110.632 343.465 111.816 344.489 112.52C345.577 113.224 347.081 113.576 349.001 113.576C349.961 113.576 350.953 113.512 351.977 113.384C353.001 113.192 353.897 112.968 354.665 112.712C355.241 113.416 355.721 114.216 356.105 115.112C356.553 115.944 356.777 116.968 356.777 118.184C356.777 120.616 355.849 122.6 353.993 124.136C352.201 125.672 349.001 126.44 344.393 126.44C338.761 126.44 334.409 125.16 331.337 122.6C328.329 120.04 326.825 115.88 326.825 110.12V69.032C327.529 68.84 328.521 68.648 329.801 68.456C331.145 68.2 332.553 68.072 334.025 68.072C336.841 68.072 339.017 68.584 340.553 69.608C342.153 70.568 342.953 72.648 342.953 75.848V81.992H355.529C355.913 82.696 356.265 83.592 356.585 84.68C356.969 85.704 357.161 86.856 357.161 88.136C357.161 90.376 356.649 92.008 355.625 93.032C354.665 93.992 353.353 94.472 351.689 94.472H342.953V108.968ZM412.796 101.672C412.796 105.64 412.188 109.192 410.972 112.328C409.756 115.4 408.028 117.992 405.788 120.104C403.612 122.216 400.988 123.816 397.916 124.904C394.844 125.992 391.42 126.536 387.644 126.536C383.868 126.536 380.444 125.96 377.372 124.808C374.3 123.656 371.644 122.024 369.404 119.912C367.228 117.736 365.532 115.112 364.316 112.04C363.1 108.968 362.492 105.512 362.492 101.672C362.492 97.896 363.1 94.472 364.316 91.4C365.532 88.328 367.228 85.736 369.404 83.624C371.644 81.448 374.3 79.784 377.372 78.632C380.444 77.48 383.868 76.904 387.644 76.904C391.42 76.904 394.844 77.512 397.916 78.728C400.988 79.88 403.612 81.544 405.788 83.72C408.028 85.832 409.756 88.424 410.972 91.496C412.188 94.568 412.796 97.96 412.796 101.672ZM379.196 101.672C379.196 105.576 379.932 108.584 381.404 110.696C382.94 112.744 385.052 113.768 387.74 113.768C390.428 113.768 392.476 112.712 393.884 110.6C395.356 108.488 396.092 105.512 396.092 101.672C396.092 97.832 395.356 94.888 393.884 92.84C392.412 90.728 390.332 89.672 387.644 89.672C384.956 89.672 382.876 90.728 381.404 92.84C379.932 94.888 379.196 97.832 379.196 101.672Z" fill="#0186B3"/>
4
+ <path d="M148.586 111.08C148.586 115.944 146.762 119.752 143.114 122.504C139.466 125.256 134.09 126.632 126.986 126.632C124.298 126.632 121.802 126.44 119.498 126.056C117.194 125.672 115.21 125.096 113.546 124.328C111.946 123.496 110.666 122.472 109.706 121.256C108.81 120.04 108.362 118.6 108.362 116.936C108.362 115.4 108.682 114.12 109.322 113.096C109.962 112.008 110.73 111.112 111.626 110.408C113.482 111.432 115.594 112.36 117.962 113.192C120.394 113.96 123.178 114.344 126.314 114.344C128.298 114.344 129.802 114.056 130.826 113.48C131.914 112.904 132.458 112.136 132.458 111.176C132.458 110.28 132.074 109.576 131.306 109.064C130.538 108.552 129.258 108.136 127.466 107.816L124.586 107.24C119.018 106.152 114.858 104.456 112.106 102.152C109.418 99.784 108.074 96.424 108.074 92.072C108.074 89.704 108.586 87.56 109.61 85.64C110.634 83.72 112.074 82.12 113.93 80.84C115.786 79.56 117.994 78.568 120.554 77.864C123.178 77.16 126.058 76.808 129.194 76.808C131.562 76.808 133.77 77 135.818 77.384C137.93 77.704 139.754 78.216 141.29 78.92C142.826 79.624 144.042 80.552 144.938 81.704C145.834 82.792 146.282 84.104 146.282 85.64C146.282 87.112 145.994 88.392 145.418 89.48C144.906 90.504 144.234 91.368 143.402 92.072C142.89 91.752 142.122 91.432 141.098 91.112C140.074 90.728 138.954 90.408 137.738 90.152C136.522 89.832 135.274 89.576 133.994 89.384C132.778 89.192 131.658 89.096 130.634 89.096C128.522 89.096 126.89 89.352 125.738 89.864C124.586 90.312 124.01 91.048 124.01 92.072C124.01 92.776 124.33 93.352 124.97 93.8C125.61 94.248 126.826 94.664 128.618 95.048L131.594 95.72C137.738 97.128 142.09 99.08 144.65 101.576C147.274 104.008 148.586 107.176 148.586 111.08Z" fill="#0186B3"/>
5
+ <path d="M183.249 89.768C181.649 89.768 180.113 90.024 178.641 90.536C177.233 91.048 175.985 91.816 174.897 92.84C173.873 93.8 173.041 95.016 172.401 96.488C171.761 97.96 171.441 99.688 171.441 101.672C171.441 105.64 172.561 108.616 174.801 110.6C177.105 112.584 179.889 113.576 183.153 113.576C185.073 113.576 186.737 113.352 188.145 112.904C189.553 112.456 190.801 111.976 191.889 111.464C193.169 112.36 194.129 113.352 194.769 114.44C195.409 115.464 195.729 116.712 195.729 118.184C195.729 120.808 194.481 122.856 191.985 124.328C189.489 125.736 186.033 126.44 181.617 126.44C177.585 126.44 173.937 125.864 170.673 124.712C167.409 123.496 164.593 121.832 162.225 119.72C159.921 117.544 158.129 114.952 156.849 111.944C155.569 108.936 154.929 105.608 154.929 101.96C154.929 97.736 155.601 94.056 156.945 90.92C158.353 87.72 160.241 85.096 162.609 83.048C164.977 81 167.697 79.464 170.769 78.44C173.905 77.416 177.201 76.904 180.657 76.904C185.265 76.904 188.817 77.736 191.313 79.4C193.809 81.064 195.057 83.208 195.057 85.832C195.057 87.048 194.769 88.2 194.193 89.288C193.617 90.312 192.945 91.208 192.177 91.976C191.089 91.464 189.777 90.984 188.241 90.536C186.705 90.024 185.041 89.768 183.249 89.768Z" fill="#0186B3"/>
6
+ <path d="M220.234 124.904C219.594 125.096 218.57 125.288 217.162 125.48C215.818 125.672 214.41 125.768 212.938 125.768C211.53 125.768 210.25 125.672 209.098 125.48C208.01 125.288 207.082 124.904 206.314 124.328C205.546 123.752 204.938 122.984 204.49 122.024C204.106 121 203.914 119.688 203.914 118.088V89.288C203.914 87.816 204.17 86.568 204.682 85.544C205.258 84.456 206.058 83.496 207.082 82.664C208.106 81.832 209.354 81.096 210.826 80.456C212.362 79.752 213.994 79.144 215.722 78.632C217.45 78.12 219.242 77.736 221.098 77.48C222.954 77.16 224.81 77 226.666 77C229.738 77 232.17 77.608 233.962 78.824C235.754 79.976 236.65 81.896 236.65 84.584C236.65 85.48 236.522 86.376 236.266 87.272C236.01 88.104 235.69 88.872 235.306 89.576C233.962 89.576 232.586 89.64 231.178 89.768C229.77 89.896 228.394 90.088 227.05 90.344C225.706 90.6 224.426 90.888 223.21 91.208C222.058 91.464 221.066 91.784 220.234 92.168V124.904Z" fill="#0186B3"/>
7
+ <path d="M242.999 65.384C242.999 62.952 243.799 60.904 245.399 59.24C247.063 57.576 249.239 56.744 251.927 56.744C254.615 56.744 256.759 57.576 258.359 59.24C260.023 60.904 260.855 62.952 260.855 65.384C260.855 67.816 260.023 69.864 258.359 71.528C256.759 73.192 254.615 74.024 251.927 74.024C249.239 74.024 247.063 73.192 245.399 71.528C243.799 69.864 242.999 67.816 242.999 65.384ZM260.087 124.904C259.383 125.032 258.327 125.192 256.919 125.384C255.575 125.64 254.199 125.768 252.791 125.768C251.383 125.768 250.103 125.672 248.951 125.48C247.863 125.288 246.935 124.904 246.167 124.328C245.399 123.752 244.791 122.984 244.343 122.024C243.959 121 243.767 119.688 243.767 118.088V79.016C244.471 78.888 245.495 78.728 246.839 78.536C248.247 78.28 249.655 78.152 251.063 78.152C252.471 78.152 253.719 78.248 254.807 78.44C255.959 78.632 256.919 79.016 257.687 79.592C258.455 80.168 259.031 80.968 259.415 81.992C259.863 82.952 260.087 84.232 260.087 85.832V124.904Z" fill="#0186B3"/>
8
+ <path d="M291.884 76.904C295.724 76.904 299.276 77.416 302.54 78.44C305.868 79.4 308.716 80.904 311.084 82.952C313.452 85 315.308 87.592 316.652 90.728C317.996 93.8 318.668 97.48 318.668 101.768C318.668 105.864 318.092 109.448 316.94 112.52C315.788 115.592 314.156 118.184 312.044 120.296C309.932 122.344 307.372 123.88 304.364 124.904C301.42 125.928 298.124 126.44 294.476 126.44C291.724 126.44 289.164 126.024 286.796 125.192V141.128C286.156 141.32 285.132 141.512 283.724 141.704C282.316 141.96 280.876 142.088 279.404 142.088C277.996 142.088 276.716 141.992 275.564 141.8C274.476 141.608 273.548 141.224 272.78 140.648C272.012 140.072 271.436 139.272 271.052 138.248C270.668 137.288 270.476 136.008 270.476 134.408V88.328C270.476 86.6 270.828 85.192 271.532 84.104C272.3 83.016 273.324 82.024 274.604 81.128C276.588 79.848 279.052 78.824 281.996 78.056C284.94 77.288 288.236 76.904 291.884 76.904ZM292.076 113.576C298.668 113.576 301.964 109.64 301.964 101.768C301.964 97.672 301.132 94.632 299.468 92.648C297.868 90.664 295.532 89.672 292.46 89.672C291.244 89.672 290.156 89.832 289.196 90.152C288.236 90.408 287.404 90.728 286.7 91.112V112.232C287.468 112.616 288.3 112.936 289.196 113.192C290.092 113.448 291.052 113.576 292.076 113.576Z" fill="#0186B3"/>
9
+ <path d="M342.953 108.968C342.953 110.632 343.465 111.816 344.489 112.52C345.577 113.224 347.081 113.576 349.001 113.576C349.961 113.576 350.953 113.512 351.977 113.384C353.001 113.192 353.897 112.968 354.665 112.712C355.241 113.416 355.721 114.216 356.105 115.112C356.553 115.944 356.777 116.968 356.777 118.184C356.777 120.616 355.849 122.6 353.993 124.136C352.201 125.672 349.001 126.44 344.393 126.44C338.761 126.44 334.409 125.16 331.337 122.6C328.329 120.04 326.825 115.88 326.825 110.12V69.032C327.529 68.84 328.521 68.648 329.801 68.456C331.145 68.2 332.553 68.072 334.025 68.072C336.841 68.072 339.017 68.584 340.553 69.608C342.153 70.568 342.953 72.648 342.953 75.848V81.992H355.529C355.913 82.696 356.265 83.592 356.585 84.68C356.969 85.704 357.161 86.856 357.161 88.136C357.161 90.376 356.649 92.008 355.625 93.032C354.665 93.992 353.353 94.472 351.689 94.472H342.953V108.968Z" fill="#0186B3"/>
10
+ <path d="M412.796 101.672C412.796 105.64 412.188 109.192 410.972 112.328C409.756 115.4 408.028 117.992 405.788 120.104C403.612 122.216 400.988 123.816 397.916 124.904C394.844 125.992 391.42 126.536 387.644 126.536C383.868 126.536 380.444 125.96 377.372 124.808C374.3 123.656 371.644 122.024 369.404 119.912C367.228 117.736 365.532 115.112 364.316 112.04C363.1 108.968 362.492 105.512 362.492 101.672C362.492 97.896 363.1 94.472 364.316 91.4C365.532 88.328 367.228 85.736 369.404 83.624C371.644 81.448 374.3 79.784 377.372 78.632C380.444 77.48 383.868 76.904 387.644 76.904C391.42 76.904 394.844 77.512 397.916 78.728C400.988 79.88 403.612 81.544 405.788 83.72C408.028 85.832 409.756 88.424 410.972 91.496C412.188 94.568 412.796 97.96 412.796 101.672ZM379.196 101.672C379.196 105.576 379.932 108.584 381.404 110.696C382.94 112.744 385.052 113.768 387.74 113.768C390.428 113.768 392.476 112.712 393.884 110.6C395.356 108.488 396.092 105.512 396.092 101.672C396.092 97.832 395.356 94.888 393.884 92.84C392.412 90.728 390.332 89.672 387.644 89.672C384.956 89.672 382.876 90.728 381.404 92.84C379.932 94.888 379.196 97.832 379.196 101.672Z" fill="#0186B3"/>
11
+ <rect x="0.5" y="0.5" width="519" height="199" stroke="black" stroke-opacity="0.5"/>
12
+ </svg>
data/mise.toml ADDED
@@ -0,0 +1,2 @@
1
+ [tools]
2
+ ruby = "3.4.2"
data/scripto.gemspec CHANGED
@@ -1,25 +1,23 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'scripto/version'
3
+ require "scripto/version"
5
4
 
6
- Gem::Specification.new do |spec|
7
- spec.name = "scripto"
8
- spec.version = Scripto::VERSION
9
- spec.platform = Gem::Platform::RUBY
10
- spec.required_ruby_version = ">= 2.0.0"
11
- spec.authors = ["Adam Doppelt"]
12
- spec.email = ["amd@gurge.com"]
13
- spec.summary = "Helpers for writing command line scripts. An extraction from Dwellable."
14
- spec.homepage = "http://github.com/gurgeous/scripto"
15
- spec.license = "MIT"
5
+ Gem::Specification.new do |s|
6
+ s.name = "scripto"
7
+ s.version = Scripto::VERSION
8
+ s.authors = ["Adam Doppelt"]
9
+ s.email = ["amd@gurge.com"]
16
10
 
17
- spec.files = `git ls-files -z`.split("\x0")
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- spec.require_paths = ["lib"]
11
+ s.summary = "Helpers for writing command line scripts. An extraction from Dwellable."
12
+ s.homepage = "http://github.com/gurgeous/scripto"
13
+ s.license = "MIT"
14
+ s.required_ruby_version = ">= 3.4.0"
21
15
 
22
- spec.add_development_dependency "bundler", "~> 1.5"
23
- spec.add_development_dependency "minitest", "~> 5.0"
24
- spec.add_development_dependency "rake"
16
+ # what's in the gem?
17
+ s.files = `git ls-files -z`.split("\x0").reject { _1.match(%r{^test/}) }
18
+ s.require_paths = ["lib"]
19
+
20
+ # gem dependencies
21
+ s.add_dependency "csv", "~> 3.3" # required for 3.4
22
+ s.add_dependency "ostruct", "~> 0.0" # required for 3.4
25
23
  end
metadata CHANGED
@@ -1,92 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scripto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Doppelt
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2017-02-28 00:00:00.000000000 Z
10
+ date: 2026-01-27 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: bundler
13
+ name: csv
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '1.5'
20
- type: :development
18
+ version: '3.3'
19
+ type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '1.5'
25
+ version: '3.3'
27
26
  - !ruby/object:Gem::Dependency
28
- name: minitest
27
+ name: ostruct
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: '5.0'
34
- type: :development
32
+ version: '0.0'
33
+ type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
- version: '5.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- description:
39
+ version: '0.0'
56
40
  email:
57
41
  - amd@gurge.com
58
42
  executables: []
59
43
  extensions: []
60
44
  extra_rdoc_files: []
61
45
  files:
46
+ - ".github/workflows/ci.yml"
62
47
  - ".gitignore"
63
- - ".travis.yml"
48
+ - ".rubocop.yml"
49
+ - ".vscode/extensions.json"
50
+ - ".vscode/settings.json"
64
51
  - Gemfile
52
+ - Gemfile.lock
65
53
  - LICENSE.txt
66
54
  - README.md
67
55
  - Rakefile
68
- - Vagrantfile
56
+ - justfile
69
57
  - lib/scripto.rb
70
58
  - lib/scripto/csv_commands.rb
71
59
  - lib/scripto/file_commands.rb
60
+ - lib/scripto/log_commands.rb
72
61
  - lib/scripto/main.rb
73
62
  - lib/scripto/misc_commands.rb
74
- - lib/scripto/print_commands.rb
75
63
  - lib/scripto/run_commands.rb
76
64
  - lib/scripto/version.rb
65
+ - logo.svg
66
+ - mise.toml
77
67
  - scripto.gemspec
78
- - test/helper.rb
79
- - test/test_csv.rb
80
- - test/test_file.rb
81
- - test/test_misc.rb
82
- - test/test_print.rb
83
- - test/test_run.rb
84
- - vagrant_provision
85
68
  homepage: http://github.com/gurgeous/scripto
86
69
  licenses:
87
70
  - MIT
88
71
  metadata: {}
89
- post_install_message:
90
72
  rdoc_options: []
91
73
  require_paths:
92
74
  - lib
@@ -94,22 +76,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
76
  requirements:
95
77
  - - ">="
96
78
  - !ruby/object:Gem::Version
97
- version: 2.0.0
79
+ version: 3.4.0
98
80
  required_rubygems_version: !ruby/object:Gem::Requirement
99
81
  requirements:
100
82
  - - ">="
101
83
  - !ruby/object:Gem::Version
102
84
  version: '0'
103
85
  requirements: []
104
- rubyforge_project:
105
- rubygems_version: 2.2.2
106
- signing_key:
86
+ rubygems_version: 3.6.2
107
87
  specification_version: 4
108
88
  summary: Helpers for writing command line scripts. An extraction from Dwellable.
109
- test_files:
110
- - test/helper.rb
111
- - test/test_csv.rb
112
- - test/test_file.rb
113
- - test/test_misc.rb
114
- - test/test_print.rb
115
- - test/test_run.rb
89
+ test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 2.1.0
5
- - 2.2.0
6
- - 2.3.0
7
- - 2.4.0
data/Vagrantfile DELETED
@@ -1,121 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
- VAGRANTFILE_API_VERSION = "2"
6
-
7
- Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
- # All Vagrant configuration is done here. The most common configuration
9
- # options are documented and commented below. For a complete reference,
10
- # please see the online documentation at vagrantup.com.
11
-
12
- # Every Vagrant virtual environment requires a box to build off of.
13
- config.vm.box = "precise32"
14
-
15
- # The url from where the 'config.vm.box' box will be fetched if it
16
- # doesn't already exist on the user's system.
17
- config.vm.box_url = "http://files.vagrantup.com/precise32.box"
18
-
19
- # amd
20
- config.vm.provision :shell, path: "vagrant_provision", privileged: false
21
-
22
- # Create a forwarded port mapping which allows access to a specific port
23
- # within the machine from a port on the host machine. In the example below,
24
- # accessing "localhost:8080" will access port 80 on the guest machine.
25
- # config.vm.network :forwarded_port, guest: 80, host: 8080
26
-
27
- # Create a private network, which allows host-only access to the machine
28
- # using a specific IP.
29
- # config.vm.network :private_network, ip: "192.168.33.10"
30
-
31
- # Create a public network, which generally matched to bridged network.
32
- # Bridged networks make the machine appear as another physical device on
33
- # your network.
34
- # config.vm.network :public_network
35
-
36
- # If true, then any SSH connections made will enable agent forwarding.
37
- # Default value: false
38
- # config.ssh.forward_agent = true
39
-
40
- # Share an additional folder to the guest VM. The first argument is
41
- # the path on the host to the actual folder. The second argument is
42
- # the path on the guest to mount the folder. And the optional third
43
- # argument is a set of non-required options.
44
- # config.vm.synced_folder "../data", "/vagrant_data"
45
-
46
- # Provider-specific configuration so you can fine-tune various
47
- # backing providers for Vagrant. These expose provider-specific options.
48
- # Example for VirtualBox:
49
- #
50
- # config.vm.provider :virtualbox do |vb|
51
- # # Don't boot with headless mode
52
- # vb.gui = true
53
- #
54
- # # Use VBoxManage to customize the VM. For example to change memory:
55
- # vb.customize ["modifyvm", :id, "--memory", "1024"]
56
- # end
57
- #
58
- # View the documentation for the provider you're using for more
59
- # information on available options.
60
-
61
- # Enable provisioning with Puppet stand alone. Puppet manifests
62
- # are contained in a directory path relative to this Vagrantfile.
63
- # You will need to create the manifests directory and a manifest in
64
- # the file precise32.pp in the manifests_path directory.
65
- #
66
- # An example Puppet manifest to provision the message of the day:
67
- #
68
- # # group { "puppet":
69
- # # ensure => "present",
70
- # # }
71
- # #
72
- # # File { owner => 0, group => 0, mode => 0644 }
73
- # #
74
- # # file { '/etc/motd':
75
- # # content => "Welcome to your Vagrant-built virtual machine!
76
- # # Managed by Puppet.\n"
77
- # # }
78
- #
79
- # config.vm.provision :puppet do |puppet|
80
- # puppet.manifests_path = "manifests"
81
- # puppet.manifest_file = "site.pp"
82
- # end
83
-
84
- # Enable provisioning with chef solo, specifying a cookbooks path, roles
85
- # path, and data_bags path (all relative to this Vagrantfile), and adding
86
- # some recipes and/or roles.
87
- #
88
- # config.vm.provision :chef_solo do |chef|
89
- # chef.cookbooks_path = "../my-recipes/cookbooks"
90
- # chef.roles_path = "../my-recipes/roles"
91
- # chef.data_bags_path = "../my-recipes/data_bags"
92
- # chef.add_recipe "mysql"
93
- # chef.add_role "web"
94
- #
95
- # # You may also specify custom JSON attributes:
96
- # chef.json = { :mysql_password => "foo" }
97
- # end
98
-
99
- # Enable provisioning with chef server, specifying the chef server URL,
100
- # and the path to the validation key (relative to this Vagrantfile).
101
- #
102
- # The Opscode Platform uses HTTPS. Substitute your organization for
103
- # ORGNAME in the URL and validation key.
104
- #
105
- # If you have your own Chef Server, use the appropriate URL, which may be
106
- # HTTP instead of HTTPS depending on your configuration. Also change the
107
- # validation key to validation.pem.
108
- #
109
- # config.vm.provision :chef_client do |chef|
110
- # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
111
- # chef.validation_key_path = "ORGNAME-validator.pem"
112
- # end
113
- #
114
- # If you're using the Opscode platform, your validator client is
115
- # ORGNAME-validator, replacing ORGNAME with your organization name.
116
- #
117
- # If you have your own Chef Server, the default validation client name is
118
- # chef-validator, unless you changed the configuration.
119
- #
120
- # chef.validation_client_name = "ORGNAME-validator"
121
- end
@@ -1,54 +0,0 @@
1
- module Scripto
2
- module PrintCommands
3
- RESET = "\e[0m"
4
- GREEN = "\e[1;37;42m"
5
- YELLOW = "\e[1;37;43m"
6
- RED = "\e[1;37;41m"
7
-
8
- attr_accessor :verbose
9
-
10
- # Is verbose mode turned on?
11
- def verbose?
12
- !!@verbose
13
- end
14
-
15
- # Turn on verbose mode. #vbanner, #vputs and #vprintf will start printing
16
- # now, and file ops will be printed too.
17
- def verbose!
18
- @verbose = true
19
- end
20
-
21
- # Print a colored banner to $stderr, but only if #verbose?.
22
- def vbanner(str = nil)
23
- banner(str) if verbose?
24
- end
25
-
26
- # Puts to $stderr, but only if #verbose?.
27
- def vputs(str = nil)
28
- $stderr.puts(str) if verbose?
29
- end
30
-
31
- # Printf to $stderr, but only if #verbose?.
32
- def vprintf(str, *args)
33
- $stderr.printf(str, *args) if verbose?
34
- end
35
-
36
- # Print a colored banner to $stderr in green.
37
- def banner(str, color: GREEN)
38
- now = Time.new.strftime("%H:%M:%S")
39
- s = "#{str} ".ljust(72, " ")
40
- $stderr.puts "#{color}[#{now}] #{s}#{RESET}"
41
- end
42
-
43
- # Print a yellow warning banner to $stderr.
44
- def warning(str)
45
- banner("Warning: #{str}", color: YELLOW)
46
- end
47
-
48
- # Print a red error banner to $stderr, then exit.
49
- def fatal(str)
50
- banner(str, color: RED)
51
- exit(1)
52
- end
53
- end
54
- end
data/test/helper.rb DELETED
@@ -1,26 +0,0 @@
1
- require "fileutils"
2
- require "minitest/autorun"
3
- require "minitest/pride"
4
-
5
- $LOAD_PATH << File.expand_path("../../lib", __FILE__)
6
- require "scripto"
7
-
8
- module Helper
9
- TMP_DIR = "/tmp/_scripto_test"
10
-
11
- # attr_accessor :main
12
-
13
- def setup
14
- # self.main = Scripto::Main.new
15
- FileUtils.rm_rf(TMP_DIR)
16
- FileUtils.mkdir_p(TMP_DIR)
17
- @pwd = Dir.pwd
18
- Dir.chdir(TMP_DIR)
19
- Scripto.verbose = false
20
- end
21
-
22
- def teardown
23
- FileUtils.rm_rf(TMP_DIR)
24
- Dir.chdir(@pwd)
25
- end
26
- end
data/test/test_csv.rb DELETED
@@ -1,60 +0,0 @@
1
- require_relative "helper"
2
-
3
- class TestCsv < Minitest::Test
4
- include Helper
5
-
6
- FILE = "test.csv"
7
-
8
- ROWS = [ { a: "1", b: "2", c: "3" }, { a: "4", b: "5", c: "6" } ]
9
- ROWS_EXP = "a,b,c\n1,2,3\n4,5,6\n"
10
- ROWS_REVERSED_EXP = "c,b,a\n3,2,1\n6,5,4\n"
11
-
12
- def test_types
13
- assert_equal(ROWS_EXP, Scripto.csv_to_s(ROWS))
14
- assert_equal(ROWS_EXP, Scripto.csv_to_s(structs))
15
- assert_equal(ROWS_EXP, Scripto.csv_to_s(ostructs))
16
- end
17
-
18
- def test_cols
19
- assert_equal(ROWS_REVERSED_EXP, Scripto.csv_to_s(ROWS, cols: %i(c b a)))
20
- assert_equal(ROWS_REVERSED_EXP, Scripto.csv_to_s(structs, cols: %i(c b a)))
21
- assert_equal(ROWS_REVERSED_EXP, Scripto.csv_to_s(ostructs, cols: %i(c b a)))
22
- end
23
-
24
- def test_csv_stdout
25
- assert_output(ROWS_EXP) { Scripto.csv_to_stdout(ROWS) }
26
- end
27
-
28
- def test_csv_read_write
29
- Scripto.csv_write(FILE, ROWS)
30
- assert_equal(ROWS_EXP, File.read(FILE))
31
- assert_equal(ROWS, Scripto.csv_read(FILE).map(&:to_h))
32
- end
33
-
34
- def test_gz
35
- Scripto.csv_write(FILE, ROWS)
36
- Scripto.run("gzip #{FILE}")
37
- assert_equal(ROWS, Scripto.csv_read("#{FILE}.gz").map(&:to_h))
38
- end
39
-
40
- def test_atomic
41
- magic = "can't touch this"
42
- File.write(FILE, magic)
43
- begin
44
- Util.csv_write(TMP, rows, cols: %i(bad_column))
45
- rescue
46
- end
47
- assert_equal(magic, File.read(FILE))
48
- end
49
-
50
- protected
51
-
52
- def structs
53
- klass = Struct.new(*ROWS.first.keys)
54
- ROWS.map { |i| klass.new(*i.values) }
55
- end
56
-
57
- def ostructs
58
- ROWS.map { |i| OpenStruct.new(i) }
59
- end
60
- end