fcrepo_wrapper 0.3.4.1 → 0.4.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 +4 -4
- data/README.md +37 -2
- data/exe/fcrepo_wrapper +18 -5
- data/lib/fcrepo_wrapper/configuration.rb +10 -2
- data/lib/fcrepo_wrapper/instance.rb +9 -1
- data/lib/fcrepo_wrapper/tasks/fcrepo_wrapper.rake +0 -1
- data/lib/fcrepo_wrapper/version.rb +1 -1
- data/lib/fcrepo_wrapper.rb +3 -10
- data/spec/lib/fcrepo_wrapper/instance_spec.rb +10 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: c13336376dbcb9d568acba19a92fd5555595af05
         | 
| 4 | 
            +
              data.tar.gz: 597e66ac22ce559f7a028a54e9c74f6f0a247a2d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2bbdc8828cdf9b44c4d32fc026c1e8b99a1cb86373b61a885aa1e6cf4a34127c27c0422f0b2c9a177449ee10054b19dfe5b2aab902075e56dce45a48503d3a15
         | 
| 7 | 
            +
              data.tar.gz: 52a8673487e434d352d70a6b7b6244eb63bfd6416b27f536fd12b57e2594539412f3306c0f700533054c0ef357b1225fa80e34433a3dd5207bf838fa18bc1ad7
         | 
    
        data/README.md
    CHANGED
    
    | @@ -8,8 +8,43 @@ FcrepoWrapper.wrap do |solr| | |
| 8 8 | 
             
            end
         | 
| 9 9 | 
             
            ```
         | 
| 10 10 |  | 
| 11 | 
            -
            ##  | 
| 11 | 
            +
            ## Configuration Options
         | 
| 12 12 |  | 
| 13 | 
            +
            ### Command Line
         | 
| 14 | 
            +
            To see a list of valid options when using fcrepo_wrapper to launch an Fcrepo instance from the command line:
         | 
| 15 | 
            +
            ```
         | 
| 16 | 
            +
            $ fcrepo_wrapper -h
         | 
| 17 | 
            +
            ```
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ### Ruby
         | 
| 13 20 | 
             
            ```ruby
         | 
| 14 | 
            -
            FcrepoWrapper.wrap port: 8983, verbose: true, managed: true
         | 
| 21 | 
            +
            FcrepoWrapper.wrap( port: 8983, verbose: true, managed: true )
         | 
| 22 | 
            +
            ```
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            ### Configuration file
         | 
| 25 | 
            +
            FcrepoWrapper can read configuration options from a YAML configuration file.
         | 
| 26 | 
            +
            By default, it looks for configuration files at `.fcrepo_wrapper` and `~/.fcrepo_wrapper`.
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            You can also specify a configuration file when launching from the command line as follows:
         | 
| 29 | 
            +
            ```
         | 
| 30 | 
            +
            $ fcrepo_wrapper -config <path_to_config_file>
         | 
