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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7da2641db8b7f89154f1822775ec8d236e36651f
4
- data.tar.gz: 9c51bd0f547609d06fa6542d36172f9dfc8aa680
3
+ metadata.gz: 0d4d19dd9aa4aa53ab77fbb3e956de2a2ed0f400
4
+ data.tar.gz: 8ad179c14a5499aa39ae090b5d1a8e5ccaa6924e
5
5
  SHA512:
6
- metadata.gz: 7ff59459899aa01aa6571380e614727e1d64b22e60312426ce7aa399b99eb90bb14598fb1f432edd55a6d72745456f36d3e46437ef5e7a0d3ac18fca2696b408
7
- data.tar.gz: 0ceb493a98b0c698db070b29d3781964f545bd638a7e327e3e28a0938269bbf1c5c44a9b5350fde0fc5eb68c7bcf9b3ed8ac5c02a202838562a3ff3cf9cd22b4
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
- gem 'active_record-annotate'
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
 
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Annotate
3
- VERSION = '0.1'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
@@ -7,9 +7,12 @@ module ActiveRecord
7
7
  module Annotate
8
8
  class << self
9
9
  def annotate
10
- models.each do |table_name, file_path|
10
+ models.each do |table_name, file_paths|
11
11
  annotation = Dumper.dump(table_name)
12
- Writer.write(annotation, file_path)
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
- Dir.glob(files_mask).each_with_object(Hash.new) do |path, models|
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] = path if klass < ActiveRecord::Base
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: '0.1'
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-12 00:00:00.000000000 Z
11
+ date: 2013-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails