dtf 0.3.3 → 0.3.5
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.
- data/Rakefile +11 -0
- data/lib/dtf.rb +27 -1
- data/lib/dtf/version.rb +1 -1
- data/lib/tasks/setup.thor +45 -31
- metadata +2 -2
data/Rakefile
CHANGED
@@ -26,3 +26,14 @@ end
|
|
26
26
|
task :spec do
|
27
27
|
Rake::Task['cover_me:report'].invoke
|
28
28
|
end
|
29
|
+
|
30
|
+
namespace :dtf do
|
31
|
+
|
32
|
+
desc "Install DTF thor tasks"
|
33
|
+
task :install do
|
34
|
+
require 'dtf'
|
35
|
+
puts "Installing DTF tasks"
|
36
|
+
FileUtils.cp(Dir.glob("#{File.join("#{Gem.loaded_specs['dtf'].gem_dir}", 'lib/tasks/*')}"), 'lib/tasks/')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
data/lib/dtf.rb
CHANGED
@@ -14,6 +14,28 @@ module Dtf
|
|
14
14
|
puts "Please see 'dtf -h' for the list of recognized commands."
|
15
15
|
end
|
16
16
|
|
17
|
+
# Copies thor tasks into any project which require's dtf
|
18
|
+
# e.g bundle exec dtf setup
|
19
|
+
class SetupDtf
|
20
|
+
def initialize(cmd_name, options)
|
21
|
+
@cmd_name = cmd_name
|
22
|
+
@cmd_opts = options
|
23
|
+
end
|
24
|
+
|
25
|
+
def execute
|
26
|
+
if "#{Gem.loaded_specs['dtf'].gem_dir}" == "#{Dir.pwd}"
|
27
|
+
$stderr.puts "Copying files over themselves is not usually good. Aborting!"
|
28
|
+
abort()
|
29
|
+
elsif ! File.exists?("#{Dir.pwd}/lib/tasks/setup.thor")
|
30
|
+
puts "Installing DTF tasks"
|
31
|
+
FileUtils.cp(Dir.glob("#{File.join("#{Gem.loaded_specs['dtf'].gem_dir}", 'lib/tasks/*')}"), "#{Dir.pwd}/lib/tasks/")
|
32
|
+
else
|
33
|
+
$stderr.puts "Copying files over themselves is not usually good. Aborting!"
|
34
|
+
abort()
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
17
39
|
# This sub-command is used to add a User to the Test Framework system
|
18
40
|
#
|
19
41
|
# Required Parameters are:
|
@@ -201,7 +223,7 @@ module Dtf
|
|
201
223
|
# It also doubles as DTF's help system.
|
202
224
|
class OptionsParser
|
203
225
|
# List of all sub-commands known within the Help System
|
204
|
-
SUB_COMMANDS = %w(create_user delete_user create_vs delete_vs)
|
226
|
+
SUB_COMMANDS = %w(create_user delete_user create_vs delete_vs setup)
|
205
227
|
|
206
228
|
# ARGV parsing method and options builder. Method depends on Trollop gem.
|
207
229
|
#
|
@@ -253,6 +275,10 @@ module Dtf
|
|
253
275
|
opt(:user_name, desc="Username of VS owner - REQUIRED", opts={:type => :string, :short => '-u'})
|
254
276
|
opt(:id, desc="ID of VS to be deleted - REQUIRED", opts={:type => :int, :short => '-i'})
|
255
277
|
end
|
278
|
+
when "setup_dtf"
|
279
|
+
Trollop::options do
|
280
|
+
opt(:install, desc="Defines if should install or not", opts={:type => :flag, :default => true})
|
281
|
+
end
|
256
282
|
when nil
|
257
283
|
Trollop::die "No command specified! Please specify an applicable command"
|
258
284
|
else
|
data/lib/dtf/version.rb
CHANGED
data/lib/tasks/setup.thor
CHANGED
@@ -1,54 +1,68 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
class DtfSetup < Thor
|
4
|
-
|
5
|
-
desc "install", "Installs database migrations
|
4
|
+
|
5
|
+
desc "install", "Installs DTF core database migrations"
|
6
6
|
method_options :force => :boolean
|
7
7
|
def install(name= "*")
|
8
8
|
puts "Installing db migrations, main schema, and config files"
|
9
|
-
|
9
|
+
|
10
10
|
# The gem is installed elsewhere so the copy path needs to be
|
11
|
-
# relative to the gem, not the user.
|
12
|
-
|
11
|
+
# relative to the gem, not the user. Gem.loaded_specs['dtf'].gemdir
|
12
|
+
# tells us where the DTF master gem lives and we need to build up the from location
|
13
|
+
# based off that, then copy locally relative to the user.
|
14
|
+
#
|
15
|
+
# Migrations
|
16
|
+
from_dir = "#{File.join("#{Gem.loaded_specs['dtf'].gem_dir}", 'db/migrate')}"
|
17
|
+
# Add schema.rb and seeds to list of additional files to be pushed
|
18
|
+
other_files = ["#{from_dir}/../schema.rb", "#{from_dir}/../seeds.rb"]
|
19
|
+
|
20
|
+
other_files.each do |source|
|
21
|
+
puts "Generating db/#{File.basename(source)}"
|
22
|
+
FileUtils.cp(source, "#{Dir.pwd}/db/#{File.basename(source)}" )
|
23
|
+
end
|
13
24
|
|
14
|
-
Dir["#{
|
25
|
+
Dir["#{from_dir}/#{name}"].each do |source|
|
15
26
|
|
16
27
|
# Use File.basename to remove the gem's path info so we can
|
17
28
|
# use just the filename to copy relative to the user.
|
18
|
-
destination = "db/migrate/#{File.basename(source)}"
|
29
|
+
destination = "#{Dir.pwd}/db/migrate/#{File.basename(source)}"
|
19
30
|
|
20
|
-
FileUtils.rm(destination) if options[:force] && File.exist?(destination)
|
21
|
-
if File.
|
22
|
-
puts "
|
31
|
+
FileUtils.rm(destination) if options[:force] && File.exist?(destination) && File.file?(destination)
|
32
|
+
if File.directory?(destination)
|
33
|
+
puts "Oops, db/migrate/#{File.basename(destination)} is a directory. Skipping!"
|
34
|
+
elsif File.exist?(destination)
|
35
|
+
puts "Skipping db/migrate/#{File.basename(destination)} because it already exists"
|
23
36
|
else
|
24
|
-
puts "Generating
|
37
|
+
puts "Generating db/migrate/#{File.basename(destination)}"
|
25
38
|
FileUtils.cp(source, destination)
|
26
39
|
end
|
27
40
|
end
|
41
|
+
puts "Don't forget to run 'rake db:setup' next! Run 'rake db:drop:all' first, if your databases already exist."
|
28
42
|
end
|
29
43
|
|
30
|
-
|
44
|
+
# dtf_setup:config is added to make sure you can copy the *config* without having to recopy
|
45
|
+
# the migrations and schema as well.
|
46
|
+
desc "config [NAME]", "Copy db configuration"
|
31
47
|
method_options :force => :boolean
|
32
|
-
def config(name = "
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
48
|
+
def config(name = "config.yml")
|
49
|
+
|
50
|
+
from_dir = "#{Gem.loaded_specs['dtf'].gem_dir}"
|
51
|
+
|
52
|
+
# Use File.basename to remove the gem's path info so we can
|
53
|
+
# use just the filename to copy relative to the user.
|
54
|
+
destination = "#{Dir.pwd}/db/#{name}"
|
39
55
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
puts "Generating #{destination}"
|
49
|
-
FileUtils.cp(source, destination)
|
50
|
-
end
|
56
|
+
FileUtils.rm(destination) if options[:force] && File.exist?(destination) && File.file?(destination)
|
57
|
+
if File.directory?(destination)
|
58
|
+
puts "Oops, db/#{File.basename(destination)} is a directory. Ignoring!"
|
59
|
+
elsif File.exist?(destination)
|
60
|
+
puts "Skipping db/#{File.basename(destination)} because it already exists"
|
61
|
+
else
|
62
|
+
puts "Generating db/#{File.basename(destination)}"
|
63
|
+
FileUtils.cp("#{from_dir}/db/#{name}", destination)
|
51
64
|
end
|
65
|
+
puts "Don't forget to run 'rake db:setup' next! Run 'rake db:drop:all' first, if your databases already exist."
|
52
66
|
end
|
53
67
|
|
54
|
-
end
|
68
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|