scripto 0.0.3 → 0.0.4

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.
@@ -1,4 +1,4 @@
1
- require_relative "helper"
1
+ require_relative 'helper'
2
2
 
3
3
  class TestMisc < Minitest::Test
4
4
  include Helper
@@ -8,39 +8,39 @@ class TestMisc < Minitest::Test
8
8
  end
9
9
 
10
10
  def test_root?
11
- assert_equal(`whoami`.strip == "root", Scripto.root?)
11
+ assert_equal(`whoami`.strip == 'root', Scripto.root?)
12
12
  end
13
13
 
14
14
  def test_md5_string
15
- assert_equal("ba73632f801ac2c72d78134722f2cb84", Scripto.md5_string("gub"))
15
+ assert_equal('ba73632f801ac2c72d78134722f2cb84', Scripto.md5_string('gub'))
16
16
  end
17
17
 
18
18
  def test_md5_file
19
- File.write("test.txt", "gub")
20
- assert_equal("ba73632f801ac2c72d78134722f2cb84", Scripto.md5_file("test.txt"))
19
+ File.write('test.txt', 'gub')
20
+ assert_equal('ba73632f801ac2c72d78134722f2cb84', Scripto.md5_file('test.txt'))
21
21
  end
22
22
 
23
23
  def test_prompt?
24
- with_fake_stdin("YES") do
25
- assert_output(nil, "question (y/n) ") do
26
- assert Scripto.prompt?("question")
24
+ with_fake_stdin('YES') do
25
+ assert_output(nil, 'question (y/n) ') do
26
+ assert Scripto.prompt?('question')
27
27
  end
28
28
  end
29
- with_fake_stdin("y") do
30
- assert_output(nil, "question (y/n) ") do
31
- assert Scripto.prompt?("question")
29
+ with_fake_stdin('y') do
30
+ assert_output(nil, 'question (y/n) ') do
31
+ assert Scripto.prompt?('question')
32
32
  end
33
33
  end
34
- with_fake_stdin("no") do
35
- assert_output(nil, "question (y/n) ") do
36
- assert !Scripto.prompt?("question")
34
+ with_fake_stdin('no') do
35
+ assert_output(nil, 'question (y/n) ') do
36
+ assert !Scripto.prompt?('question')
37
37
  end
38
38
  end
39
39
  end
40
40
 
41
41
  protected
42
42
 
43
- def with_fake_stdin(str, &block)
43
+ def with_fake_stdin(str)
44
44
  old_stdin = $stdin
45
45
  begin
46
46
  $stdin = StringIO.new(str)
@@ -50,4 +50,4 @@ class TestMisc < Minitest::Test
50
50
  $stdin = old_stdin
51
51
  end
52
52
  end
53
- end
53
+ end
@@ -1,4 +1,4 @@
1
- require_relative "helper"
1
+ require_relative 'helper'
2
2
 
3
3
  class TestPrint < Minitest::Test
4
4
  include Helper
@@ -10,19 +10,19 @@ class TestPrint < Minitest::Test
10
10
  end
11
11
 
12
12
  def test_quiet
13
- assert_silent { Scripto.vbanner "gub" }
14
- assert_silent { Scripto.vprintf("gub %d", 123) }
15
- assert_silent { Scripto.vputs "gub" }
13
+ assert_silent { Scripto.vbanner 'gub' }
14
+ assert_silent { Scripto.vprintf('gub %d', 123) }
15
+ assert_silent { Scripto.vputs 'gub' }
16
16
  end
17
17
 
18
18
  def test_loud
19
19
  Scripto.verbose!
20
- assert_output(nil, /gub/) { Scripto.vbanner "gub" }
21
- assert_output(nil, /gub/) { Scripto.vprintf("zub %s", "gub") }
22
- assert_output(nil, /gub/) { Scripto.vputs "gub" }
20
+ assert_output(nil, /gub/) { Scripto.vbanner 'gub' }
21
+ assert_output(nil, /gub/) { Scripto.vprintf('zub %s', 'gub') }
22
+ assert_output(nil, /gub/) { Scripto.vputs 'gub' }
23
23
  end
