<commit_before># ChinaRegionFu

ChinaRegionFu provide the region data of china.You will got complete chian region data after use this gem.
       

## Installation

Put 'gem china_region_fu' to your Gemfile:

    gem china_region_fu

Run bundler command to install the gem:

    bundle install

After you install the gem, you need run the generator:

    rails g china_region_fu:install
   
   It will:
   * Generate `db/migrate/<timestamp>create_china_region_tables.rb` migrate file to your app, `provinces`, `cities`, `districts` table is used for store the regions.
   * Copy regions.yml to config/ directory.
   * Run `rake db:migrate`.
   * Run `rake region:import`.

   Now you have there ActiveRecord modules: `Province`, `City`, `District`.
   
   Run with `rails g` for get generator list.

If you want to customize the region modules you can run the generator:

    rails g china_region_fu:mvc

   This will create:
   
    create  app/models/province.rb
    create  app/models/city.rb
    create  app/models/district.rb

   So you can do what you want to do in this files.
   
## Usage

#### Model

    a = Province.last
    a.name                # => "台湾省"
    a.cities.map(&:name)  # => ["嘉义市", "台南市", "新竹市", "台中市", "基隆市", "台北市"]
    
    Province.first.districts.map(&:name) # => ["延庆县", "密云县", "平谷区", ...]
    
    c = City.last
    c.name                # => "酒泉市"
    c.zip_code            # => "735000"
    c.pinyin              # => "jiuquan"
    c.pinyin_abbr         # => "jq"
    c.districts.map(&:name) # => ["敦煌市", "玉门市", "阿克塞哈萨克族自治县", "肃北蒙古族自治县", "安西县", ...]
    c.brothers.map(&:name)  # => ["甘南藏族自治州", "临夏回族自治州", "陇南市", ...]
    
#### View

    <%= form_for(@post) do |f| %>
      <div class="field">
        <%= f.label :province, '选择地区：' %><br />
        
        # FormBuilder
        # <%= f.region_select [:province, :city, :district] %>
        # <%= f.region_select [:province, :city] %>
        # <%= f.region_select [:city, :district] %>
        # <%= f.region_select [:province, :district] %>
        
        # FromHelper
        # <%= region_select :post, [:province, :city, :district] %>
        # ...
        
      </div><commit_msg>Typo fix in README.md<commit_after># ChinaRegionFu

ChinaRegionFu provide the region data of china.You will got complete chian region data after use this gem.
       

## Installation

Put 'gem china_region_fu' to your Gemfile:

    gem china_region_fu

Run bundler command to install the gem:

    bundle install

After you install the gem, you need run the generator:

    rails g china_region_fu:install
   
   It will:
   * Generate `db/migrate/<timestamp>create_china_region_tables.rb` migrate file to your app, `provinces`, `cities`, `districts` table is used for store the regions.
   * Copy regions.yml to config/ directory.
   * Run `rake db:migrate`.
   * Run `rake region:import`.

   Now you have there ActiveRecord modules: `Province`, `City`, `District`.
   
   Run with `rails g` for get generator list.

If you want to customize the region modules you can run the generator:

    rails g china_region_fu:mvc

   This will create:
   
    create  app/models/province.rb
    create  app/models/city.rb
    create  app/models/district.rb

   So you can do what you want to do in this files.
   
## Usage

#### Model

    a = Province.last
    a.name                # => "台湾省"
    a.cities.map(&:name)  # => ["嘉义市", "台南市", "新竹市", "台中市", "基隆市", "台北市"]
    
    Province.first.districts.map(&:name) # => ["延庆县", "密云县", "平谷区", ...]
    
    c = City.last
    c.name                # => "酒泉市"
    c.zip_code            # => "735000"
    c.pinyin              # => "jiuquan"
    c.pinyin_abbr         # => "jq"
    c.districts.map(&:name) # => ["敦煌市", "玉门市", "阿克塞哈萨克族自治县", "肃北蒙古族自治县", "安西县", ...]
    c.brothers.map(&:name)  # => ["甘南藏族自治州", "临夏回族自治州", "陇南市", ...]
    
#### View

    <%= form_for(@post) do |f| %>
      <div class="field">
        <%= f.label :province, '选择地区：' %><br />
        
        # FormBuilder
        # <%= f.region_select :city %>
        # <%= f.region_select [:province, :city, :district] %>
        # <%= f.region_select [:province, :city] %>
        # <%= f.region_select [:city, :district] %>
        # <%= f.region_select [:province, :district] %>
        
        # FormHelper
        # <%= region_select :post, :province %>
        # <%= region_select :post, [:province, :city, :district] %>
        # ...
        
      </div>
{'fraction_non_alphanumeric': 0.150281214848144, 'fraction_numerical': 0.0026996625421822273, 'mean_word_length': 2.3403456048084146, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2382012', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1702, 'n_words': 411}