ruby-plsql 0.6.0 → 0.7.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/.codeclimate.yml +30 -0
- data/.github/stale.yml +37 -0
- data/.rubocop.yml +153 -0
- data/.travis.yml +20 -6
- data/.travis/oracle/download.sh +9 -10
- data/.travis/oracle/install.sh +6 -6
- data/Gemfile +13 -9
- data/History.txt +26 -0
- data/README.md +9 -5
- data/Rakefile +31 -26
- data/VERSION +1 -1
- data/Vagrantfile +2 -2
- data/gemfiles/Gemfile.activerecord-5.0 +21 -0
- data/gemfiles/Gemfile.activerecord-5.1 +21 -0
- data/gemfiles/Gemfile.activerecord-5.2 +21 -0
- data/lib/plsql/connection.rb +16 -18
- data/lib/plsql/helpers.rb +1 -3
- data/lib/plsql/jdbc_connection.rb +66 -61
- data/lib/plsql/oci8_patches.rb +2 -2
- data/lib/plsql/oci_connection.rb +51 -69
- data/lib/plsql/package.rb +5 -8
- data/lib/plsql/procedure.rb +75 -78
- data/lib/plsql/procedure_call.rb +498 -501
- data/lib/plsql/schema.rb +95 -100
- data/lib/plsql/sequence.rb +10 -13
- data/lib/plsql/sql_statements.rb +9 -11
- data/lib/plsql/table.rb +59 -63
- data/lib/plsql/type.rb +71 -76
- data/lib/plsql/variable.rb +89 -94
- data/lib/plsql/version.rb +1 -1
- data/lib/plsql/view.rb +16 -19
- data/ruby-plsql.gemspec +41 -37
- data/spec/plsql/connection_spec.rb +67 -67
- data/spec/plsql/package_spec.rb +15 -15
- data/spec/plsql/procedure_spec.rb +286 -233
- data/spec/plsql/schema_spec.rb +22 -23
- data/spec/plsql/sequence_spec.rb +2 -2
- data/spec/plsql/sql_statements_spec.rb +5 -5
- data/spec/plsql/table_spec.rb +77 -77
- data/spec/plsql/type_spec.rb +23 -29
- data/spec/plsql/variable_spec.rb +59 -59
- data/spec/plsql/version_spec.rb +4 -4
- data/spec/plsql/view_spec.rb +42 -42
- data/spec/spec_helper.rb +37 -29
- data/spec/support/test_db.rb +12 -13
- metadata +44 -26
- data/.travis/oracle/LICENSE +0 -5
- data/.travis/oracle/README.md +0 -64
- data/.travis/oracle/download.js +0 -100
    
        data/spec/support/test_db.rb
    CHANGED
    
    | @@ -1,5 +1,4 @@ | |
| 1 1 | 
             
            class TestDb
         | 
| 2 | 
            -
             | 
| 3 2 | 
             
              DATABASE_USERS = %w{hr arunit}
         | 
| 4 3 |  | 
| 5 4 | 
             
              def self.build
         | 
| @@ -11,8 +10,8 @@ class TestDb | |
| 11 10 | 
             
              end
         | 
| 12 11 |  | 
| 13 12 | 
             
              def self.database_version
         | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 13 | 
            +
                db = self.new
         | 
| 14 | 
            +
                db.database_version
         | 
| 16 15 | 
             
              end
         | 
| 17 16 |  | 
| 18 17 | 
             
              def connection
         | 
| @@ -21,15 +20,15 @@ class TestDb | |
| 21 20 | 
             
                    Timeout::timeout(5) {
         | 
| 22 21 | 
             
                      if defined?(JRUBY_VERSION)
         | 
| 23 22 | 
             
                        @connection = java.sql.DriverManager.get_connection(
         | 
| 24 | 
            -
                           | 
| 25 | 
            -
                           | 
| 26 | 
            -
                           | 
| 27 | 
            -
                        ) | 
| 23 | 
            +
                          "jdbc:oracle:thin:@127.0.0.1:1521/XE",
         | 
| 24 | 
            +
                          "system",
         | 
| 25 | 
            +
                          "oracle"
         | 
| 26 | 
            +
                        )
         | 
