aam 0.0.5 → 0.0.8
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/README.org +5 -5
- data/examples/0100_example.rb +12 -12
- data/lib/aam/annotation.rb +2 -1
- data/lib/aam/version.rb +1 -1
- metadata +1 -2
- data/experiment/000_example.rb +0 -121
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f5d090a2014c41a0f27f5e0064b048ece5ffac5df27541f4f15e2cc4c955f72c
         | 
| 4 | 
            +
              data.tar.gz: 745cf9b2abbb273c17d47e6b4134e39dd8d32f2189d6e5792bfb6ee04d120fac
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1f740c88a8435abfd5e42b5e717b53cf84fbf8f14f125dfa77a6af151a0b53344afdb1f6b0940e932d59c1cc0a7f4d4add43e2069f0efdd91a27329a411f8ef7
         | 
| 7 | 
            +
              data.tar.gz: 4366e42568f1663aa99cd673c3c6203514d68f3b265e19c1006e2afddc1e6205e8aa155df2ddb453d5e0402a2b1dc4db1dc647069a2f3c4974f813746255d1ae
         | 
    
        data/README.org
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 | 
            -
            *  | 
| 1 | 
            +
            * Advanced Annotate Models
         | 
| 2 2 |  | 
| 3 | 
            -
            **  | 
| 3 | 
            +
            ** How to use
         | 
| 4 4 |  | 
| 5 5 | 
             
            #+BEGIN_SRC shell
         | 
| 6 6 | 
             
            $ rake aam  
         | 
| 7 7 | 
             
            #+END_SRC
         | 
| 8 8 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 9 | 
            +
            This will create column information in related files.
         | 
| 10 | 
            +
            Embed warnings if there are no indexes in places you need.
         | 
| 11 11 |  | 
| 12 | 
            -
            **  | 
| 12 | 
            +
            ** Examples of using alone
         | 
| 13 13 |  | 
| 14 14 | 
             
            #+BEGIN_SRC ruby
         | 
| 15 15 | 
             
            ActiveRecord::Schema.define do
         | 
    
        data/examples/0100_example.rb
    CHANGED
    
    | @@ -58,25 +58,25 @@ puts Aam::SchemaInfoGenerator.new(SubArticle).generate | |
| 58 58 | 
             
            # >> #
         | 
| 59 59 | 
             
            # >> # Userテーブル (users as User)
         | 
| 60 60 | 
             
            # >> #
         | 
| 61 | 
            -
            # >> #  | 
| 61 | 
            +
            # >> # |----------+------+---------+-------------+------+-------|
         | 
| 62 62 | 
             
            # >> # | カラム名 | 意味 | タイプ  | 属性        | 参照 | INDEX |
         | 
| 63 | 
            -
            # >> #  | 
| 63 | 
            +
            # >> # |----------+------+---------+-------------+------+-------|
         | 
| 64 64 | 
             
            # >> # | id       | Id   | integer | NOT NULL PK |      |       |
         | 
| 65 65 | 
             
            # >> # | name     | Name | string  |             |      | A!    |
         | 
| 66 66 | 
             
            # >> # | flag     | Flag | boolean | DEFAULT(f)  |      |       |
         | 
| 67 | 
            -
            # >> #  | 
| 67 | 
            +
            # >> # |----------+------+---------+-------------+------+-------|
         | 
| 68 68 | 
             
            # >> # == Schema Information ==
         | 
| 69 69 | 
             
            # >> #
         | 
| 70 70 | 
             
            # >> # Articleテーブル (articles as Article)
         | 
| 71 71 | 
             
            # >> #
         | 
| 72 | 
            -
            # >> #  | 
| 72 | 
            +
            # >> # |----------+----------+---------+-------------+-----------------------+-------|
         | 
| 73 73 | 
             
            # >> # | カラム名 | 意味     | タイプ  | 属性        | 参照                  | INDEX |
         | 
| 74 | 
            -
            # >> #  | 
| 74 | 
            +
            # >> # |----------+----------+---------+-------------+-----------------------+-------|
         | 
| 75 75 | 
             
            # >> # | id       | Id       | integer | NOT NULL PK |                       |       |
         | 
| 76 76 | 
             
            # >> # | user_id  | ユーザー | integer |             | => User#id            | A     |
         | 
| 77 77 | 
             
            # >> # | foo_type | Foo type | string  |             | モデル名(polymorphic) |       |
         | 
| 78 78 | 
             
            # >> # | foo_id   | Foo      | integer |             | => (foo_type)#id      |       |
         | 
| 79 | 
            -
            # >> #  | 
| 79 | 
            +
            # >> # |----------+----------+---------+-------------+-----------------------+-------|
         | 
