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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/that.rb +27 -23
  3. data/lib/that/version.rb +1 -1
  4. metadata +11 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7b98e5b07ad8210eff1eb06e075c8b399b61036
4
- data.tar.gz: f9ce67eca9050227806605d724365b209192e21d
3
+ metadata.gz: b1df6248ff21363b9ce23e511b05eedf65b9ad28
4
+ data.tar.gz: 2d456df2236048c88349839793a6888f65f65c16
5
5
  SHA512:
6
- metadata.gz: df72f38ae9e35323954a5022263136893356122ffaf7f3bbfffad2f837ace41d33cc115ba961f96a218d76ee6e2f204fe598e2ef798412c99a2d1ec8ee7a0934
7
- data.tar.gz: f53b7b38054893e78c850cfe12be826678c9e86fbbfb8707dd85c1c231c31574daad3398d9b4257d4148b2857c09c25ee07d2bff6a57f7dc2708cdee7a4274f6
6
+ metadata.gz: 24730c1b2128c59f63f56dd902e2638c5a7830fc26884fe8977c3896a267c204ff880c7bb6bb0a7246732dbe28fd70cd2aefe7230bcd9d4cd1e1dc038672c106
7
+ data.tar.gz: ae597ef35546d661884aaf929928e14df1e2485bc7e3ec3344daf6858e42f7b145e372b02f94c6313ad9d9158c7fd88473a307060d1965052df4858491a07a35
@@ -1,31 +1,35 @@
1
1
  module That
2
- DEFAULT_TO_THAT_KEYS = [:name, :login, :email]
3
- def that(query)
4
- query = query.to_s
5
- # Make sure all models are loaded
6
- Rails.application.eager_load!
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
- # Find out what symbols are AR subclasses
9
- models = Module.constants.collect do |constant_name|
10
- constant = eval(constant_name.to_s)
11
- if not constant.nil? and constant.is_a? Class and constant.superclass == ActiveRecord::Base
12
- constant
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
- end
15
- models.compact!
16
+ models.compact!
16
17
 
17
- results = []
18
- # Query everything!
19
- models.each do |model|
20
- keys = model.respond_to?(:to_that) ? model.to_that : DEFAULT_TO_THAT_KEYS
21
- keys.each do |key|
22
- results += model.where(key => query) if model.column_names.include?(key.to_s)
23
- end
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
- results.length == 1 ? results.first : results
29
+ alias_method :dat, :that
27
30
  end
28
- alias_method :dat, :that
29
- end
30
31
 
31
- Object.send(:include, That) # lol
32
+ def self.activate
33
+ Object.send(:include, That::Core) # lol
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module That
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
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.1
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-05-19 00:00:00.000000000 Z
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.0.3
93
+ rubygems_version: 2.2.2
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: ActiveRecord console findey-helpey guy