scv 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in scv.gemspec
4
+ gemspec
data/MIT-LICENCE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2011 Dmitriy Kiriyenko
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ **"SCV ready to go, sir!"** -- *some scv*.
2
+
3
+ A set of thor scripts with most general tasks to administer Rails applications.
4
+
5
+ ## Installation ##
6
+
7
+ Into Gemfile:
8
+
9
+ ```ruby
10
+ gem 'scv', :group => 'development', :require => false
11
+ ```
12
+
13
+ ## Usage ##
14
+
15
+ ### scv config ###
16
+
17
+ It's a common pattern, especially for open source projects not to keep development configuration files in version control, keeping their example versions instead. The most common is config/database.yml.example. While I'm going to support this patten in future, I currently suggest another one, which is keeping all example configuration files in config/examples, which structure repeats config directory. For support of this patter there is a setup:config script in this set. Run
18
+
19
+ ```shell
20
+ scv config
21
+ ```
22
+
23
+ to copy all example configuration files to their natural locations. You may use `--force`, `--skip`, `--quiet` and `--pretend` options as with usual Rails generators. If you append any of the file names with `.tt` it will be considered as template, evaluated and placed to the right place without `.tt`.
24
+
25
+ ### scv db ###
26
+
27
+ Pretty often you need to create a database, tune it's schema to current and load seeds after checking out a new application. I advice you to use a
28
+
29
+ ```shell
30
+ scv db
31
+ ```
32
+
33
+ for it. Available modificators are:
34
+
35
+ * `--drop` or `-d` - drop database before creation. Defaults to false.
36
+ * `--migrate` or `-m` - force running migrations. By default scv will run `db:schema:load` if `db/schema.rb` is present, `db:migrate` otherwise.
37
+ * `--no-seeds` - don't run `db:seed`
38
+
39
+ The `no-` options are also available with `--skip` prefix as usual (e.g., `--skip-test-clone`)
40
+
41
+ ### scv populate ###
42
+
43
+ Again, pretty often you need to populate database with a test data, needed for development. I suggest a solution when near `db/seeds.rb` file you place `db/populate.rb` with the similar purpose and content, but containing data you'd like to insert to database for development. If you do so, you may use
44
+
45
+ ```shell
46
+ scv populate
47
+ ```
48
+
49
+ to clean the database, load `seeds.rb` and `populate.rb` without dropping the database. There is an option `--no-truncate` to prevent database cleanup, that is used from meta tasks like `bootstrap` or `reset`.
50
+
51
+ ### scv bootstrap ###
52
+
53
+ `scv bootstrap` should be used after initial checkout of application. It does `scv config --force`, then `scv db --no-seed` (because `scv populate` is expected to be run), and then, yeah, `scv populate --no-truncate`.
54
+
55
+ ### scv reset ###
56
+
57
+ In the meantime, `scv reset` should be used when you wish to reset your database. It does `scv db --drop --no-seed`, then `scv populate --no-truncate`. This command can also be executed by just running `scv db`.
58
+
59
+ ## How it looks ##
60
+
61
+ [![Space Construction Vehicle](http://i.minus.com/iXECZqiT0Ab7h.jpeg)](http://eu.battle.net/sc2/en/game/unit/scv)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/scv ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'rubygems'
4
+ require 'lib/scv/cli'
5
+ SCV::CLI.start
data/lib/scv.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "scv/version"
2
+
3
+ module SCV
4
+ # Your code goes here...
5
+ end
data/lib/scv/cli.rb ADDED
@@ -0,0 +1,72 @@
1
+ require 'thor'
2
+ require 'rails/generators/actions'
3
+ require 'database_cleaner'
4
+
5
+ module SCV
6
+ class CLI < ::Thor
7
+ include Thor::Actions
8
+ include Rails::Generators::Actions
9
+ add_runtime_options!
10
+
11
+ default_task(:reset)
12
+
13
+ desc "bootstrap", "Initially sets up the application"
14
+ method_option :migrate, :type => :boolean, :default => false, :aliases => '-m'
15
+ def bootstrap
16
+ invoke :config, [], :force => true
17
+ invoke :db, [], :seed => false, :migrate => options.migrate?
18
+ invoke :populate, :truncate => false
19
+ end
20
+
21
+ desc "reset", "Drops and recreates the database with test data"
22
+ method_option :migrate, :type => :boolean, :default => false, :aliases => '-m'
23
+ def reset
24
+ invoke :db, [], :drop => true, :seed => false, :migrate => options.migrate?
25
+ invoke :populate, [], :truncate => false
26
+ end
27
+
28
+ desc "config [--force] [--quiet] [--pretend] [--skip]", "copy example configuration files to config directory"
29
+ def config
30
+ source_paths.push(destination_root = ".")
31
+ directory("config/examples", "config")
32
+ end
33
+
34
+ desc "db", "initialize db and load schema"
35
+ method_option :drop, :type => :boolean, :default => false, :aliases => '-d'
36
+ method_option :migrate, :type => :boolean, :default => false, :aliases => '-m'
37
+ method_option :seed, :type => :boolean, :default => true, :aliases => '-s'
38
+ def db
39
+ remove_file("db/schema.rb") if options.migrate?
40
+ rake([].tap do |commands|
41
+ commands.push "db:drop" if options.drop?
42
+ commands.push "db:create"
43
+ commands.push File.exists?("db/schema.rb") ? "db:schema:load" : "db:migrate"
44
+ commands.push "db:seed" if options.seed?
45
+ commands.push "db:test:clone"
46
+ end.join(" "))
47
+ end
48
+
49
+ desc "populate", "populate database with test data"
50
+ method_option :truncate, :type => :boolean, :default => true, :aliases => "-t"
51
+ def populate
52
+ log :load, "environment"
53
+ require './config/environment'
54
+
55
+ if options.truncate?
56
+ log :truncate, "database"
57
+ DatabaseCleaner.clean_with(:truncation)
58
+ end
59
+ load_seed_file("db/seeds.rb")
60
+ load_seed_file("db/populate.rb")
61
+ end
62
+
63
+ private
64
+
65
+ def load_seed_file(file)
66
+ if File.exist?(file)
67
+ log :load, file
68
+ load(file)
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,3 @@
1
+ module SCV
2
+ VERSION = "0.0.1"
3
+ end
data/scv.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "scv/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "scv"
7
+ s.version = SCV::VERSION
8
+ s.authors = ["Dmitriy Kiriyenko"]
9
+ s.email = ["dmitriy.kiriyenko@anahoret.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{A set of thor scripts to manage rails application basic tasks}
12
+ s.description = %q{A set of thor scripts to manage rails application basic tasks.
13
+ Such as managing local configuration files, dropping, creating
14
+ and populating db, etc.}
15
+
16
+ s.rubyforge_project = "scv"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_development_dependency "rake"
24
+
25
+ s.add_runtime_dependency "thor"
26
+ s.add_runtime_dependency "database_cleaner"
27
+ s.add_runtime_dependency "railties"
28
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dmitriy Kiriyenko
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-18 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &2157794600 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2157794600
25
+ - !ruby/object:Gem::Dependency
26
+ name: thor
27
+ requirement: &2157794180 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2157794180
36
+ - !ruby/object:Gem::Dependency
37
+ name: database_cleaner
38
+ requirement: &2157793760 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2157793760
47
+ - !ruby/object:Gem::Dependency
48
+ name: railties
49
+ requirement: &2157793340 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *2157793340
58
+ description: ! "A set of thor scripts to manage rails application basic tasks.\n Such
59
+ as managing local configuration files, dropping, creating\n and
60
+ populating db, etc."
61
+ email:
62
+ - dmitriy.kiriyenko@anahoret.com
63
+ executables:
64
+ - scv
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - .gitignore
69
+ - Gemfile
70
+ - MIT-LICENCE
71
+ - README.md
72
+ - Rakefile
73
+ - bin/scv
74
+ - lib/scv.rb
75
+ - lib/scv/cli.rb
76
+ - lib/scv/version.rb
77
+ - scv.gemspec
78
+ homepage: ''
79
+ licenses: []
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project: scv
98
+ rubygems_version: 1.8.6
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: A set of thor scripts to manage rails application basic tasks
102
+ test_files: []