active_record-annotate 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/active_record/annotate/version.rb +1 -1
- data/lib/active_record/annotate.rb +11 -4
- 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: 0d4d19dd9aa4aa53ab77fbb3e956de2a2ed0f400
|
4
|
+
data.tar.gz: 8ad179c14a5499aa39ae090b5d1a8e5ccaa6924e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b584d252701c53b7153e3977825e95722902edd654ef0eb1a5fd02a093ecdc00c2276b182b338252cba9f37727384ac7f0c8b0df128c3abacfaef9155862adaf
|
7
|
+
data.tar.gz: 1efd1c3364ae8dfe5f7758e6d7aba2d39b71f11e7a9fdb9544ab397260c35bbcaac90655d9dea94817bf848a9ce0d0f2835f885819a660cce503103280f12584
|
data/README.md
CHANGED
@@ -8,7 +8,9 @@ Trivial.
|
|
8
8
|
|
9
9
|
``` ruby
|
10
10
|
# Gemfile
|
11
|
-
|
11
|
+
group :development do
|
12
|
+
gem 'active_record-annotate'
|
13
|
+
end
|
12
14
|
```
|
13
15
|
|
14
16
|
``` sh
|
@@ -41,6 +43,7 @@ class Document < ActiveRecord::Base
|
|
41
43
|
* Cover everything with tests
|
42
44
|
* Write YARD docs
|
43
45
|
* Add some means to configure the annotation process (annotation format, a place to put it)
|
46
|
+
* Try to add auto-annotation after `db:migrate`
|
44
47
|
|
45
48
|
## Contributing
|
46
49
|
|
@@ -7,9 +7,12 @@ module ActiveRecord
|
|
7
7
|
module Annotate
|
8
8
|
class << self
|
9
9
|
def annotate
|
10
|
-
models.each do |table_name,
|
10
|
+
models.each do |table_name, file_paths|
|
11
11
|
annotation = Dumper.dump(table_name)
|
12
|
-
|
12
|
+
|
13
|
+
file_paths.each do |path|
|
14
|
+
Writer.write(annotation, path)
|
15
|
+
end
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
@@ -17,7 +20,11 @@ module ActiveRecord
|
|
17
20
|
models_dir = Rails.root.join('app/models')
|
18
21
|
files_mask = models_dir.join('**', '*.rb')
|
19
22
|
|
20
|
-
|
23
|
+
hash_with_arrays = Hash.new do |hash, key|
|
24
|
+
hash[key] = []
|
25
|
+
end
|
26
|
+
|
27
|
+
Dir.glob(files_mask).each_with_object(hash_with_arrays) do |path, models|
|
21
28
|
# .../app/models/car/hatchback.rb -> car/hatchback
|
22
29
|
short_path = path.sub(models_dir.to_s + '/', '').sub(/\.rb$/, '')
|
23
30
|
# skip any app/models/concerns files
|
@@ -26,7 +33,7 @@ module ActiveRecord
|
|
26
33
|
# car/hatchback -> Car::Hatchback
|
27
34
|
klass = short_path.camelize.constantize
|
28
35
|
# collect only AR::Base descendants
|
29
|
-
models[klass.table_name]
|
36
|
+
models[klass.table_name] << path if klass < ActiveRecord::Base
|
30
37
|
end
|
31
38
|
end
|
32
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-annotate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vsevolod Romashov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|