24
24
 
25
25
  def test_warning
26
- assert_output(nil, /gub/) { Scripto.warning "gub" }
26
+ assert_output(nil, /gub/) { Scripto.warning 'gub' }
27
27
  end
28
- end
28
+ end
@@ -1,18 +1,18 @@
1
- require_relative "helper"
1
+ require_relative 'helper'
2
2
 
3
3
  class TestRun < Minitest::Test
4
4
  include Helper
5
5
 
6
- SUCCEEDS = "echo gub"
7
- FAILS = "cat scripto_bogus_file 2> /dev/null"
8
- BAD_COMMAND = "this_command_doesnt_exist"
9
- SRC = "_scripto_src"
10
- DST = "_scripto with spaces"
11
- ARGS = [ "-f", SRC, DST ]
6
+ SUCCEEDS = 'echo gub'.freeze
7
+ FAILS = 'cat scripto_bogus_file 2> /dev/null'.freeze
8
+ BAD_COMMAND = 'this_command_doesnt_exist'.freeze
9
+ SRC = '_scripto_src'.freeze
10
+ DST = '_scripto with spaces'.freeze
11
+ ARGS = [ '-f', SRC, DST ].freeze
12
12
 
13
13
  def setup
14
14
  super
15
- File.write(SRC, "something")
15
+ File.write(SRC, 'something')
16
16
  end
17
17
 
18
18
  #
@@ -21,8 +21,8 @@ class TestRun < Minitest::Test
21
21
 
22
22
  def test_run
23
23
  Scripto.run("#{SUCCEEDS} > #{SRC}")
24
- assert_equal("gub", File.read(SRC).strip)
25
- assert("gub", Scripto.run_capture(SUCCEEDS))
24
+ assert_equal('gub', File.read(SRC).strip)
25
+ assert('gub', Scripto.run_capture(SUCCEEDS))
26
26
  Scripto.run_quietly(SUCCEEDS)
27
27
  end
28
28
 
@@ -33,8 +33,8 @@ class TestRun < Minitest::Test
33
33
  end
34
34
 
35
35
  def test_shellescape
36
- assert_equal("gub", Scripto.shellescape("gub"))
37
- assert_equal("gub\\ zub", Scripto.shellescape("gub zub"))
36
+ assert_equal('gub', Scripto.shellescape('gub'))
37
+ assert_equal('gub\\ zub', Scripto.shellescape('gub zub'))
38
38
  end
39
39
 
40
40
  # verbosity
@@ -60,14 +60,14 @@ class TestRun < Minitest::Test
60
60
 
61
61
  def test_run_args
62
62
  # make sure SRC is copied to DST in all cases
63
- assert_cp { Scripto.run("cp", ARGS) }
64
- assert_cp { Scripto.run_quietly("cp", ARGS) }
65
- assert_cp { assert_succeeds("cp", ARGS) }
63
+ assert_cp { Scripto.run('cp', ARGS) }
64
+ assert_cp { Scripto.run_quietly('cp', ARGS) }
65
+ assert_cp { assert_succeeds('cp', ARGS) }
66
66
  end
67
67
 
68
68
  def test_capture_escaping
69
69
  tricky = "\"'!tricky!'\""
70
- assert_equal("#{tricky} #{tricky}\n", Scripto.run_capture("echo", [tricky, tricky]))
70
+ assert_equal("#{tricky} #{tricky}\n", Scripto.run_capture('echo', [ tricky, tricky ]))
71
71
  end
72
72
 
73
73
  def test_args_succeeds_fails
@@ -77,14 +77,14 @@ class TestRun < Minitest::Test
77
77
  # is output escaped properly with verbose?
78
78
  def test_args_verbose
79
79
  Scripto.verbose!