| 28 27 | 
             
                      else
         | 
| 29 28 | 
             
                        @connection = OCI8.new(
         | 
| 30 | 
            -
                           | 
| 31 | 
            -
                           | 
| 32 | 
            -
                           | 
| 29 | 
            +
                          "system",
         | 
| 30 | 
            +
                          "oracle",
         | 
| 31 | 
            +
                          "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE)))"
         | 
| 33 32 | 
             
                        )
         | 
| 34 33 | 
             
                      end
         | 
| 35 34 | 
             
                    }
         | 
| @@ -61,7 +60,7 @@ class TestDb | |
| 61 60 | 
             
              end
         | 
| 62 61 |  | 
| 63 62 | 
             
              def database_users
         | 
| 64 | 
            -
                DATABASE_USERS.inject([]){|array, user| array << [user.upcase, user]}
         | 
| 63 | 
            +
                DATABASE_USERS.inject([]) { |array, user| array << [user.upcase, user] }
         | 
| 65 64 | 
             
              end
         | 
| 66 65 |  | 
| 67 66 | 
             
              def cleanup_database_users
         | 
| @@ -118,14 +117,14 @@ class TestDb | |
| 118 117 | 
             
              end
         | 
| 119 118 |  | 
| 120 119 | 
             
              def database_version
         | 
| 121 | 
            -
                query =  | 
| 120 | 
            +
                query = "SELECT version FROM V$INSTANCE"
         | 
| 122 121 |  | 
| 123 122 | 
             
                if defined?(JRUBY_VERSION)
         | 
| 124 123 | 
             
                  statement = connection.create_statement
         | 
| 125 124 | 
             
                  resource  = statement.execute_query(query)
         | 
| 126 125 |  | 
| 127 126 | 
             
                  resource.next
         | 