| 80 80 | 
             
            # >> #
         | 
| 81 81 | 
             
            # >> #- 備考 -------------------------------------------------------------------------
         | 
| 82 82 | 
             
            # >> # ・Article モデルは User モデルから has_many :articles されています。
         | 
| @@ -86,24 +86,24 @@ puts Aam::SchemaInfoGenerator.new(SubArticle).generate | |
| 86 86 | 
             
            # >> #
         | 
| 87 87 | 
             
            # >> # Blogテーブル (blogs as Blog)
         | 
| 88 88 | 
             
            # >> #
         | 
| 89 | 
            -
            # >> #  | 
| 89 | 
            +
            # >> # |----------+------+---------+-------------+------+-------|
         | 
| 90 90 | 
             
            # >> # | カラム名 | 意味 | タイプ  | 属性        | 参照 | INDEX |
         | 
| 91 | 
            -
            # >> #  | 
| 91 | 
            +
            # >> # |----------+------+---------+-------------+------+-------|
         | 
| 92 92 | 
             
            # >> # | id       | Id   | integer | NOT NULL PK |      |       |
         | 
| 93 93 | 
             
            # >> # | name     | Name | string  |             |      |       |
         | 
| 94 | 
            -
            # >> #  | 
| 94 | 
            +
            # >> # |----------+------+---------+-------------+------+-------|
         | 
| 95 95 | 
             
            # >> # == Schema Information ==
         | 
| 96 96 | 
             
            # >> #
         | 
| 97 97 | 
             
            # >> # なんとかテーブル (articles as SubArticle)
         | 
| 98 98 | 
             
            # >> #
         | 
| 99 | 
            -
            # >> #  | 
| 99 | 
            +
            # >> # |----------+----------+---------+-------------+--------------------------------------+-------|
         | 
| 100 100 | 
             
            # >> # | カラム名 | 意味     | タイプ  | 属性        | 参照                                 | INDEX |
         | 
| 101 | 
            -
            # >> #  | 
| 101 | 
            +
            # >> # |----------+----------+---------+-------------+--------------------------------------+-------|
         | 
| 102 102 | 
             
            # >> # | id       | Id       | integer | NOT NULL PK |                                      |       |
         | 
| 103 103 | 
             
            # >> # | user_id  | ユーザー | integer |             | => User#id                           | A     |
         | 
| 104 104 | 
             
            # >> # | foo_type | Foo type | string  |             | モデル名(polymorphic)                |       |
         | 
| 105 105 | 
             
            # >> # | foo_id   | Foo      | integer |             | :blog => Blog#id と => (foo_type)#id |       |
         | 
| 106 | 
            -
            # >> #  | 
| 106 | 
            +
            # >> # |----------+----------+---------+-------------+--------------------------------------+-------|
         | 
| 107 107 | 
             
            # >> #
         | 
| 108 108 | 
             
            # >> #- 備考 -------------------------------------------------------------------------
         | 
| 109 109 | 
             
            # >> # ・SubArticle モデルは User モデルから has_many :articles されています。
         | 
    
        data/lib/aam/annotation.rb
    CHANGED
    
    | @@ -39,6 +39,7 @@ module Aam | |
| 39 39 | 
             
                      @counts[:error] += 1
         | 
| 40 40 | 
             
                    end
         | 
| 41 41 | 
             
                  end
         | 
| 42 | 
            +
                  puts
         | 
| 42 43 | 
             
                  puts "#{@counts[:success]} success, #{@counts[:skip]} skip, #{@counts[:error]} errors"
         | 
| 43 44 | 
             
                end
         | 
| 44 45 |  | 
| @@ -74,7 +75,7 @@ module Aam | |
| 74 75 | 
             
                  end
         | 
| 75 76 |  | 
| 76 77 | 
             
                  def write_to_relation_files
         | 
| 77 | 
            -
                    puts " | 
| 78 | 
            +
                    puts ""
         | 
| 78 79 | 
             
                    puts "--> #{@klass}"
         | 