| 15 31 | 
             
            ```
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            ### Valid ruby and YAML options
         | 
| 34 | 
            +
            |Option           | Description                             |
         | 
| 35 | 
            +
            |-----------------|-----------------------------------------|
         | 
| 36 | 
            +
            | download_dir    | Local path for storing the downloaded jar & md5 file |
         | 
| 37 | 
            +
            | env             | *(Hash)* |
         | 
| 38 | 
            +
            | fcrepo_home_dir | Directory to store fedora repoistory data files |
         | 
| 39 | 
            +
            | fedora_options  | *(Hash)* |
         | 
| 40 | 
            +
            | ignore_md5sum   | *(Boolean)* suppress checksum error messages |
         | 
| 41 | 
            +
            | instance_dir    | Directory to store the fedora jar file |
         | 
| 42 | 
            +
            | md5sum          | Path/URL to MD5 checksum |
         | 
| 43 | 
            +
            | port            | Port to run Fedora on |
         | 
| 44 | 
            +
            | url             | URL of the jar file to download |
         | 
| 45 | 
            +
            | validate        | *(Boolean)* download a new md5 and (re-)validate the jar file? (default: true) |
         | 
| 46 | 
            +
            | verbose         | *(Boolean)* return verbose info when running fcrepo commands (default: false) |
         | 
| 47 | 
            +
            | version         | Fedora version to download and install |
         | 
| 48 | 
            +
            | version_file    | Local path to store the currently installed version number |
         | 
| 49 | 
            +
             | 
| 50 | 
            +
             | 
    
        data/exe/fcrepo_wrapper
    CHANGED
    
    | @@ -5,10 +5,10 @@ require 'optparse' | |
| 5 5 |  | 
| 6 6 | 
             
            options = {}
         | 
| 7 7 |  | 
| 8 | 
            -
            OptionParser.new do |opts|
         | 
| 8 | 
            +
            args = OptionParser.new do |opts|
         | 
| 9 9 | 
             
              opts.banner = "Usage: fcrepo_wrapper [options]"
         | 
| 10 10 |  | 
| 11 | 
            -
              opts.on("--config", "Load configuration from a file") do |v|
         | 
| 11 | 
            +
              opts.on("--config FILE", "Load configuration from a file") do |v|
         | 
| 12 12 | 
             
                options[:config] = v
         | 
| 13 13 | 
             
              end
         | 
| 14 14 |  | 
| @@ -16,7 +16,7 @@ OptionParser.new do |opts| | |
| 16 16 | 
             
                options[:verbose] = v
         | 
| 17 17 | 
             
              end
         | 
| 18 18 |  | 
| 19 | 
            -
              opts.on("--[no-]jms", "Run  | 
| 19 | 
            +
              opts.on("--[no-]jms", "Run with[or witout] JMS") do |v|
         | 
| 20 20 | 
             
                options[:enable_jms] = v
         | 
| 21 21 | 
             
              end
         | 
| 22 22 |  | 
| @@ -24,7 +24,7 @@ OptionParser.new do |opts| | |
| 24 24 | 
             
                options[:version] = v
         | 
| 25 25 | 
             
              end
         | 
| 26 26 |  | 
| 27 | 
            -
              opts.on("-pPORT", "--port PORT", "Specify the port fcrepo should run at (default:  | 
| 27 | 
            +
              opts.on("-pPORT", "--port PORT", "Specify the port fcrepo should run at (default: #{FcrepoWrapper.default_fcrepo_port})") do |p|
         | 
| 28 28 | 
             
                if p == 'random'
         | 
| 29 29 | 
             
                  options[:port] = nil
         | 
| 30 30 | 
             
                else
         | 
| @@ -39,7 +39,20 @@ OptionParser.new do |opts| | |
| 39 39 | 
             
              opts.on("-dDIR", "--fcrepo_home DIR", "Store fcrepo at the given directory") do |d|
         | 
| 40 40 | 
             
                options[:fcrepo_home_dir] = d
         | 
| 41 41 | 
             
              end
         | 
| 42 | 
            -
             | 
| 42 | 
            +
             | 
| 43 | 
            +
              opts.on("-h", "--help", "Show these usage options") do
         | 
| 44 | 
            +
                puts opts
         | 
| 45 | 
            +
                exit
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
            end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            begin
         | 
| 50 | 
            +
              args.parse!
         | 
| 51 | 
            +
            rescue => error
         | 
| 52 | 
            +
              $stderr.puts "ERROR: #{error}\n"
         | 
| 53 | 
            +
              $stderr.puts "#{args.help}\n"
         | 
| 54 | 
            +
              exit 1
         | 
| 55 | 
            +
            end
         | 
| 43 56 |  | 
| 44 57 | 
             
            # default to verbose
         | 
| 45 58 | 
             
            options[:verbose] = true if options[:verbose].nil?
         | 
| @@ -95,7 +95,7 @@ module FcrepoWrapper | |
| 95 95 | 
             
                  # Check if the port option has been explicitly set to nil.
         | 
| 96 96 | 
             
                  # this means to start fcrepo_wrapper on a random open port
         | 
| 97 97 | 
             
                  return nil if options.key?(:port) && !options[:port]
         | 
| 98 | 
            -
                  options[:port] || FcrepoWrapper. | 
| 98 | 
            +
                  options[:port] || FcrepoWrapper.default_fcrepo_port
         | 
| 99 99 | 
             
                end
         | 
| 100 100 |  | 
| 101 101 | 
             
                def validate
         | 
| @@ -132,8 +132,16 @@ module FcrepoWrapper | |
| 132 132 | 
             
                    ['.fcrepo_wrapper', '~/.fcrepo_wrapper']
         | 
| 133 133 | 
             
                  end
         | 
| 134 134 |  | 
| 135 | 
            +
                  def default_download_dir
         | 
| 136 | 
            +
                    if defined? Rails
         | 
| 137 | 
            +
                      File.join(Rails.root, 'tmp')
         | 
| 138 | 
            +
                    else
         | 
| 139 | 
            +
                      Dir.tmpdir
         | 
| 140 | 
            +
                    end
         | 
| 141 | 
            +
                  end
         | 
| 142 | 
            +
             | 
| 135 143 | 
             
                  def download_dir
         | 
| 136 | 
            -
                    @download_dir ||= options.fetch(:download_dir,  | 
| 144 | 
            +
                    @download_dir ||= options.fetch(:download_dir, default_download_dir)
         | 
| 137 145 | 
             
                    FileUtils.mkdir_p @download_dir
         | 
| 138 146 | 
             
                    @download_dir
         | 
| 139 147 | 
             
                  end
         | 
| @@ -141,6 +141,14 @@ module FcrepoWrapper | |
| 141 141 | 
             
                  config.version
         | 
| 142 142 | 
             
                end
         | 
| 143 143 |  | 
| 144 | 
            +
                def instance_dir
         | 
| 145 | 
            +
                  config.instance_dir
         | 
| 146 | 
            +
                end
         | 
| 147 | 
            +
             | 
| 148 | 
            +
                def options
         | 
| 149 | 
            +
                  config.options
         | 
| 150 | 
            +
                end
         | 
| 151 | 
            +
             | 
| 144 152 | 
             
                ##
         | 
| 145 153 | 
             
                # Clean up any files fcrepo_wrapper may have downloaded
         | 
| 146 154 | 
             
                def clean!
         | 
| @@ -191,7 +199,7 @@ module FcrepoWrapper | |
| 191 199 | 
             
                end
         | 
| 192 200 |  | 
| 193 201 | 
             
                def download
         | 
| 194 | 
            -
                  unless File.exists?(config.download_path) && validate?(config.download_path)
         | 
| 202 | 
            +
                  unless File.exists?(config.download_path) && md5.validate?(config.download_path)
         | 
| 195 203 | 
             
                    Downloader.fetch_with_progressbar config.download_url, config.download_path
         | 
| 196 204 | 
             
                    md5.validate! config.download_path
         | 
| 197 205 | 
             
                  end
         | 
| @@ -4,7 +4,6 @@ require 'fcrepo_wrapper' | |
| 4 4 | 
             
            namespace :fcrepo do
         | 
| 5 5 | 
             
              desc "Load the fcrepo options and fcrepo instance"
         | 
| 6 6 | 
             
              task :environment do
         | 
| 7 | 
            -
                FcrepoWrapper.default_instance_options[:download_dir] ||= Rails.root.to_s + '/tmp' if defined? Rails
         | 
| 8 7 | 
             
                @fcrepo_instance = FcrepoWrapper.default_instance
         | 
| 9 8 | 
             
              end
         | 
| 10 9 |  | 
    
        data/lib/fcrepo_wrapper.rb
    CHANGED
    
    | @@ -10,19 +10,12 @@ module FcrepoWrapper | |
| 10 10 | 
             
                '4.5.0'
         | 
| 11 11 | 
             
              end
         | 
| 12 12 |  | 
| 13 | 
            -
              def self. | 
| 14 | 
            -
                 | 
| 15 | 
            -
                  port: '8080',
         | 
| 16 | 
            -
                  version: FcrepoWrapper.default_fcrepo_version
         | 
| 17 | 
            -
                }
         | 
| 18 | 
            -
              end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              def self.default_instance_options=(options)
         | 
| 21 | 
            -
                @default_instance_options = options
         | 
| 13 | 
            +
              def self.default_fcrepo_port
         | 
| 14 | 
            +
                '8080'
         | 
| 22 15 | 
             
              end
         | 
| 23 16 |  | 
| 24 17 | 
             
              def self.default_instance(options = {})
         | 
| 25 | 
            -
                @default_instance ||= FcrepoWrapper::Instance.new  | 
| 18 | 
            +
                @default_instance ||= FcrepoWrapper::Instance.new options
         | 
| 26 19 | 
             
              end
         | 
| 27 20 |  | 
| 28 21 | 
             
              ##
         | 
| @@ -27,5 +27,14 @@ describe FcrepoWrapper::Instance do | |
| 27 27 | 
             
                subject { wrapper.md5 }
         | 
| 28 28 | 
             
                it { is_expected.to be_instance_of FcrepoWrapper::MD5 }
         | 
| 29 29 | 
             
              end
         | 
| 30 | 
            -
            end
         | 
| 31 30 |  | 
| 31 | 
            +
              describe "#instance_dir" do
         | 
| 32 | 
            +
                subject { File.exists?(wrapper.instance_dir) }
         | 
| 33 | 
            +
                it { is_expected.to be true }
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              describe "#options" do
         | 
| 37 | 
            +
                subject { wrapper.options }
         | 
| 38 | 
            +
                it { is_expected.to eq({}) }
         | 
| 39 | 
            +
              end 
         | 
| 40 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fcrepo_wrapper
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Chris Beer
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016- | 
| 11 | 
            +
            date: 2016-04-12 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: ruby-progressbar
         |