| 128 | 
            -
                  value = resource.get_string( | 
| 127 | 
            +
                  value = resource.get_string("VERSION")
         | 
| 129 128 |  | 
| 130 129 | 
             
                  resource.close
         | 
| 131 130 | 
             
                  statement.close
         | 
    
        metadata
    CHANGED
    
    | @@ -1,64 +1,78 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: ruby-plsql
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.7.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Raimonds Simanovskis
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2018-09-03 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            -
              name:  | 
| 14 | 
            +
              name: juwelier
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: 2.0 | 
| 19 | 
            +
                    version: '2.0'
         | 
| 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: 2.0 | 
| 26 | 
            +
                    version: '2.0'
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            -
              name:  | 
| 28 | 
            +
              name: rspec_junit_formatter
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 30 | 
             
                requirements:
         | 
| 31 | 
            -
                - - " | 
| 31 | 
            +
                - - ">="
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: ' | 
| 33 | 
            +
                    version: '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: '0'
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            -
              name:  | 
| 42 | 
            +
              name: rake
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 44 | 
             
                requirements:
         | 
| 45 45 | 
             
                - - ">="
         | 
| 46 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            -
                    version: '0'
         | 
| 47 | 
            +
                    version: '10.0'
         | 
| 48 48 | 
             
              type: :development
         | 
| 49 49 | 
             
              prerelease: false
         | 
| 50 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 51 | 
             
                requirements:
         | 
| 52 52 | 
             
                - - ">="
         | 
| 53 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version: '0'
         | 
| 54 | 
            +
                    version: '10.0'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: rspec
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '3.1'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '3.1'
         | 
| 55 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 70 | 
             
              name: activerecord
         | 
| 57 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 72 | 
             
                requirements:
         | 
| 59 73 | 
             
                - - "<"
         | 
| 60 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version:  | 
| 75 | 
            +
                    version: 5.2.0
         | 
| 62 76 | 
             
                - - ">="
         | 
| 63 77 | 
             
                  - !ruby/object:Gem::Version
         | 
| 64 78 | 
             
                    version: 3.2.3
         | 
| @@ -68,7 +82,7 @@ dependencies: | |
| 68 82 | 
             
                requirements:
         | 
| 69 83 | 
             
                - - "<"
         | 
| 70 84 | 
             
                  - !ruby/object:Gem::Version
         | 
| 71 | 
            -
                    version:  | 
| 85 | 
            +
                    version: 5.2.0
         | 
| 72 86 | 
             
                - - ">="
         | 
| 73 87 | 
             
                  - !ruby/object:Gem::Version
         | 
| 74 88 | 
             
                    version: 3.2.3
         | 
| @@ -78,7 +92,7 @@ dependencies: | |
| 78 92 | 
             
                requirements:
         | 
| 79 93 | 
             
                - - "<"
         | 
| 80 94 | 
             
                  - !ruby/object:Gem::Version
         | 
| 81 | 
            -
                    version: 1. | 
| 95 | 
            +
                    version: 1.9.0
         | 
| 82 96 | 
             
                - - ">="
         | 
| 83 97 | 
             
                  - !ruby/object:Gem::Version
         | 
| 84 98 | 
             
                    version: 1.4.1
         | 
| @@ -88,7 +102,7 @@ dependencies: | |
| 88 102 | 
             
                requirements:
         | 
| 89 103 | 
             
                - - "<"
         | 
| 90 104 | 
             
                  - !ruby/object:Gem::Version
         | 
| 91 | 
            -
                    version: 1. | 
| 105 | 
            +
                    version: 1.9.0
         | 
| 92 106 | 
             
                - - ">="
         | 
| 93 107 | 
             
                  - !ruby/object:Gem::Version
         | 
| 94 108 | 
             
                    version: 1.4.1
         | 
| @@ -120,20 +134,20 @@ dependencies: | |
| 120 134 | 
             
                - - "~>"
         | 
| 121 135 | 
             
                  - !ruby/object:Gem::Version
         | 
| 122 136 | 
             
                    version: '2.1'
         | 
| 123 | 
            -
            description: |
         | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 137 | 
            +
            description: |2
         | 
| 138 | 
            +
                ruby-plsql gem provides simple Ruby API for calling Oracle PL/SQL procedures.
         | 
| 139 | 
            +
                It could be used both for accessing Oracle PL/SQL API procedures in legacy applications
         | 
| 140 | 
            +
                as well as it could be used to create PL/SQL unit tests using Ruby testing libraries.
         | 
| 127 141 | 
             
            email: raimonds.simanovskis@gmail.com
         | 
| 128 142 | 
             
            executables: []
         | 
| 129 143 | 
             
            extensions: []
         | 
| 130 144 | 
             
            extra_rdoc_files:
         | 
| 131 145 | 
             
            - README.md
         | 
| 132 146 | 
             
            files:
         | 
| 147 | 
            +
            - ".codeclimate.yml"
         | 
| 148 | 
            +
            - ".github/stale.yml"
         | 
| 149 | 
            +
            - ".rubocop.yml"
         | 
| 133 150 | 
             
            - ".travis.yml"
         | 
| 134 | 
            -
            - ".travis/oracle/LICENSE"
         | 
| 135 | 
            -
            - ".travis/oracle/README.md"
         | 
| 136 | 
            -
            - ".travis/oracle/download.js"
         | 
| 137 151 | 
             
            - ".travis/oracle/download.sh"
         | 
| 138 152 | 
             
            - ".travis/oracle/install.sh"
         | 
| 139 153 | 
             
            - ".travis/setup_accounts.sh"
         | 
| @@ -144,6 +158,9 @@ files: | |
| 144 158 | 
             
            - Rakefile
         | 
| 145 159 | 
             
            - VERSION
         | 
| 146 160 | 
             
            - Vagrantfile
         | 
| 161 | 
            +
            - gemfiles/Gemfile.activerecord-5.0
         | 
| 162 | 
            +
            - gemfiles/Gemfile.activerecord-5.1
         | 
| 163 | 
            +
            - gemfiles/Gemfile.activerecord-5.2
         | 
| 147 164 | 
             
            - lib/plsql/connection.rb
         | 
| 148 165 | 
             
            - lib/plsql/helpers.rb
         | 
| 149 166 | 
             
            - lib/plsql/jdbc_connection.rb
         | 
| @@ -182,7 +199,8 @@ files: | |
| 182 199 | 
             
            - spec/support/test_db.rb
         | 
| 183 200 | 
             
            - spec/support/unlock_and_setup_hr_user.sql
         | 
| 184 201 | 
             
            homepage: http://github.com/rsim/ruby-plsql
         | 
| 185 | 
            -
            licenses: | 
| 202 | 
            +
            licenses:
         | 
| 203 | 
            +
            - MIT
         | 
| 186 204 | 
             
            metadata: {}
         | 
| 187 205 | 
             
            post_install_message: 
         | 
| 188 206 | 
             
            rdoc_options: []
         | 
| @@ -200,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 200 218 | 
             
                  version: '0'
         | 
| 201 219 | 
             
            requirements: []
         | 
| 202 220 | 
             
            rubyforge_project: 
         | 
| 203 | 
            -
            rubygems_version: 2. | 
| 221 | 
            +
            rubygems_version: 2.7.7
         | 
| 204 222 | 
             
            signing_key: 
         | 
| 205 223 | 
             
            specification_version: 4
         | 
| 206 224 | 
             
            summary: Ruby API for calling Oracle PL/SQL procedures.
         | 
    
        data/.travis/oracle/LICENSE
    DELETED
    
    | @@ -1,5 +0,0 @@ | |
| 1 | 
            -
            Copyright (c) 2013, Christopher Bandy
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
         | 
    
        data/.travis/oracle/README.md
    DELETED
    
    | @@ -1,64 +0,0 @@ | |
| 1 | 
            -
            [](https://travis-ci.org/cbandy/travis-oracle)
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            Use [Oracle Database Express Edition][] in your builds on [Travis CI][].
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            [Oracle Database Express Edition]: http://www.oracle.com/technetwork/database/database-technologies/express-edition/overview/index.html
         | 
| 6 | 
            -
            [Travis CI]: https://travis-ci.org/
         | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
            Usage
         | 
| 10 | 
            -
            -----
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            To use this tool, you must have an Oracle account with which you have accepted
         | 
| 13 | 
            -
            the current license agreement for [Oracle Database Express Edition][].
         | 
| 14 | 
            -
             | 
| 15 | 
            -
            1. Add your Oracle username and password to your build [environment variables][],
         | 
| 16 | 
            -
               either as hidden repository settings or encrypted variables:
         | 
| 17 | 
            -
             | 
| 18 | 
            -
               | Variable Name              | Value         |
         | 
| 19 | 
            -
               | -------------------------- | ------------- |
         | 
| 20 | 
            -
               | `ORACLE_LOGIN_ssousername` | your username |
         | 
| 21 | 
            -
               | `ORACLE_LOGIN_password`    | your password |
         | 
| 22 | 
            -
             | 
| 23 | 
            -
            2. Add the version information to your build environment variables:
         | 
| 24 | 
            -
             | 
| 25 | 
            -
               ```yaml
         | 
| 26 | 
            -
               - ORACLE_COOKIE=sqldev
         | 
| 27 | 
            -
               - ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
         | 
| 28 | 
            -
               - ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
         | 
| 29 | 
            -
               - ORACLE_SID=XE
         | 
| 30 | 
            -
               ```
         | 
| 31 | 
            -
             | 
| 32 | 
            -
            3. Download and extract the [latest release][] into your project. For example,
         | 
| 33 | 
            -
             | 
| 34 | 
            -
               ```shell
         | 
| 35 | 
            -
               wget 'https://github.com/cbandy/travis-oracle/archive/v2.0.0.tar.gz'
         | 
| 36 | 
            -
               mkdir -p .travis/oracle
         | 
| 37 | 
            -
               tar xz --strip-components 1 -C .travis/oracle -f v2.0.0.tar.gz
         | 
| 38 | 
            -
               ```
         | 
| 39 | 
            -
             | 
| 40 | 
            -
            4. Enable [`sudo`](https://docs.travis-ci.com/user/workers/standard-infrastructure/):
         | 
| 41 | 
            -
             | 
| 42 | 
            -
               ```yaml
         | 
| 43 | 
            -
               sudo: required
         | 
| 44 | 
            -
               ```
         | 
| 45 | 
            -
             | 
| 46 | 
            -
            5. Finally, execute the extracted scripts as part of your build, usually
         | 
| 47 | 
            -
               during [`before_install`](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle):
         | 
| 48 | 
            -
             | 
| 49 | 
            -
               ```yaml
         | 
| 50 | 
            -
               - .travis/oracle/download.sh
         | 
| 51 | 
            -
               - .travis/oracle/install.sh
         | 
| 52 | 
            -
               ```
         | 
| 53 | 
            -
             | 
| 54 | 
            -
            [SQL\*Plus][] is installed to `$ORACLE_HOME/bin/sqlplus`, and the current user
         | 
| 55 | 
            -
            has both normal and DBA access without a password, i.e. `/` and `/ AS SYSDBA`.
         | 
| 56 | 
            -
             | 
| 57 | 
            -
            [OCI][] and [OCCI][] libraries and header files are in `$ORACLE_HOME/lib` and
         | 
| 58 | 
            -
            `$ORACLE_HOME/rdbms/public`, respectively.
         | 
| 59 | 
            -
             | 
| 60 | 
            -
            [environment variables]: https://docs.travis-ci.com/user/environment-variables/
         | 
| 61 | 
            -
            [latest release]: https://github.com/cbandy/travis-oracle/releases/latest
         | 
| 62 | 
            -
            [OCCI]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=LNCPP
         | 
| 63 | 
            -
            [OCI]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=LNOCI
         | 
| 64 | 
            -
            [SQL\*Plus]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=SQPUG
         | 
    
        data/.travis/oracle/download.js
    DELETED
    
    | @@ -1,100 +0,0 @@ | |
| 1 | 
            -
            // vim: set et sw=2 ts=2:
         | 
| 2 | 
            -
            "use strict";
         | 
| 3 | 
            -
            var env = process.env;
         | 
| 4 | 
            -
            var Promise = require('bluebird');
         | 
| 5 | 
            -
            var Phantom = Promise.promisifyAll(require('node-phantom-simple'));
         | 
| 6 | 
            -
            var PhantomError = require('node-phantom-simple/headless_error');
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            Phantom.createAsync({ parameters: { 'ssl-protocol': 'tlsv1' } }).then(function (browser) {
         | 
| 9 | 
            -
              browser = Promise.promisifyAll(browser, { suffix: 'Promise' });
         | 
| 10 | 
            -
             | 
| 11 | 
            -
              // Configure the browser, open a tab
         | 
| 12 | 
            -
              return browser
         | 
| 13 | 
            -
              .addCookiePromise({'name': 'oraclelicense', 'value': "accept-" + env['ORACLE_COOKIE'] + "-cookie", 'domain': '.oracle.com' })
         | 
| 14 | 
            -
              .then(function () {
         | 
| 15 | 
            -
                return browser.createPagePromise();
         | 
| 16 | 
            -
              })
         | 
| 17 | 
            -
              .then(function (page) {
         | 
| 18 | 
            -
                page = Promise.promisifyAll(page, { suffix: 'Promise' });
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                // Configure the tab
         | 
| 21 | 
            -
                page.onResourceError = console.error.bind(console);
         | 
| 22 | 
            -
                return page
         | 
| 23 | 
            -
                .setPromise('settings.userAgent', env['USER_AGENT']) // PhantomJS configures the UA per tab
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                // Request the file, wait for the login page
         | 
| 26 | 
            -
                .then(function () {
         | 
| 27 | 
            -
                  return page.openPromise("https://edelivery.oracle.com/akam/otn/linux/" + env['ORACLE_FILE']).then(function (status) {
         | 
| 28 | 
            -
                    if (status != 'success') throw "Unable to connect to oracle.com";
         | 
| 29 | 
            -
                    return page.waitForSelectorPromise('input[type=password]', 5000);
         | 
| 30 | 
            -
                  })
         | 
| 31 | 
            -
                  .catch(PhantomError, function (err) {
         | 
| 32 | 
            -
                    return page.getPromise('plainText').then(function (text) {
         | 
| 33 | 
            -
                      console.error("Unable to load login page. Last response was:\n" + text);
         | 
| 34 | 
            -
                      throw err;
         | 
| 35 | 
            -
                    });
         | 
| 36 | 
            -
                  });
         | 
| 37 | 
            -
                })
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                // Export cookies for cURL
         | 
| 40 | 
            -
                .then(function () {
         | 
| 41 | 
            -
                  return page.getPromise('cookies').then(function (cookies) {
         | 
| 42 | 
            -
                    var data = "";
         | 
| 43 | 
            -
                    for (var i = 0; i < cookies.length; ++i) {
         | 
| 44 | 
            -
                      var cookie = cookies[i];
         | 
| 45 | 
            -
                      data += cookie.domain + "\tTRUE\t" + cookie.path + "\t"
         | 
| 46 | 
            -
                        + (cookie.secure ? "TRUE" : "FALSE") + "\t0\t"
         | 
| 47 | 
            -
                        + cookie.name + "\t" + cookie.value + "\n";
         | 
| 48 | 
            -
                    }
         | 
| 49 | 
            -
                    return Promise.promisifyAll(require('fs')).writeFileAsync(env['COOKIES'], data);
         | 
| 50 | 
            -
                  });
         | 
| 51 | 
            -
                })
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                // Submit the login form using cURL
         | 
| 54 | 
            -
                .then(function () {
         | 
| 55 | 
            -
                  return page.evaluatePromise(function () {
         | 
| 56 | 
            -
                    var $form = jQuery(document.forms[0]);
         | 
| 57 | 
            -
                    return {
         | 
| 58 | 
            -
                      action: $form.prop('action'),
         | 
| 59 | 
            -
                      data: $form.serialize()
         | 
| 60 | 
            -
                    };
         | 
| 61 | 
            -
                  })
         | 
| 62 | 
            -
                  .then(function (form) {
         | 
| 63 | 
            -
                    return browser.exitPromise().then(function () {
         | 
| 64 | 
            -
                      for (var key in env) {
         | 
| 65 | 
            -
                        if (key.indexOf('ORACLE_LOGIN_') == 0 && env.hasOwnProperty(key)) {
         | 
| 66 | 
            -
                          var name = key.substr(13) + '=';
         | 
| 67 | 
            -
                          form.data = form.data.replace(name, name + env[key]);
         | 
| 68 | 
            -
                        }
         | 
| 69 | 
            -
                      }
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                      var cmd = ['curl', [
         | 
| 72 | 
            -
                        '--cookie', env['COOKIES'],
         | 
| 73 | 
            -
                        '--cookie-jar', env['COOKIES'],
         | 
| 74 | 
            -
                        '--data', '@-',
         | 
| 75 | 
            -
                        '--location',
         | 
| 76 | 
            -
                        '--output', require('path').basename(env['ORACLE_FILE']),
         | 
| 77 | 
            -
                        '--user-agent', env['USER_AGENT'],
         | 
| 78 | 
            -
                        form.action
         | 
| 79 | 
            -
                      ]];
         | 
| 80 | 
            -
             | 
| 81 | 
            -
                      console.info("Executing %j", cmd);
         | 
| 82 | 
            -
             | 
| 83 | 
            -
                      var child_process = require('child_process');
         | 
| 84 | 
            -
                      var child = child_process.spawn.apply(child_process, cmd.concat({ stdio: ['pipe', 1, 2] }));
         | 
| 85 | 
            -
                      child.on('exit', process.exit);
         | 
| 86 | 
            -
                      child.stdin.end(form.data);
         | 
| 87 | 
            -
                    });
         | 
| 88 | 
            -
                  });
         | 
| 89 | 
            -
                })
         | 
| 90 | 
            -
                .catch(function (err) {
         | 
| 91 | 
            -
                  console.error(err);
         | 
| 92 | 
            -
                  browser.on('exit', function () { process.exit(1); });
         | 
| 93 | 
            -
                  browser.exit();
         | 
| 94 | 
            -
                });
         | 
| 95 | 
            -
              });
         | 
| 96 | 
            -
            })
         | 
| 97 | 
            -
            .catch(function (err) {
         | 
| 98 | 
            -
              console.error(err);
         | 
| 99 | 
            -
              process.exit(1);
         | 
| 100 | 
            -
            });
         |