softwear-lib 0.0.1
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 +7 -0
 - data/.gitignore +15 -0
 - data/.rspec +3 -0
 - data/Gemfile +4 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +31 -0
 - data/Rakefile +2 -0
 - data/lib/softwear/lib/spec.rb +114 -0
 - data/lib/softwear/lib/version.rb +5 -0
 - data/lib/softwear/lib.rb +90 -0
 - data/softwear-lib.gemspec +26 -0
 - data/spec/spec_helper.rb +93 -0
 - metadata +112 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: ecc5f164e59fd521b6522ac4ba01e739bd945436
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1efe4f44b72912c2875095ec8f3c5e3f5c96f465
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 560506dd92dfea4c1caabf3af759860aa03b1d8f775d4973e8bdce34f192026cb034eb00e370621b04b964ff22411786fba0f4f979f68f90ee3f774d506c84bb
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: f62844ef50b2087df31e8005ff9ca00ff64424dae285f55b19cca13d4f7cc8a698e7ee4395b3745e589a84e30e34606b54035ecb036f6f0ebd738a0892d7ddbe
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2015 Nigel Baillie
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Softwear::Lib
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            TODO: Write a gem description
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 10 
     | 
    
         
            +
            gem 'softwear-lib'
         
     | 
| 
      
 11 
     | 
    
         
            +
            ```
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                $ gem install softwear-lib
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            TODO: Write usage instructions here
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            1. Fork it ( https://github.com/[my-github-username]/softwear-lib/fork )
         
     | 
| 
      
 28 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 29 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 30 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 31 
     | 
    
         
            +
            5. Create a new Pull Request
         
     | 
    
        data/Rakefile
    ADDED
    
    
| 
         @@ -0,0 +1,114 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'active_support/concern'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Softwear::Lib
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Spec
         
     | 
| 
      
 5 
     | 
    
         
            +
                extend ActiveSupport::Concern
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                module CapybaraHelpers
         
     | 
| 
      
 8 
     | 
    
         
            +
                  def wait_for_ajax
         
     | 
| 
      
 9 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 10 
     | 
    
         
            +
                      Timeout.timeout(Capybara.default_wait_time) do
         
     | 
| 
      
 11 
     | 
    
         
            +
                        wait_for_jquery
         
     | 
| 
      
 12 
     | 
    
         
            +
                        loop until finished_all_ajax_requests?
         
     | 
| 
      
 13 
     | 
    
         
            +
                      end
         
     | 
| 
      
 14 
     | 
    
         
            +
                    rescue
         
     | 
| 
      
 15 
     | 
    
         
            +
                      sleep 0.1
         
     | 
| 
      
 16 
     | 
    
         
            +
                    end
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  def finished_all_ajax_requests?
         
     | 
| 
      
 20 
     | 
    
         
            +
                    page.evaluate_script('jQuery.active').zero?
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  def wait_for_redirect
         
     | 
| 
      
 24 
     | 
    
         
            +
                    original_url = current_path
         
     | 
| 
      
 25 
     | 
    
         
            +
                    until current_path != original_url
         
     | 
| 
      
 26 
     | 
    
         
            +
                      sleep(0.1)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    end
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  def wait_for_jquery
         
     | 
| 
      
 31 
     | 
    
         
            +
                    until page.evaluate_script('jQuery.active') == 0
         
     | 
| 
      
 32 
     | 
    
         
            +
                      sleep(0.1)
         
     | 
| 
      
 33 
     | 
    
         
            +
                    end
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  def accept_alert
         
     | 
| 
      
 37 
     | 
    
         
            +
                    page.evaluate_script('window.confirm = function() { return true; }')
         
     | 
| 
      
 38 
     | 
    
         
            +
                    yield
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  def dismiss_alert
         
     | 
| 
      
 42 
     | 
    
         
            +
                    page.evaluate_script('window.confirm = function() { return false; }')
         
     | 
| 
      
 43 
     | 
    
         
            +
                    yield
         
     | 
| 
      
 44 
     | 
    
         
            +
                    # Restore existing default
         
     | 
| 
      
 45 
     | 
    
         
            +
                    page.evaluate_script('window.confirm = function() { return true; }')
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                module Select2
         
     | 
| 
      
 50 
     | 
    
         
            +
                  def set_select2_field(field, value)
         
     | 
| 
      
 51 
     | 
    
         
            +
                    page.execute_script %Q{$('#{field}').select2('val', '#{value}')}
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                  def select2_search(value, options)
         
     | 
| 
      
 55 
     | 
    
         
            +
                    label = find_label_by_text(options[:from])
         
     | 
| 
      
 56 
     | 
    
         
            +
                    within label.first(:xpath,'.//..') do
         
     | 
| 
      
 57 
     | 
    
         
            +
                      options[:from] = "##{find('.select2-container')['id']}"
         
     | 
| 
      
 58 
     | 
    
         
            +
                    end
         
     | 
| 
      
 59 
     | 
    
         
            +
                    targetted_select2_search(value, options)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                  def targetted_select2_search(value, options)
         
     | 
| 
      
 63 
     | 
    
         
            +
                    page.execute_script %Q{$('#{options[:from]}').select2('open')}
         
     | 
| 
      
 64 
     | 
    
         
            +
                    page.execute_script "$('#{options[:dropdown_css]} input.select2-input').val('#{value}').trigger('keyup-change');"
         
     | 
| 
      
 65 
     | 
    
         
            +
                    select_select2_result(value)
         
     | 
| 
      
 66 
     | 
    
         
            +
                  end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                  def select2(value, options)
         
     | 
| 
      
 69 
     | 
    
         
            +
                    label = find_label_by_text(options[:from])
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                    within label.first(:xpath,'.//..') do
         
     | 
| 
      
 72 
     | 
    
         
            +
                      options[:from] = "##{find('.select2-container')['id']}"
         
     | 
| 
      
 73 
     | 
    
         
            +
                    end
         
     | 
| 
      
 74 
     | 
    
         
            +
                    targetted_select2(value, options)
         
     | 
| 
      
 75 
     | 
    
         
            +
                  end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                  def select2_no_label value, options={}
         
     | 
| 
      
 78 
     | 
    
         
            +
                    raise "Must pass a hash containing 'from'" if not options.is_a?(Hash) or not options.has_key?(:from)
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                    placeholder = options[:from]
         
     | 
| 
      
 81 
     | 
    
         
            +
                    # TODO: still need this?
         
     | 
| 
      
 82 
     | 
    
         
            +
                    # minlength = options[:minlength] || 4
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                    click_link placeholder
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                    select_select2_result(value)
         
     | 
| 
      
 87 
     | 
    
         
            +
                  end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                  def targetted_select2(value, options)
         
     | 
| 
      
 90 
     | 
    
         
            +
                    # find select2 element and click it
         
     | 
| 
      
 91 
     | 
    
         
            +
                    find(options[:from]).find('a').click
         
     | 
| 
      
 92 
     | 
    
         
            +
                    select_select2_result(value)
         
     | 
| 
      
 93 
     | 
    
         
            +
                  end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                  def select_select2_result(value)
         
     | 
| 
      
 96 
     | 
    
         
            +
                    # results are in a div appended to the end of the document
         
     | 
| 
      
 97 
     | 
    
         
            +
                    within(:xpath, '//body') do
         
     | 
| 
      
 98 
     | 
    
         
            +
                      page.find('div.select2-result-label', text: %r{#{Regexp.escape(value)}}i).click
         
     | 
| 
      
 99 
     | 
    
         
            +
                    end
         
     | 
| 
      
 100 
     | 
    
         
            +
                  end
         
     | 
| 
      
 101 
     | 
    
         
            +
                end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                included do
         
     | 
| 
      
 104 
     | 
    
         
            +
                  include Warden::Test::Helpers
         
     | 
| 
      
 105 
     | 
    
         
            +
                  Warden.test_mode!
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                  RSpec.configure do |config|
         
     | 
| 
      
 108 
     | 
    
         
            +
                    config.include CapybaraHelpers, type: :feature
         
     | 
| 
      
 109 
     | 
    
         
            +
                    config.include Select2, type: :feature
         
     | 
| 
      
 110 
     | 
    
         
            +
                  end
         
     | 
| 
      
 111 
     | 
    
         
            +
                end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
              end
         
     | 
| 
      
 114 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/softwear/lib.rb
    ADDED
    
    | 
         @@ -0,0 +1,90 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "softwear/lib/version"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "softwear/lib/spec"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Softwear
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Lib
         
     | 
| 
      
 6 
     | 
    
         
            +
                # Your code goes here...
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                def self.common_gems(gemfile)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  gemfile.instance_eval do
         
     | 
| 
      
 10 
     | 
    
         
            +
                    gem 'rails', '4.2.1'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                    gem 'mysql2'
         
     | 
| 
      
 13 
     | 
    
         
            +
                    gem 'sass-rails'
         
     | 
| 
      
 14 
     | 
    
         
            +
                    gem 'uglifier', '>= 1.3.0'
         
     | 
| 
      
 15 
     | 
    
         
            +
                    gem 'coffee-rails', '~> 4.0.0'
         
     | 
| 
      
 16 
     | 
    
         
            +
                    gem 'bootstrap-sass', '~> 3.2.0'
         
     | 
| 
      
 17 
     | 
    
         
            +
                    gem 'activeresource'
         
     | 
| 
      
 18 
     | 
    
         
            +
                    gem 'jquery-rails'
         
     | 
| 
      
 19 
     | 
    
         
            +
                    gem 'jquery-ui-rails'
         
     | 
| 
      
 20 
     | 
    
         
            +
                    gem 'hirb'
         
     | 
| 
      
 21 
     | 
    
         
            +
                    gem 'momentjs-rails', '>= 2.8.3'
         
     | 
| 
      
 22 
     | 
    
         
            +
                    gem 'bootstrap3-datetimepicker-rails', '~> 3.1.3'
         
     | 
| 
      
 23 
     | 
    
         
            +
                    gem 'js-routes'
         
     | 
| 
      
 24 
     | 
    
         
            +
                    gem 'inherited_resources'
         
     | 
| 
      
 25 
     | 
    
         
            +
                    gem 'devise'
         
     | 
| 
      
 26 
     | 
    
         
            +
                    gem 'figaro'
         
     | 
| 
      
 27 
     | 
    
         
            +
                    gem 'paranoia', '~> 2.0'
         
     | 
| 
      
 28 
     | 
    
         
            +
                    gem 'paperclip', github: 'thoughtbot/paperclip'
         
     | 
| 
      
 29 
     | 
    
         
            +
                    gem 'kaminari'
         
     | 
| 
      
 30 
     | 
    
         
            +
                    gem 'whenever'
         
     | 
| 
      
 31 
     | 
    
         
            +
                    gem 'dumpsync', git: 'git@github.com:AnnArborTees/dumpsync.git'
         
     | 
| 
      
 32 
     | 
    
         
            +
                    gem 'bootstrap_form'
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    group :development do
         
     | 
| 
      
 35 
     | 
    
         
            +
                      gem 'capistrano', '~> 3.2.0'
         
     | 
| 
      
 36 
     | 
    
         
            +
                      gem 'capistrano-rvm'
         
     | 
| 
      
 37 
     | 
    
         
            +
                      gem 'capistrano-rails'
         
     | 
| 
      
 38 
     | 
    
         
            +
                      gem 'capistrano-bundler'
         
     | 
| 
      
 39 
     | 
    
         
            +
                      gem 'better_errors', '>= 0.3.2'
         
     | 
| 
      
 40 
     | 
    
         
            +
                      gem 'binding_of_caller'
         
     | 
| 
      
 41 
     | 
    
         
            +
                    end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                    group :development, :test do
         
     | 
| 
      
 44 
     | 
    
         
            +
                      gem 'byebug', platforms: :mri
         
     | 
| 
      
 45 
     | 
    
         
            +
                      gem 'rubinius-debugger', platforms: :rbx
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    group :test do
         
     | 
| 
      
 49 
     | 
    
         
            +
                      gem "rspec-rails", "~> 3.2.0"
         
     | 
| 
      
 50 
     | 
    
         
            +
                      gem 'factory_girl_rails', '>= 4.2.0', require: true
         
     | 
| 
      
 51 
     | 
    
         
            +
                      gem 'capybara', '~> 2.4'
         
     | 
| 
      
 52 
     | 
    
         
            +
                      gem 'capybara-webkit'
         
     | 
| 
      
 53 
     | 
    
         
            +
                      gem 'webmock', require: false
         
     | 
| 
      
 54 
     | 
    
         
            +
                      gem 'rspec-mocks'
         
     | 
| 
      
 55 
     | 
    
         
            +
                      gem 'rspec-retry'
         
     | 
| 
      
 56 
     | 
    
         
            +
                      gem 'email_spec'
         
     | 
| 
      
 57 
     | 
    
         
            +
                      gem 'selenium-webdriver'
         
     | 
| 
      
 58 
     | 
    
         
            +
                      gem 'shoulda-matchers'
         
     | 
| 
      
 59 
     | 
    
         
            +
                    end
         
     | 
| 
      
 60 
     | 
    
         
            +
                  end
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                def self.fix_sort_argument_error_on_rubinius
         
     | 
| 
      
 64 
     | 
    
         
            +
                  # Rubinius calls Enumerator#sort! within Enumerator#sort_by,
         
     | 
| 
      
 65 
     | 
    
         
            +
                  # # and Mail::PartsList calls sort_by within sort!... See the
         
     | 
| 
      
 66 
     | 
    
         
            +
                  # problem?
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                  if RUBY_ENGINE == 'rbx'
         
     | 
| 
      
 69 
     | 
    
         
            +
                    require 'mail'
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                    Mail::PartsList.class_eval do
         
     | 
| 
      
 72 
     | 
    
         
            +
                      def map!(&block)
         
     | 
| 
      
 73 
     | 
    
         
            +
                        Mail::PartsList.new(collect(&block))
         
     | 
| 
      
 74 
     | 
    
         
            +
                      end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                      def sort!(order = nil)
         
     | 
| 
      
 77 
     | 
    
         
            +
                        return super() if order.nil?
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                        i = 0
         
     | 
| 
      
 80 
     | 
    
         
            +
                        sorted = self.sort_by do |a|
         
     | 
| 
      
 81 
     | 
    
         
            +
                          [get_order_value(a, order), i += 1]
         
     | 
| 
      
 82 
     | 
    
         
            +
                        end
         
     | 
| 
      
 83 
     | 
    
         
            +
                        self.clear
         
     | 
| 
      
 84 
     | 
    
         
            +
                        sorted.each(&self.method(:<<))
         
     | 
| 
      
 85 
     | 
    
         
            +
                      end
         
     | 
| 
      
 86 
     | 
    
         
            +
                    end
         
     | 
| 
      
 87 
     | 
    
         
            +
                  end
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'softwear/lib/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = "softwear-lib"
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = Softwear::Lib::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["Nigel Baillie"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["nigel@annarbortees.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary       = %q{Common gems and logic for all softwear apps.}
         
     | 
| 
      
 12 
     | 
    
         
            +
              # spec.description   = %q{TODO: Write a longer description. Optional.}
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.homepage      = ""
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0")
         
     | 
| 
      
 17 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 1.7"
         
     | 
| 
      
 22 
     | 
    
         
            +
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
| 
      
 23 
     | 
    
         
            +
              spec.add_development_dependency "rspec", "~> 3.2.0"
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_dependency "activesupport"
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,93 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # This file was generated by the `rspec --init` command. Conventionally, all
         
     | 
| 
      
 2 
     | 
    
         
            +
            # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
         
     | 
| 
      
 3 
     | 
    
         
            +
            # The generated `.rspec` file contains `--require spec_helper` which will cause
         
     | 
| 
      
 4 
     | 
    
         
            +
            # this file to always be loaded, without a need to explicitly require it in any
         
     | 
| 
      
 5 
     | 
    
         
            +
            # files.
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
      
 7 
     | 
    
         
            +
            # Given that it is always loaded, you are encouraged to keep this file as
         
     | 
| 
      
 8 
     | 
    
         
            +
            # light-weight as possible. Requiring heavyweight dependencies from this file
         
     | 
| 
      
 9 
     | 
    
         
            +
            # will add to the boot time of your test suite on EVERY test run, even for an
         
     | 
| 
      
 10 
     | 
    
         
            +
            # individual file that may not need all of that loaded. Instead, consider making
         
     | 
| 
      
 11 
     | 
    
         
            +
            # a separate helper file that requires the additional dependencies and performs
         
     | 
| 
      
 12 
     | 
    
         
            +
            # the additional setup, and require it from the spec files that actually need
         
     | 
| 
      
 13 
     | 
    
         
            +
            # it.
         
     | 
| 
      
 14 
     | 
    
         
            +
            #
         
     | 
| 
      
 15 
     | 
    
         
            +
            # The `.rspec` file also contains a few flags that are not defaults but that
         
     | 
| 
      
 16 
     | 
    
         
            +
            # users commonly want.
         
     | 
| 
      
 17 
     | 
    
         
            +
            #
         
     | 
| 
      
 18 
     | 
    
         
            +
            # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
         
     | 
| 
      
 19 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 20 
     | 
    
         
            +
              # rspec-expectations config goes here. You can use an alternate
         
     | 
| 
      
 21 
     | 
    
         
            +
              # assertion/expectation library such as wrong or the stdlib/minitest
         
     | 
| 
      
 22 
     | 
    
         
            +
              # assertions if you prefer.
         
     | 
| 
      
 23 
     | 
    
         
            +
              config.expect_with :rspec do |expectations|
         
     | 
| 
      
 24 
     | 
    
         
            +
                # This option will default to `true` in RSpec 4. It makes the `description`
         
     | 
| 
      
 25 
     | 
    
         
            +
                # and `failure_message` of custom matchers include text for helper methods
         
     | 
| 
      
 26 
     | 
    
         
            +
                # defined using `chain`, e.g.:
         
     | 
| 
      
 27 
     | 
    
         
            +
                #     be_bigger_than(2).and_smaller_than(4).description
         
     | 
| 
      
 28 
     | 
    
         
            +
                #     # => "be bigger than 2 and smaller than 4"
         
     | 
| 
      
 29 
     | 
    
         
            +
                # ...rather than:
         
     | 
| 
      
 30 
     | 
    
         
            +
                #     # => "be bigger than 2"
         
     | 
| 
      
 31 
     | 
    
         
            +
                expectations.include_chain_clauses_in_custom_matcher_descriptions = true
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              # rspec-mocks config goes here. You can use an alternate test double
         
     | 
| 
      
 35 
     | 
    
         
            +
              # library (such as bogus or mocha) by changing the `mock_with` option here.
         
     | 
| 
      
 36 
     | 
    
         
            +
              config.mock_with :rspec do |mocks|
         
     | 
| 
      
 37 
     | 
    
         
            +
                # Prevents you from mocking or stubbing a method that does not exist on
         
     | 
| 
      
 38 
     | 
    
         
            +
                # a real object. This is generally recommended, and will default to
         
     | 
| 
      
 39 
     | 
    
         
            +
                # `true` in RSpec 4.
         
     | 
| 
      
 40 
     | 
    
         
            +
                mocks.verify_partial_doubles = true
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              config.order = :random
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            # The settings below are suggested to provide a good initial experience
         
     | 
| 
      
 46 
     | 
    
         
            +
            # with RSpec, but feel free to customize to your heart's content.
         
     | 
| 
      
 47 
     | 
    
         
            +
            =begin
         
     | 
| 
      
 48 
     | 
    
         
            +
              # These two settings work together to allow you to limit a spec run
         
     | 
| 
      
 49 
     | 
    
         
            +
              # to individual examples or groups you care about by tagging them with
         
     | 
| 
      
 50 
     | 
    
         
            +
              # `:focus` metadata. When nothing is tagged with `:focus`, all examples
         
     | 
| 
      
 51 
     | 
    
         
            +
              # get run.
         
     | 
| 
      
 52 
     | 
    
         
            +
              config.filter_run :focus
         
     | 
| 
      
 53 
     | 
    
         
            +
              config.run_all_when_everything_filtered = true
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              # Limits the available syntax to the non-monkey patched syntax that is
         
     | 
| 
      
 56 
     | 
    
         
            +
              # recommended. For more details, see:
         
     | 
| 
      
 57 
     | 
    
         
            +
              #   - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
         
     | 
| 
      
 58 
     | 
    
         
            +
              #   - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
         
     | 
| 
      
 59 
     | 
    
         
            +
              #   - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
         
     | 
| 
      
 60 
     | 
    
         
            +
              config.disable_monkey_patching!
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
              # This setting enables warnings. It's recommended, but in some cases may
         
     | 
| 
      
 63 
     | 
    
         
            +
              # be too noisy due to issues in dependencies.
         
     | 
| 
      
 64 
     | 
    
         
            +
              config.warnings = true
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
              # Many RSpec users commonly either run the entire suite or an individual
         
     | 
| 
      
 67 
     | 
    
         
            +
              # file, and it's useful to allow more verbose output when running an
         
     | 
| 
      
 68 
     | 
    
         
            +
              # individual spec file.
         
     | 
| 
      
 69 
     | 
    
         
            +
              if config.files_to_run.one?
         
     | 
| 
      
 70 
     | 
    
         
            +
                # Use the documentation formatter for detailed output,
         
     | 
| 
      
 71 
     | 
    
         
            +
                # unless a formatter has already been configured
         
     | 
| 
      
 72 
     | 
    
         
            +
                # (e.g. via a command-line flag).
         
     | 
| 
      
 73 
     | 
    
         
            +
                config.default_formatter = 'doc'
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
              # Print the 10 slowest examples and example groups at the
         
     | 
| 
      
 77 
     | 
    
         
            +
              # end of the spec run, to help surface which specs are running
         
     | 
| 
      
 78 
     | 
    
         
            +
              # particularly slow.
         
     | 
| 
      
 79 
     | 
    
         
            +
              config.profile_examples = 10
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
              # Run specs in random order to surface order dependencies. If you find an
         
     | 
| 
      
 82 
     | 
    
         
            +
              # order dependency and want to debug it, you can fix the order by providing
         
     | 
| 
      
 83 
     | 
    
         
            +
              # the seed, which is printed after each run.
         
     | 
| 
      
 84 
     | 
    
         
            +
              #     --seed 1234
         
     | 
| 
      
 85 
     | 
    
         
            +
              config.order = :random
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              # Seed global randomization in this process using the `--seed` CLI option.
         
     | 
| 
      
 88 
     | 
    
         
            +
              # Setting this allows you to use `--seed` to deterministically reproduce
         
     | 
| 
      
 89 
     | 
    
         
            +
              # test failures related to randomization by passing the same `--seed` value
         
     | 
| 
      
 90 
     | 
    
         
            +
              # as the one that triggered the failure.
         
     | 
| 
      
 91 
     | 
    
         
            +
              Kernel.srand config.seed
         
     | 
| 
      
 92 
     | 
    
         
            +
            =end
         
     | 
| 
      
 93 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,112 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: softwear-lib
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Nigel Baillie
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-05-20 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 15 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 17 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 18 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 19 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 20 
     | 
    
         
            +
                    version: '1.7'
         
     | 
| 
      
 21 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 22 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 23 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 24 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 25 
     | 
    
         
            +
                    version: '1.7'
         
     | 
| 
      
 26 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 29 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 30 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 31 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 32 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 33 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 34 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 35 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 36 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 37 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 38 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 39 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 40 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 43 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 44 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 45 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 46 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 47 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 48 
     | 
    
         
            +
                    version: 3.2.0
         
     | 
| 
      
 49 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 50 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 51 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 52 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 53 
     | 
    
         
            +
                    version: 3.2.0
         
     | 
| 
      
 54 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: activesupport
         
     | 
| 
      
 57 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 58 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 59 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 60 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 61 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 62 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 63 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 64 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 65 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 66 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 67 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 68 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 69 
     | 
    
         
            +
            description: 
         
     | 
| 
      
 70 
     | 
    
         
            +
            email:
         
     | 
| 
      
 71 
     | 
    
         
            +
            - nigel@annarbortees.com
         
     | 
| 
      
 72 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 73 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 74 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 75 
     | 
    
         
            +
            files:
         
     | 
| 
      
 76 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 77 
     | 
    
         
            +
            - ".rspec"
         
     | 
| 
      
 78 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 79 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 80 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 81 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 82 
     | 
    
         
            +
            - lib/softwear/lib.rb
         
     | 
| 
      
 83 
     | 
    
         
            +
            - lib/softwear/lib/spec.rb
         
     | 
| 
      
 84 
     | 
    
         
            +
            - lib/softwear/lib/version.rb
         
     | 
| 
      
 85 
     | 
    
         
            +
            - softwear-lib.gemspec
         
     | 
| 
      
 86 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 87 
     | 
    
         
            +
            homepage: ''
         
     | 
| 
      
 88 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 89 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 90 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 91 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 92 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 93 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 94 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 95 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 96 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 97 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 98 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 99 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 100 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 101 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 102 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 103 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 104 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 105 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 106 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 107 
     | 
    
         
            +
            rubygems_version: 2.4.6
         
     | 
| 
      
 108 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 109 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 110 
     | 
    
         
            +
            summary: Common gems and logic for all softwear apps.
         
     | 
| 
      
 111 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 112 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     |