| 79 80 | 
             
                    target_files = search_paths.collect {|search_path|
         | 
| 80 81 | 
             
                      v = Pathname.glob((@base.root_dir + search_path).expand_path)
         | 
    
        data/lib/aam/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: aam
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.8
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - akicho8
         | 
| @@ -137,7 +137,6 @@ files: | |
| 137 137 | 
             
            - Rakefile
         | 
| 138 138 | 
             
            - aam.gemspec
         | 
| 139 139 | 
             
            - examples/0100_example.rb
         | 
| 140 | 
            -
            - experiment/000_example.rb
         | 
| 141 140 | 
             
            - lib/aam.rb
         | 
| 142 141 | 
             
            - lib/aam/annotation.rb
         | 
| 143 142 | 
             
            - lib/aam/railtie.rb
         | 
    
        data/experiment/000_example.rb
    DELETED
    
    | @@ -1,121 +0,0 @@ | |
| 1 | 
            -
            $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
         | 
| 2 | 
            -
            require "aam"
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
         | 
| 5 | 
            -
            ActiveRecord::Schema.define do
         | 
| 6 | 
            -
              suppress_messages do
         | 
| 7 | 
            -
                create_table(:users) do |t|
         | 
| 8 | 
            -
                  t.string :name, :limit => 32
         | 
| 9 | 
            -
                  t.boolean :flag, :default => false
         | 
| 10 | 
            -
                end
         | 
| 11 | 
            -
                add_index :users, :name, :unique => true
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                create_table(:articles) do |t|
         | 
| 14 | 
            -
                  t.belongs_to :user, :index => false
         | 
| 15 | 
            -
                  t.belongs_to :xxx, :polymorphic => true, :index => false
         | 
| 16 | 
            -
                end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                create_table(:blogs) do |t|
         | 
| 19 | 
            -
                  t.string :name
         | 
| 20 | 
            -
                end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                create_table(:foos) do |t|
         | 
| 23 | 
            -
                  t.belongs_to :user, :index => false
         | 
| 24 | 
            -
                  t.belongs_to :xxx, :polymorphic => true, :index => false
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
            end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
            class User < ActiveRecord::Base
         | 
| 30 | 
            -
              has_many :articles
         | 
| 31 | 
            -
              has_one :article, :as => :xxx
         | 
| 32 | 
            -
            end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
            class Article < ActiveRecord::Base
         | 
| 35 | 
            -
              belongs_to :user
         | 
| 36 | 
            -
              belongs_to :xxx, :polymorphic => true
         | 
| 37 | 
            -
            end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
            class Blog < ActiveRecord::Base
         | 
| 40 | 
            -
              has_many :sub_articles, :foreign_key => :xxx_id
         | 
| 41 | 
            -
            end
         | 
| 42 | 
            -
             | 
| 43 | 
            -
            class SubArticle < Article
         | 
| 44 | 
            -
              belongs_to :blog, :class_name => "Blog", :foreign_key => :xxx_id
         | 
| 45 | 
            -
            end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
            class Foo < ActiveRecord::Base
         | 
| 48 | 
            -
            end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
            Aam.logger = nil
         | 
| 51 | 
            -
            puts Aam::SchemaInfoGenerator.new(User).generate
         | 
| 52 | 
            -
            puts Aam::SchemaInfoGenerator.new(Article).generate
         | 
| 53 | 
            -
            puts Aam::SchemaInfoGenerator.new(SubArticle).generate
         | 
| 54 | 
            -
            puts Aam::SchemaInfoGenerator.new(Foo).generate
         | 
| 55 | 
            -
            # >> # == Schema Information ==
         | 
| 56 | 
            -
            # >> #
         | 
| 57 | 
            -
            # >> # Userテーブル (users as User)
         | 
| 58 | 
            -
            # >> #
         | 
| 59 | 
            -
            # >> # |----------+------+------------+-------------+------+-------|
         | 
| 60 | 
            -
            # >> # | カラム名 | 意味 | タイプ     | 属性        | 参照 | INDEX |
         | 
| 61 | 
            -
            # >> # |----------+------+------------+-------------+------+-------|
         | 
| 62 | 
            -
            # >> # | id       | Id   | integer    | NOT NULL PK |      |       |
         | 
| 63 | 
            -
            # >> # | name     | Name | string(32) |             |      | A!    |
         | 
| 64 | 
            -
            # >> # | flag     | Flag | boolean    | DEFAULT(f)  |      |       |
         | 
| 65 | 
            -
            # >> # |----------+------+------------+-------------+------+-------|
         | 
| 66 | 
            -
            # >> # == Schema Information ==
         | 
| 67 | 
            -
            # >> #
         | 
| 68 | 
            -
            # >> # Articleテーブル (articles as Article)
         | 
| 69 | 
            -
            # >> #
         | 
| 70 | 
            -
            # >> # |----------+----------+---------+-------------+-----------------------+-------|
         | 
| 71 | 
            -
            # >> # | カラム名 | 意味     | タイプ  | 属性        | 参照                  | INDEX |
         | 
| 72 | 
            -
            # >> # |----------+----------+---------+-------------+-----------------------+-------|
         | 
| 73 | 
            -
            # >> # | id       | Id       | integer | NOT NULL PK |                       |       |
         | 
| 74 | 
            -
            # >> # | user_id  | User     | integer |             | => User#id            |       |
         | 
| 75 | 
            -
            # >> # | xxx_type | Xxx type | string  |             | モデル名(polymorphic) |       |
         | 
| 76 | 
            -
            # >> # | xxx_id   | Xxx      | integer |             | => (xxx_type)#id      |       |
         | 
| 77 | 
            -
            # >> # |----------+----------+---------+-------------+-----------------------+-------|
         | 
| 78 | 
            -
            # >> #
         | 
| 79 | 
            -
            # >> #- 備考 -------------------------------------------------------------------------
         | 
| 80 | 
            -
            # >> # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, :user_id を追加してください
         | 
| 81 | 
            -
            # >> # ・Article モデルは User モデルから has_many :articles されています。
         | 
| 82 | 
            -
            # >> # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, [:xxx_id, :xxx_type] を追加してください
         | 
| 83 | 
            -
            # >> #--------------------------------------------------------------------------------
         | 
| 84 | 
            -
            # >> # == Schema Information ==
         | 
| 85 | 
            -
            # >> #
         | 
| 86 | 
            -
            # >> # Sub articleテーブル (articles as SubArticle)
         | 
| 87 | 
            -
            # >> #
         | 
| 88 | 
            -
            # >> # |----------+----------+---------+-------------+--------------------------------------+-------|
         | 
| 89 | 
            -
            # >> # | カラム名 | 意味     | タイプ  | 属性        | 参照                                 | INDEX |
         | 
| 90 | 
            -
            # >> # |----------+----------+---------+-------------+--------------------------------------+-------|
         | 
| 91 | 
            -
            # >> # | id       | Id       | integer | NOT NULL PK |                                      |       |
         | 
| 92 | 
            -
            # >> # | user_id  | User     | integer |             | => User#id                           |       |
         | 
| 93 | 
            -
            # >> # | xxx_type | Xxx type | string  |             | モデル名(polymorphic)                |       |
         | 
| 94 | 
            -
            # >> # | xxx_id   | Xxx      | integer |             | :blog => Blog#id と => (xxx_type)#id |       |
         | 
| 95 | 
            -
            # >> # |----------+----------+---------+-------------+--------------------------------------+-------|
         | 
| 96 | 
            -
            # >> #
         | 
| 97 | 
            -
            # >> #- 備考 -------------------------------------------------------------------------
         | 
| 98 | 
            -
            # >> # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, :user_id を追加してください
         | 
| 99 | 
            -
            # >> # ・SubArticle モデルは User モデルから has_many :articles されています。
         | 
| 100 | 
            -
            # >> # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, [:xxx_id, :xxx_type] を追加してください
         | 
| 101 | 
            -
            # >> # ・SubArticle モデルは Blog モデルから has_many :sub_articles, :foreign_key => :xxx_id されています。
         | 
| 102 | 
            -
            # >> #--------------------------------------------------------------------------------
         | 
| 103 | 
            -
            # >> # == Schema Information ==
         | 
| 104 | 
            -
            # >> #
         | 
| 105 | 
            -
            # >> # Fooテーブル (foos as Foo)
         | 
| 106 | 
            -
            # >> #
         | 
| 107 | 
            -
            # >> # |----------+----------+---------+-------------+------+-------|
         | 
| 108 | 
            -
            # >> # | カラム名 | 意味     | タイプ  | 属性        | 参照 | INDEX |
         | 
| 109 | 
            -
            # >> # |----------+----------+---------+-------------+------+-------|
         | 
| 110 | 
            -
            # >> # | id       | Id       | integer | NOT NULL PK |      |       |
         | 
| 111 | 
            -
            # >> # | user_id  | User     | integer |             |      |       |
         | 
| 112 | 
            -
            # >> # | xxx_type | Xxx type | string  |             |      |       |
         | 
| 113 | 
            -
            # >> # | xxx_id   | Xxx      | integer |             |      |       |
         | 
| 114 | 
            -
            # >> # |----------+----------+---------+-------------+------+-------|
         | 
| 115 | 
            -
            # >> #
         | 
| 116 | 
            -
            # >> #- 備考 -------------------------------------------------------------------------
         | 
| 117 | 
            -
            # >> # ・【警告:インデックス欠如】create_foos マイグレーションに add_index :foos, :user_id を追加してください
         | 
| 118 | 
            -
            # >> # ・【警告】Foo モデルに belongs_to :user を追加してください
         | 
| 119 | 
            -
            # >> # ・【警告:インデックス欠如】create_foos マイグレーションに add_index :foos, [:xxx_id, :xxx_type] を追加してください
         | 
| 120 | 
            -
            # >> # ・【警告】Foo モデルに belongs_to :xxx, :polymorphic => true を追加してください
         | 
| 121 | 
            -
            # >> #--------------------------------------------------------------------------------
         |