GitHub PullRequestReviewCommentEvent at 2014-01-03 21:44:34
Repository: sow
Actor: efatsi
Payload: {"comment":{"url":"https://api.github.com/repos/vigetlabs/sow/pulls/comments/8645918","id":8645918,"diff_hunk":"@@ -1,15 +1,90 @@\n #Sow\n \n-##Seed Files\n-Seed files are unique to the environment in which your Rails application is running. Within `db/seeds` create an environment-specific directory and seed file (e.g. `development.rb` & `/development` for your 'development' environment). The seed file will be evaluated just like a normal seed file. You're not required to use any Sow fanciness, and Sow directives can be mixed and mashed with plain old Ruby.\n+[![Code Climate](https://codeclimate.com/github/vigetlabs/sow.png)](https://codeclimate.com/github/vigetlabs/sow)\n+\n+Seed Rails application by convention, not configuration.\n+\n+Provides support for common files types: *csv*, *yaml*, and *json*.  Extensible for the rest!\n+\n \n ##The Sow Directive\n-Within your seed file, you can use the `sow` directive to initiate Sow's powerful auto-seeding. A simple directive might look like this.\n+\n+Within your seed file, you can use the `sow` directive to initiate Sow's dark magicks. A simple directive might look like this.\n+\n ```ruby\n+# seeds.rb\n+\n+include Sow::Helpers\n+\n sow [User, Post, Comment]\n ```\n \n-This directive tells sow to go find your datafiles for the `User`, `Post`, and `Comment` seed resources, build records from the data entries, and insert them into the database. Sow will automatically detect known datafile types like `.yml`, `.json`, or `.csv` within your environment-specific seed directory. But if all your data is in `.wat` files, fear not. You can tell Sow where to look for your data, and point it toward a custom parser class for turning your data into records. The example below tells Sow to read `User` seed data from a Google Spreadsheet, and parse it accordingly.\n+This directive tells sow to go find your datafiles for the `User`, `Post`, and `Comment` seed resources, build records from the data entries, and insert them into the database. Sow will automatically detect known datafile types like `.yml`, `.json`, or `.csv` within your environment-specific seed directory.\n+\n+\n+##Environment\n+\n+Seed files are unique to the environment in which your Rails application is running. Within `db/seeds` create an environment-specific directory (i.e. `/development` for your 'development' environment).\n+\n+Todo: [Support for shared seed files]\n+\n+\n+##Seed files\n+\n+Hang your seed definitions on a `records` key for *csv* and *json* files.\n+\n+Examples:\n+\n+```yaml\n+# users.yml\n+\n+records:\n+  - sow_id: 1\n+    first_name: 'Lawson'\n+    last_name: 'Kurtz'\n+    username: 'lawdawg'\n+  - sow_id: 2\n+    first_name: 'Ryan'\n+    last_name: 'Foster'\n+    username: 'mc_rubs'\n+```\n+\n+```json\n+// posts.json\n+\n+{\n+  \"records\":[\n+    {\n+      \"sow_id\":1,\n+      \"title\":\"Json title\",\n+      \"content\":\"Json content\"\n+    },\n+    {\n+      \"sow_id\":2,\n+      \"title\":\"Headline\",\n+      \"content\":\"Words about things\"\n+    }\n+  ]\n+}\n+```\n+\n+Each seed record needs a `sow_id` defined that must be *unique across all seed files*.  It can be an integer, string, whatever you prefer; as long as it is unique, Sow can sort your seeds for insertion and detect any cyclic relationships.","path":"README.md","position":75,"original_position":75,"commit_id":"ca38c70f162b3cd1a6045c62a90e7aba15895a99","original_commit_id":"ca38c70f162b3cd1a6045c62a90e7aba15895a99","user":{"login":"efatsi","id":1410181,"avatar_url":"https://gravatar.com/avatar/d36d659354005cd2b9d7a9a66da1c947?d=https%3A%2F%2Fidenticons.github.com%2F02266f28817252af91b76bc5f804ae51.png&r=x","gravatar_id":"d36d659354005cd2b9d7a9a66da1c947","url":"https://api.github.com/users/efatsi","html_url":"https://github.com/efatsi","followers_url":"https://api.github.com/users/efatsi/followers","following_url":"https://api.github.com/users/efatsi/following{/other_user}","gists_url":"https://api.github.com/users/efatsi/gists{/gist_id}","starred_url":"https://api.github.com/users/efatsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/efatsi/subscriptions","organizations_url":"https://api.github.com/users/efatsi/orgs","repos_url":"https://api.github.com/users/efatsi/repos","events_url":"https://api.github.com/users/efatsi/events{/privacy}","received_events_url":"https://api.github.com/users/efatsi/received_events","type":"User","site_admin":false},"body":"`*unique across all seed files*`, does this mean that if something is `seed_id: 1` in one file, the first thing in another file can't have `seed_id: 1`?","created_at":"2014-01-03T21:44:34Z","updated_at":"2014-01-03T21:44:34Z","html_url":"https://github.com/vigetlabs/sow/pull/6#discussion_r8645918","pull_request_url":"https://api.github.com/repos/vigetlabs/sow/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/vigetlabs/sow/pulls/comments/8645918"},"html":{"href":"https://github.com/vigetlabs/sow/pull/6#discussion_r8645918"},"pull_request":{"href":"https://api.github.com/repos/vigetlabs/sow/pulls/6"}}}}