phil_columns 0.2.0 → 0.3.0

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: 8f2e5f91da147995e312530fb811dc3ff34871c3
4
- data.tar.gz: a8ed23b4ce9daecc5365212c0abb315c3183a7ae
3
+ metadata.gz: d789fc3c03e3480119e3beff9827ade6e9a1400f
4
+ data.tar.gz: 247007881ff42be0a715b6d880beefda0ced5baa
5
5
  SHA512:
6
- metadata.gz: ee4bf29e129c603dd4b7e72c4d32832f785a682a2ad98bf4aa76654fefdb57aef7015acc70a350c0287961c826f74d6e158343005d02cc8f707a16b69e61a352
7
- data.tar.gz: 03f90d08be6e33b587e49494ebf1959f5668cba01e2a17c3d72b10b5ac1a705db86a3f9a7e8919fd6e0fa21c2c47f32f7557d8fdeff98d3e5115ba55f9f6b728
6
+ metadata.gz: 6979d9a76ee6a732e66ccb95e2c4fa13d427908b6eb65f23d826aa28e9bea165e07c088b7f6898ec8578f8152260930ba5755bab6264e93faf3d33eb50127683
7
+ data.tar.gz: c965c6209b0dbed143f66e50915ba72b6424f3eb43b4218f8e50b2912a40e185f8efe47e79bae46627829ca2a75ce9f615df8db4678181e9230ecfa5af03cc6d
data/README.md CHANGED
@@ -244,16 +244,19 @@ To specify a seed for production, simply add production to the specified environ
244
244
 
245
245
  ### The Configuration File
246
246
 
247
- The configuration file is in YAML format.
247
+ The configuration file is in YAML format. The following configuraiton file is the default configuration for a Rails project.
248
248
 
249
249
  ---
250
250
  default_tags:
251
251
  - default
252
252
  env_files:
253
253
  - config/environment
254
+ - config/phil_columns
254
255
  schema_load_strategy: load
255
256
  schema_unload_strategy: drop
256
257
  seeds_path: db/seeds
258
+ skip_tables_on_purge:
259
+ - ncite_fake_vetting_responses
257
260
 
258
261
  #### Configuration Attributes
259
262
 
@@ -279,8 +282,65 @@ the environment file(s) from a framework, such as Rails.
279
282
 
280
283
  [String] The relative path to the seeds directory.
281
284
 
285
+ ##### skip_tables_on_purge
286
+
287
+ [String] A list of tables to skip when purging.
288
+
289
+
290
+ ### DRYing Seeds Up
291
+
292
+ #### Rails Project
293
+
294
+ As your seed set grows you will certainly have opportunities to DRY up your seeds with utility methods, etc. The best way to accomplish this is to add
295
+ code to the config/phil_columns.rb (Rails specific). One possibility is to define modules to use as mix-ins to the seeds.
296
+
297
+ # Add any Phil Columns only configuration in this file
298
+
299
+ Rails.logger.level = Logger::WARN #minimize log output during seeding
300
+
301
+ module ThingHelper
302
+ def create_thing( name )
303
+ Thing.create! name: name
304
+ end
305
+ end
306
+
307
+ To use the code in a seed simply include the module.
308
+
309
+ class AddThings < PhilColumns::Seed
310
+ include ThingHelper
311
+
312
+ def up
313
+ create_thing( 'toy' )
314
+ end
315
+ end
316
+
317
+ #### Plain-Old Ruby Project
318
+
319
+ The same concepts applied above to a Rails project apply to a Ruby project. The only difference is specifying an environment file in the configuration
320
+ file: .phil\_columns. The env_files attribute takes an array of files to load. Simply provide a relative path to the file from the project root and place
321
+ the common code into one or more files.
322
+
323
+ ---
324
+ ...
325
+ env_files:
326
+ - some/environment/file
327
+ - another/environment/file
328
+ ...
329
+
330
+
331
+ ### The Console
332
+
333
+ Phil columns has a built in console that loads up the seeding environment and any helpers defined in the Seeds module.
334
+
335
+ $ phil-columns console
336
+
282
337
 
283
338
  ## Adapters and Extensions
284
339
 
285
340
  * [phil_columns-activerecord](https://github.com/midas/phil_columns-activerecord)
286
341
  * [phil_columns-factory_girl](https://github.com/midas/phil_columns-factory_girl)
342
+
343
+
344
+ ## Contributors
345
+
346
+ * Nils Jonsson [njonsson](https://github.com/njonsson)
@@ -53,6 +53,15 @@ module PhilColumns
53
53
  version is not included in the set.)
54
54
  end
55
55
 
56
+ desc "console", "Load a console with seeding assets available"
57
+ long_desc <<-LONGDESC
58
+ #{env_option_description}
59
+ LONGDESC
60
+ env_option
61
+ def console
62
+ execute PhilColumns::Command::Console
63
+ end
64
+
56
65
  desc "purge", "Purge all data from tables"
57
66
  long_desc <<-LONGDESC
58
67
  Purges all tables excluding any project metadata tables, ie. schema_migrations when using ActiveRecord.
@@ -2,6 +2,7 @@ module PhilColumns
2
2
  module Command
3
3
 
4
4
  autoload :Base, 'phil_columns/command/base'
5
+ autoload :Console, 'phil_columns/command/console'
5
6
  autoload :Generate, 'phil_columns/command/generate'
6
7
  autoload :Generator, 'phil_columns/command/generator'
7
8
  autoload :Install, 'phil_columns/command/install'
@@ -0,0 +1,29 @@
1
+ module PhilColumns
2
+ module Command
3
+ class Console < Base
4
+
5
+ def execute
6
+ load_environment
7
+ load_seed_helpers
8
+ start_console
9
+ end
10
+
11
+ protected
12
+
13
+ def start_console
14
+ require 'irb'
15
+ IRB.start
16
+ end
17
+
18
+ def load_seed_helpers
19
+ if defined?( Seeds )
20
+ Seeds::constants.each do |const_name|
21
+ konstant = Seeds::const_get(const_name)
22
+ Object.send( :include, konstant )
23
+ end
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module PhilColumns
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phil_columns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JC. ason Harrelson (midas)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-30 00:00:00.000000000 Z
11
+ date: 2014-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -151,6 +151,7 @@ files:
151
151
  - lib/phil_columns/cli/reset.rb
152
152
  - lib/phil_columns/command.rb
153
153
  - lib/phil_columns/command/base.rb
154
+ - lib/phil_columns/command/console.rb
154
155
  - lib/phil_columns/command/generate.rb
155
156
  - lib/phil_columns/command/generate/seed.rb
156
157
  - lib/phil_columns/command/generator.rb