model_discovery 0.2.4 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28350c4773c7dd720ae05262010f84e88895a40c
4
- data.tar.gz: ee68f965a61338cf5f4a780752fa9d88c90d708a
3
+ metadata.gz: 005ad7be478082d2f9f06e9bab598f3c5ff93542
4
+ data.tar.gz: 7d9b864ba556114f45c1c845d8da06c97aab4b10
5
5
  SHA512:
6
- metadata.gz: af7139fcb7efaa2bfa0ebec83fff65a42cadc3872dcc70d6d8f32d74f425a43b008898fd645af8dcbccf38f35f2cc2974c12c5406ee3391d39b8cea3ec89d752
7
- data.tar.gz: dc9aba7731436ef947fd6e88805d4e89582ed6aa537a20b48b0340f598fd1ac55b3fcb269991dc76e1c328f2ec59c854c8c2ad7c7d370564ff5e38bfe212a220
6
+ metadata.gz: 7440dad75beac5d507436f665d1d1c4ddc0c9b5cad0ef59b45c2e4d14bb7c0951cbce5f45bca03fdb90713dd7375bbc995d64ea20767fa6d84bf802f1d1a1b94
7
+ data.tar.gz: 331a63358206c663857f71cb808ee0e0cdebf92655a34aaebcb9e0f5a2137066e946f851cdcafb1ccd700ed8b8654293fdd0c0496011e3f4b57b08e3d2e1ca00
@@ -1,2 +1,12 @@
1
- class ApplicationModels < ActiveRecord::Base
1
+ # This model contains all the model names in a rails
2
+ # application
3
+ class ApplicationModels < (defined?(ActiveRecord) ? ActiveRecord::Base : Object)
4
+
5
+ if defined? Mongoid
6
+ include Mongoid::Document
7
+ include Mongoid::Timestamps
8
+
9
+ field :model, :type => String
10
+ end
11
+
2
12
  end
@@ -1,4 +1,5 @@
1
1
  require "model_discovery/engine"
2
2
  require "model_discovery/discovery"
3
+
3
4
  module ModelDiscovery
4
5
  end
@@ -1,4 +1,6 @@
1
1
  module ModelDiscovery
2
+
3
+ # Create a list of current rails application tables or documents
2
4
  def self.build_table_list
3
5
  # Get all gem by requiring them
4
6
  all_gems = Bundler.require()
@@ -15,9 +17,18 @@ module ModelDiscovery
15
17
  # Discover models in current rails app and load them
16
18
  discover Rails.root
17
19
 
18
- # Create a content type entry for all Models
19
- ActiveRecord::Base.subclasses.each do |model|
20
- ApplicationModels.find_or_create_by(model: model.to_s)
20
+ if defined? ActiveRecord
21
+ # Create a content type entry for all Models
22
+ ActiveRecord::Base.subclasses.each do |model|
23
+ ApplicationModels.find_or_create_by(model: model.to_s)
24
+ end
25
+ end
26
+
27
+ if defined? Mongoid
28
+ Mongoid.models.each do |model|
29
+ puts ">>>>>>>>>>>>>>>>>> ", model
30
+ ApplicationModels.find_or_create_by(model: model.to_s)
31
+ end
21
32
  end
22
33
  end
23
34
 
@@ -1,3 +1,3 @@
1
1
  module ModelDiscovery
2
- VERSION = "0.2.4"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_discovery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sameer Rahmani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-03 00:00:00.000000000 Z
11
+ date: 2014-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.0.2
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: 4.0.2
27
27
  - !ruby/object:Gem::Dependency
28
- name: sqlite3
28
+ name: orm_adapter
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- type: :development
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Detecting all models in a rails application (even those in gems) without
@@ -46,54 +46,54 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
+ - LICENSE
50
+ - README.md
51
+ - Rakefile
49
52
  - app/models/application_models.rb
50
53
  - config/routes.rb
