coque 0.7.1 → 0.8.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.
- checksums.yaml +5 -5
- data/Gemfile.lock +5 -5
- data/README.md +45 -0
- data/coque.gemspec +1 -1
- data/lib/coque/result.rb +1 -1
- data/lib/coque/runnable.rb +11 -0
- data/lib/coque/version.rb +1 -1
- metadata +5 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 6f9a270751ea085a375d71bc3b7a7ccd34237f4094dce63ffbffb66005b123ff
         | 
| 4 | 
            +
              data.tar.gz: 89e0e4065a6eb61c27c1b41e2ecd1dd84470b83ba934e3421ea8ee119840d5cd
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 64b833a5a39cc7ed3a65339af2ac13c0a3f0e0461247cd899c69deab5a9a7d30ffccb7bae4da16a7fed175638a59a19aaa43c2335aba109a5105b7b27e0f5682
         | 
| 7 | 
            +
              data.tar.gz: 853b5a31c91d099dc88e0881672c4fa8b465bca04ae70d553dcac9daed4c21f29501a4818fb4b04a42d8bc6e1ab021c32ae5e4a411dc3d5e3a1f1a7e44dc5aa8
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                coque (0. | 
| 4 | 
            +
                coque (0.8.0)
         | 
| 5 5 |  | 
| 6 6 | 
             
            GEM
         | 
| 7 7 | 
             
              remote: https://rubygems.org/
         | 
| @@ -10,7 +10,7 @@ GEM | |
| 10 10 | 
             
                builder (3.2.3)
         | 
| 11 11 | 
             
                coderay (1.1.2)
         | 
| 12 12 | 
             
                docile (1.3.1)
         | 
| 13 | 
            -
                json (2.1 | 
| 13 | 
            +
                json (2.3.1)
         | 
| 14 14 | 
             
                method_source (0.9.0)
         | 
| 15 15 | 
             
                minitest (5.11.3)
         | 
| 16 16 | 
             
                minitest-reporters (1.2.0)
         | 
| @@ -21,7 +21,7 @@ GEM | |
| 21 21 | 
             
                pry (0.11.2)
         | 
| 22 22 | 
             
                  coderay (~> 1.1.0)
         | 
| 23 23 | 
             
                  method_source (~> 0.9.0)
         | 
| 24 | 
            -
                rake ( | 
| 24 | 
            +
                rake (13.0.1)
         | 
| 25 25 | 
             
                ruby-progressbar (1.9.0)
         | 
| 26 26 | 
             
                simplecov (0.16.1)
         | 
| 27 27 | 
             
                  docile (~> 1.1)
         | 
| @@ -38,8 +38,8 @@ DEPENDENCIES | |
| 38 38 | 
             
              minitest (~> 5.11)
         | 
| 39 39 | 
             
              minitest-reporters
         | 
| 40 40 | 
             
              pry
         | 
| 41 | 
            -
              rake (~>  | 
| 41 | 
            +
              rake (~> 13.0)
         | 
| 42 42 | 
             
              simplecov
         | 
| 43 43 |  | 
| 44 44 | 
             
            BUNDLED WITH
         | 
| 45 | 
            -
               2. | 
| 45 | 
            +
               2.2.24
         | 
    
        data/README.md
    CHANGED
    
    | @@ -102,6 +102,51 @@ Coque also includes a `Coque.source` helper for feeding Ruby enumerables into sh | |
| 102 102 | 
             
            # => ["500"]
         | 
| 103 103 | 
             
            ```
         | 
| 104 104 |  | 
| 105 | 
            +
            #### Asynchrony and Waiting on Processes
         | 
| 106 | 
            +
             | 
| 107 | 
            +
            Running a Coque command forks a new process, and by default these processes run asynchronously. Calling `.run` on a Coque command or pipeline returns a `Coque::Result` object which can be used to get the output (`.to_a`) or exit code (`.exit_code`) of the process:
         | 
| 108 | 
            +
             | 
| 109 | 
            +
            ```rb
         | 
| 110 | 
            +
            result = Coque['echo', 'hi'].run
         | 
| 111 | 
            +
            # => #<Coque::Result:0x000055da63437838 @out=#<IO:fd 15>, @pid=29236>
         | 
| 112 | 
            +
            puts "its running in the background..."
         | 
| 113 | 
            +
            its running in the background...
         | 
| 114 | 
            +
            result.to_a
         | 
| 115 | 
            +
            # => ["hi"]
         | 
| 116 | 
            +
            result.exit_code
         | 
| 117 | 
            +
            # => 0
         | 
| 118 | 
            +
            ```
         | 
| 119 | 
            +
             | 
| 120 | 
            +
            However you can also just use `.wait` to block on a process while it runs:
         | 
| 121 | 
            +
             | 
| 122 | 
            +
            ```rb
         | 
| 123 | 
            +
            result = Coque['echo', 'hi'].run.wait
         | 
| 124 | 
            +
            # => #<Coque::Result:0x000055da633c98b0 @exit_code=0, @out=#<IO:fd 17>, @pid=29536>
         | 
| 125 | 
            +
            ```
         | 
| 126 | 
            +
             | 
| 127 | 
            +
            Or, use `.run!` to block on the process _and_ raise an exception if it exits with a non-zero response:
         | 
| 128 | 
            +
             | 
| 129 | 
            +
            ```
         | 
| 130 | 
            +
            Coque["head", "/usr/share/dict/words"].run!
         | 
| 131 | 
            +
            # => nil
         | 
| 132 | 
            +
            Coque["head", "/usr/share/dict/pizza"].run!
         | 
| 133 | 
            +
            # head: cannot open '/usr/share/dict/pizza' for reading: No such file or directory
         | 
| 134 | 
            +
            # RuntimeError: Coque Command Failed: <Coque::Sh head /usr/share/dict/pizza>
         | 
| 135 | 
            +
            from /home/horace/.gem/ruby/2.4.4/gems/coque-0.7.1/lib/coque/runnable.rb:13:in `run!'
         | 
| 136 | 
            +
            ```
         | 
| 137 | 
            +
             | 
| 138 | 
            +
            There's also a `to_a!` variant on commands which combines the error handling of `run!` with the array-slurping of stdout:
         | 
| 139 | 
            +
             | 
| 140 | 
            +
            ```
         | 
| 141 | 
            +
            Coque['head', '-n 1', '/usr/share/dict/words'].to_a!
         | 
| 142 | 
            +
            => ["A"]
         | 
| 143 | 
            +
             | 
| 144 | 
            +
            Coque['head', '-n 1', '/usr/share/dict/asdf'].to_a!
         | 
| 145 | 
            +
            head: cannot open '/usr/share/dict/asdf' for reading: No such file or directory
         | 
| 146 | 
            +
            RuntimeError: Coque Command Failed: <Coque::Sh head -n 1 /usr/share/dict/asdf>
         | 
| 147 | 
            +
            from /code/coque/lib/coque/runnable.rb:11:in `to_a!'
         | 
| 148 | 
            +
            ```
         | 
| 149 | 
            +
             | 
| 105 150 | 
             
            #### Named (Non-Operator) Method Alternatives
         | 
| 106 151 |  | 
| 107 152 | 
             
            The main piping and redirection methods also include named alternatives:
         | 
    
        data/coque.gemspec
    CHANGED
    
    | @@ -31,7 +31,7 @@ Gem::Specification.new do |spec| | |
| 31 31 | 
             
              spec.require_paths = ["lib"]
         | 
| 32 32 |  | 
| 33 33 | 
             
              spec.add_development_dependency "bundler", "~> 2.0"
         | 
| 34 | 
            -
              spec.add_development_dependency "rake", "~>  | 
| 34 | 
            +
              spec.add_development_dependency "rake", "~> 13.0"
         | 
| 35 35 | 
             
              spec.add_development_dependency "minitest", "~> 5.11"
         | 
| 36 36 | 
             
              spec.add_development_dependency "minitest-reporters"
         | 
| 37 37 | 
             
              spec.add_development_dependency "pry"
         | 
    
        data/lib/coque/result.rb
    CHANGED
    
    
    
        data/lib/coque/runnable.rb
    CHANGED
    
    | @@ -4,6 +4,15 @@ module Coque | |
| 4 4 | 
             
                  run.to_a
         | 
| 5 5 | 
             
                end
         | 
| 6 6 |  | 
| 7 | 
            +
                def to_a!
         | 
| 8 | 
            +
                  res = run
         | 
| 9 | 
            +
                  rows = res.to_a
         | 
| 10 | 
            +
                  unless res.exit_code == 0
         | 
| 11 | 
            +
                    raise "Coque Command Failed: #{self}"
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                  rows
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 7 16 | 
             
                def success?
         | 
| 8 17 | 
             
                  run.success?
         | 
| 9 18 | 
             
                end
         | 
| @@ -11,6 +20,8 @@ module Coque | |
| 11 20 | 
             
                def run!
         | 
| 12 21 | 
             
                  if !success?
         | 
| 13 22 | 
             
                    raise "Coque Command Failed: #{self}"
         | 
| 23 | 
            +
                  else
         | 
| 24 | 
            +
                    self
         | 
| 14 25 | 
             
                  end
         | 
| 15 26 | 
             
                end
         | 
| 16 27 |  | 
    
        data/lib/coque/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: coque
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.8.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Horace Williams
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2021-08-22 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -30,14 +30,14 @@ dependencies: | |
| 30 30 | 
             
                requirements:
         | 
| 31 31 | 
             
                - - "~>"
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: ' | 
| 33 | 
            +
                    version: '13.0'
         | 
| 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: ' | 
| 40 | 
            +
                    version: '13.0'
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 42 | 
             
              name: minitest
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -144,8 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 144 144 | 
             
                - !ruby/object:Gem::Version
         | 
| 145 145 | 
             
                  version: '0'
         | 
| 146 146 | 
             
            requirements: []
         | 
| 147 | 
            -
             | 
| 148 | 
            -
            rubygems_version: 2.6.14.1
         | 
| 147 | 
            +
            rubygems_version: 3.2.21
         | 
| 149 148 | 
             
            signing_key: 
         | 
| 150 149 | 
             
            specification_version: 4
         | 
| 151 150 | 
             
            summary: Shell command utilities with easy integration with Ruby code.
         |