80
- assert_output(nil, "cp -f #{SRC} #{DST.gsub(" ", "\\ ")}\n") do
81
- Scripto.run("cp", ARGS)
80
+ assert_output(nil, "cp -f #{SRC} #{DST.gsub(' ', '\\ ')}\n") do
81
+ Scripto.run('cp', ARGS)
82
82
  end
83
83
  end
84
84
 
85
85
  protected
86
86
 
87
- def assert_cp(&block)
87
+ def assert_cp
88
88
  File.unlink(DST) if File.exist?(DST)
89
89
  yield
90
90
  assert_equal(File.read(SRC), File.read(DST))
@@ -100,4 +100,4 @@ class TestRun < Minitest::Test
100
100
  assert_equal(false, Scripto.run_succeeds?(command, args))
101
101
  assert_equal(true, Scripto.run_fails?(command, args))
102
102
  end
103
- end
103
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scripto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Doppelt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-28 00:00:00.000000000 Z
11
+ date: 2020-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
19
+ version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.5'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.0'
33
+ version: '5.14'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '5.0'
40
+ version: '5.14'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +52,21 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description:
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
56
70
  email:
57
71
  - amd@gurge.com
58
72
  executables: []
@@ -81,12 +95,11 @@ files:
81
95
  - test/test_misc.rb
82
96
  - test/test_print.rb
83
97
  - test/test_run.rb
84
- - vagrant_provision
85
98
  homepage: http://github.com/gurgeous/scripto
86
99
  licenses:
87
100
  - MIT
88
101
  metadata: {}
89
- post_install_message:
102
+ post_install_message:
90
103
  rdoc_options: []
91
104
  require_paths:
92
105
  - lib
@@ -101,9 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
114
  - !ruby/object:Gem::Version
102
115
  version: '0'
103
116
  requirements: []
104
- rubyforge_project:
105
- rubygems_version: 2.2.2
106
- signing_key:
117
+ rubygems_version: 3.1.2
118
+ signing_key:
107
119
  specification_version: 4
108
120
  summary: Helpers for writing command line scripts. An extraction from Dwellable.
109
121
  test_files:
@@ -1,50 +0,0 @@
1
- #!/bin/bash
2
-
3
- # bail on errors
4
- set -eu
5
-
6
- function banner() {
7
- printf '\e[1;37;43m[%s] %-72s\e[0m\n' `date '+%H:%M:%S'` "vagrant_provision: $1"
8
- }
9
-
10
- # packages needed for building ruby
11
- banner "Packages..."
12
- sudo apt-get -y install git-core
13
- sudo apt-get -y install build-essential checkinstall libffi-dev libreadline-gplv2-dev libncurses5-dev libssl-dev libyaml-dev zlib1g-dev
14
-
15
- # rbenv
16
- banner "Rbenv..."
17
- if [ ! -d ~/.rbenv ] ; then
18
- git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
19
- fi
20
- if [ ! -d ~/.rbenv/plugins/ruby-build ] ; then
21
- git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
22
- fi
23
-
24
- # add rbenv to .bashrc
25
- if ! grep -q 'vagrant provisioning' ~/.bashrc ; then
26
- cat >> ~/.bashrc <<"EOF"
27
- # added by vagrant provisioning
28
- export PATH="$HOME/.rbenv/bin:$PATH"
29
- eval "$(rbenv init -)"
30
- EOF
31
-
32
- # make sure we pickup rbenv too!
33
- export PATH="$HOME/.rbenv/bin:$PATH"
34
- eval "$(rbenv init -)"
35
- fi
36
-
37
- # no rdoc, please
38
- echo 'gem: --no-ri --no-rdoc' > ~/.gemrc
39
-
40
- # now install ruby
41
- banner "Ruby..."
42
- rbenv install 2.0.0-p353
43
- rbenv global 2.0.0-p353
44
- ruby -v
45
-
46
- # and gems
47
- banner "Gems..."
48
- gem update --system
49
- gem install bundler
50
- rbenv rehash