51
54
  - db/migrate/20140129104940_create_application_models.rb
52
55
  - db/seeds.rb
53
- - lib/model_discovery/version.rb
56
+ - lib/model_discovery.rb
54
57
  - lib/model_discovery/discovery.rb
55
58
  - lib/model_discovery/engine.rb
59
+ - lib/model_discovery/version.rb
56
60
  - lib/tasks/model_discovery_tasks.rake
57
- - lib/model_discovery.rb
58
- - LICENSE
59
- - Rakefile
60
- - README.md
61
- - test/integration/navigation_test.rb
62
- - test/models/application_models_test.rb
63
- - test/fixtures/application_models.yml
64
- - test/model_discovery_test.rb
65
- - test/test_helper.rb
66
- - test/dummy/public/500.html
67
- - test/dummy/public/404.html
68
- - test/dummy/public/422.html
69
- - test/dummy/public/favicon.ico
70
- - test/dummy/config.ru
71
61
  - test/dummy/README.rdoc
72
- - test/dummy/app/views/layouts/application.html.erb
62
+ - test/dummy/Rakefile
73
63
  - test/dummy/app/assets/javascripts/application.js
74
64
  - test/dummy/app/assets/stylesheets/application.css
75
65
  - test/dummy/app/controllers/application_controller.rb
76
66
  - test/dummy/app/helpers/application_helper.rb
77
- - test/dummy/Rakefile
78
- - test/dummy/bin/rake
67
+ - test/dummy/app/views/layouts/application.html.erb
79
68
  - test/dummy/bin/bundle
80
69
  - test/dummy/bin/rails
70
+ - test/dummy/bin/rake
71
+ - test/dummy/config.ru
81
72
  - test/dummy/config/application.rb
82
- - test/dummy/config/environments/test.rb
73
+ - test/dummy/config/boot.rb
74
+ - test/dummy/config/database.yml
75
+ - test/dummy/config/environment.rb
83
76
  - test/dummy/config/environments/development.rb
84
77
  - test/dummy/config/environments/production.rb
85
- - test/dummy/config/routes.rb
86
- - test/dummy/config/environment.rb
87
- - test/dummy/config/database.yml
88
- - test/dummy/config/locales/en.yml
89
- - test/dummy/config/boot.rb
90
- - test/dummy/config/initializers/session_store.rb
78
+ - test/dummy/config/environments/test.rb
91
79
  - test/dummy/config/initializers/backtrace_silencers.rb
92
- - test/dummy/config/initializers/wrap_parameters.rb
93
- - test/dummy/config/initializers/inflections.rb
94
80
  - test/dummy/config/initializers/filter_parameter_logging.rb
81
+ - test/dummy/config/initializers/inflections.rb
95
82
  - test/dummy/config/initializers/mime_types.rb
96
83
  - test/dummy/config/initializers/secret_token.rb
84
+ - test/dummy/config/initializers/session_store.rb
85
+ - test/dummy/config/initializers/wrap_parameters.rb
86
+ - test/dummy/config/locales/en.yml
87
+ - test/dummy/config/routes.rb
88
+ - test/dummy/public/404.html
89
+ - test/dummy/public/422.html
90
+ - test/dummy/public/500.html
91
+ - test/dummy/public/favicon.ico
92
+ - test/fixtures/application_models.yml
93
+ - test/integration/navigation_test.rb
94
+ - test/model_discovery_test.rb
95
+ - test/models/application_models_test.rb
96
+ - test/test_helper.rb
97
97
  homepage: https://github.com/Yellowen/model_discovery
98
98
  licenses:
99
99
  - GPL-2
@@ -104,17 +104,17 @@ require_paths:
104
104
  - lib
105
105
  required_ruby_version: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - '>='
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - '>='
112
+ - - ">="
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
116
  rubyforge_project:
117
- rubygems_version: 2.0.3
117
+ rubygems_version: 2.2.0
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: A fast solution to model detection in Ruby on Rails.