that 0.0.1 → 0.1.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/lib/that.rb +27 -23
- data/lib/that/version.rb +1 -1
- metadata +11 -11
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b1df6248ff21363b9ce23e511b05eedf65b9ad28
         | 
| 4 | 
            +
              data.tar.gz: 2d456df2236048c88349839793a6888f65f65c16
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 24730c1b2128c59f63f56dd902e2638c5a7830fc26884fe8977c3896a267c204ff880c7bb6bb0a7246732dbe28fd70cd2aefe7230bcd9d4cd1e1dc038672c106
         | 
| 7 | 
            +
              data.tar.gz: ae597ef35546d661884aaf929928e14df1e2485bc7e3ec3344daf6858e42f7b145e372b02f94c6313ad9d9158c7fd88473a307060d1965052df4858491a07a35
         | 
    
        data/lib/that.rb
    CHANGED
    
    | @@ -1,31 +1,35 @@ | |
| 1 1 | 
             
            module That
         | 
| 2 | 
            -
               | 
| 3 | 
            -
             | 
| 4 | 
            -
                 | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 2 | 
            +
              module Core
         | 
| 3 | 
            +
                DEFAULT_TO_THAT_KEYS = [:name, :login, :email]
         | 
| 4 | 
            +
                def that(query)
         | 
| 5 | 
            +
                  query = query.to_s
         | 
| 6 | 
            +
                  # Make sure all models are loaded
         | 
| 7 | 
            +
                  Rails.application.eager_load!
         | 
| 7 8 |  | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 9 | 
            +
                  # Find out what symbols are AR subclasses
         | 
| 10 | 
            +
                  models = Module.constants.collect do |constant_name|
         | 
| 11 | 
            +
                    constant = eval(constant_name.to_s)
         | 
| 12 | 
            +
                    if not constant.nil? and constant.is_a? Class and constant.superclass == ActiveRecord::Base
         | 
| 13 | 
            +
                      constant
         | 
| 14 | 
            +
                    end
         | 
| 13 15 | 
             
                  end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                models.compact!
         | 
| 16 | 
            +
                  models.compact!
         | 
| 16 17 |  | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 18 | 
            +
                  results = []
         | 
| 19 | 
            +
                  # Query everything!
         | 
| 20 | 
            +
                  models.each do |model|
         | 
| 21 | 
            +
                    keys = model.respond_to?(:to_that) ? model.to_that : DEFAULT_TO_THAT_KEYS
         | 
| 22 | 
            +
                    keys.each do |key|
         | 
| 23 | 
            +
                      results += model.where(key => query) if model.column_names.include?(key.to_s)
         | 
| 24 | 
            +
                    end
         | 
| 24 25 |  | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                  results.length == 1 ? results.first : results
         | 
| 25 28 | 
             
                end
         | 
| 26 | 
            -
                 | 
| 29 | 
            +
                alias_method :dat, :that
         | 
| 27 30 | 
             
              end
         | 
| 28 | 
            -
              alias_method :dat, :that
         | 
| 29 | 
            -
            end
         | 
| 30 31 |  | 
| 31 | 
            -
             | 
| 32 | 
            +
              def self.activate
         | 
| 33 | 
            +
                Object.send(:include, That::Core) # lol
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
            end
         | 
    
        data/lib/that/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,27 +1,27 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: that
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0 | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Daniel Hengeveld
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014- | 
| 11 | 
            +
            date: 2014-12-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 | 
            -
                - -  | 
| 17 | 
            +
                - - ">="
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 19 | 
             
                    version: '0'
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 | 
            -
                - -  | 
| 24 | 
            +
                - - ">="
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 26 | 
             
                    version: '0'
         | 
| 27 27 | 
             
            description: |2
         | 
| @@ -34,8 +34,10 @@ executables: [] | |
| 34 34 | 
             
            extensions: []
         | 
| 35 35 | 
             
            extra_rdoc_files: []
         | 
| 36 36 | 
             
            files:
         | 
| 37 | 
            -
            - lib/that/version.rb
         | 
| 38 37 | 
             
            - lib/that.rb
         | 
| 38 | 
            +
            - lib/that/version.rb
         | 
| 39 | 
            +
            - test/dummy/README.rdoc
         | 
| 40 | 
            +
            - test/dummy/Rakefile
         | 
| 39 41 | 
             
            - test/dummy/app/assets/javascripts/application.js
         | 
| 40 42 | 
             
            - test/dummy/app/assets/stylesheets/application.css
         | 
| 41 43 | 
             
            - test/dummy/app/controllers/application_controller.rb
         | 
| @@ -44,6 +46,7 @@ files: | |
| 44 46 | 
             
            - test/dummy/bin/bundle
         | 
| 45 47 | 
             
            - test/dummy/bin/rails
         | 
| 46 48 | 
             
            - test/dummy/bin/rake
         | 
| 49 | 
            +
            - test/dummy/config.ru
         | 
| 47 50 | 
             
            - test/dummy/config/application.rb
         | 
| 48 51 | 
             
            - test/dummy/config/boot.rb
         | 
| 49 52 | 
             
            - test/dummy/config/database.yml
         | 
| @@ -60,15 +63,12 @@ files: | |
| 60 63 | 
             
            - test/dummy/config/initializers/wrap_parameters.rb
         | 
| 61 64 | 
             
            - test/dummy/config/locales/en.yml
         | 
| 62 65 | 
             
            - test/dummy/config/routes.rb
         | 
| 63 | 
            -
            - test/dummy/config.ru
         | 
| 64 66 | 
             
            - test/dummy/db/test.sqlite3
         | 
| 65 67 | 
             
            - test/dummy/log/test.log
         | 
| 66 68 | 
             
            - test/dummy/public/404.html
         | 
| 67 69 | 
             
            - test/dummy/public/422.html
         | 
| 68 70 | 
             
            - test/dummy/public/500.html
         | 
| 69 71 | 
             
            - test/dummy/public/favicon.ico
         | 
| 70 | 
            -
            - test/dummy/Rakefile
         | 
| 71 | 
            -
            - test/dummy/README.rdoc
         | 
| 72 72 | 
             
            - test/test_helper.rb
         | 
| 73 73 | 
             
            - test/that_test.rb
         | 
| 74 74 | 
             
            homepage: https://github.com/thedaniel/that
         | 
| @@ -80,17 +80,17 @@ require_paths: | |
| 80 80 | 
             
            - lib
         | 
| 81 81 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 82 82 | 
             
              requirements:
         | 
| 83 | 
            -
              - -  | 
| 83 | 
            +
              - - ">="
         | 
| 84 84 | 
             
                - !ruby/object:Gem::Version
         | 
| 85 85 | 
             
                  version: '0'
         | 
| 86 86 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 87 87 | 
             
              requirements:
         | 
| 88 | 
            -
              - -  | 
| 88 | 
            +
              - - ">="
         | 
| 89 89 | 
             
                - !ruby/object:Gem::Version
         | 
| 90 90 | 
             
                  version: '0'
         | 
| 91 91 | 
             
            requirements: []
         | 
| 92 92 | 
             
            rubyforge_project: 
         | 
| 93 | 
            -
            rubygems_version: 2. | 
| 93 | 
            +
            rubygems_version: 2.2.2
         | 
| 94 94 | 
             
            signing_key: 
         | 
| 95 95 | 
             
            specification_version: 4
         | 
| 96 96 | 
             
            summary: ActiveRecord console findey-helpey guy
         |