physique 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTk4ZGQ1NDM0Mzc2MDY1MjljNjRhZTc5ZDg1ZjZmZjk3ZjU3MjQ1Ng==
4
+ YzZlZWQ4M2U1ZjFkNTYyZDhhNDViZWM1MmUzZjA4NDRkNWJmOGI5Mg==
5
5
  data.tar.gz: !binary |-
6
- ZTZhNGMyN2ZiMGNhMjZjYjM3MDIwZmRkMTc2NWQ0NGQ0NTY3YjVmZQ==
6
+ YWJmNTM0ZGM5OWQxMDU0ZDhmOGJhYTJmZDRlNTg3OGEyYTY2MGRjYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjQzZmI2MTY2M2I1MDZmM2E5NWZkNTJlMTBlNzNlNTY1YzQyYTFhZWEwMDU3
10
- YTgyMTA1Nzk5NWQ5ZWZlNzgxOWY4ODNlMDBmMzY4NjMyYTZlMjIxOWRkZjAx
11
- M2NjODhhOTgzMGY3OWE0M2ZhOTIxMmI1Yjk5ZDQ1OWZkYmY3YTM=
9
+ MzQxM2I4NmNiMWQ0OWU3ZDQ2ZDlkMGNhNzlmMTJmYjA3ZTkzMzdkMjMwNjQ1
10
+ Y2Q5ZDBjOGE2YzYyMDg1NWUwYTdkMjJjNDM0NTlhY2I2NmFhMGEyNGI3MzIw
11
+ ZmY5MDZmMDEwNGRhNWQ2ZGUyZTA5ZDYxYWRiMTRlM2JiNzIwNDI=
12
12
  data.tar.gz: !binary |-
13
- N2FkYTlmMThhNzEzNjhjNDA5ZGNkNTcxMTgxNTcxYmM4M2ViMDhlNWE0MTgy
14
- NjYzZWU0YTYwYjY5NjExNWE4N2U1MmQ5ZmJmNDQyOTI0ZDEyZmZiMjI1OGE0
15
- MGY3ODk4NDhmYzgxNjE4Njk4YzQ1N2EyMDk4OGIzM2Y3MDFlNWE=
13
+ NzE0ZTM4YmU2MTU5M2E1YWQyNWVhZmNlNDc1ZTA0Mjc5MGNlZjI5NGE3NGJh
14
+ MmZiM2RkNTA5YmUwMzkyYTg1OWJiZTVmMjNhNzIwMzE3M2Q3NWU2ODI1ZGYz
15
+ NDBmODVjN2NhMDNhMWM2OGMxYWQ3YmFjZTgzYjRiNTk5M2NiNmQ=
@@ -1,33 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- physique (0.3.0)
4
+ physique (0.3.1)
5
5
  activesupport (~> 4.1)
6
- albacore (= 2.0.0.rc.12)
6
+ albacore (~> 2.3)
7
7
  map (~> 6.5)
8
+ rake (~> 10)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- ProcessPilot (2.0.0.20120301)
13
- rUtilAnts (>= 1.0)
14
13
  activesupport (4.2.0)
15
14
  i18n (~> 0.7)
16
15
  json (~> 1.7, >= 1.7.7)
17
16
  minitest (~> 5.1)
18
17
  thread_safe (~> 0.3, >= 0.3.4)
19
18
  tzinfo (~> 1.1)
20
- albacore (2.0.0.rc.12)
21
- ProcessPilot (~> 2.0)
22
- facter (~> 1.7)
23
- highline (~> 1.6)
19
+ albacore (2.3.15)
24
20
  map (~> 6.5)
25
21
  nokogiri (~> 1.5)
26
- rake (> 10)
27
- semver2 (~> 3.3)
22
+ rake (~> 10)
23
+ semver2 (~> 3.4)
28
24
  diff-lcs (1.2.5)
29
- facter (1.7.6)
30
- highline (1.6.21)
31
25
  i18n (0.7.0)
32
26
  json (1.8.2)
33
27
  map (6.5.5)
@@ -35,7 +29,6 @@ GEM
35
29
  minitest (5.5.1)
36
30
  nokogiri (1.6.6.2-x86-mingw32)
37
31
  mini_portile (~> 0.6.0)
38
- rUtilAnts (2.0.0.20130827)
39
32
  rake (10.4.2)
40
33
  rspec (2.14.1)
41
34
  rspec-core (~> 2.14.0)
@@ -30,8 +30,12 @@ module Physique
30
30
  end
31
31
 
32
32
  def fluently_migrate
33
- @migrator = FluentMigratorConfig.new
34
- yield @migrator
33
+ @dbs_to_migrate = @dbs_to_migrate || []
34
+
35
+ migrator = FluentMigratorConfig.new
36
+ yield migrator
37
+
38
+ @dbs_to_migrate << migrator
35
39
  end
36
40
 
37
41
  alias_method :database, :fluently_migrate
@@ -52,9 +56,9 @@ module Physique
52
56
  nuget: @nuget && @nuget.opts,
53
57
  compile: @compilation && @compilation.opts,
54
58
  test: @tests && @tests.opts,
55
- migrator: @migrator && @migrator.opts,
59
+ fluent_migrator_dbs: @dbs_to_migrate && @dbs_to_migrate.map {|db| db.opts },
56
60
  octopus: @octopus && @octopus.opts,
57
- publish_nugets: @publish_nugets && @publish_nugets.opts,
61
+ publish_nugets: @publish_nugets && @publish_nugets.opts
58
62
  })
59
63
  end
60
64
  end
@@ -41,13 +41,13 @@ module Physique
41
41
  def add_compile_tasks
42
42
  block = lambda &method(:configure_build)
43
43
 
44
- task = build :compile => [ :restore ], &block.curry.(%w(Clean Rebuild))
45
- task.add_description 'Builds the solution'
44
+ desc 'Builds the solution'
45
+ build :compile => [ :restore ], &block.curry.(%w(Clean Rebuild))
46
46
 
47
47
  namespace :compile do
48
48
  solution.compile.targets.each do |t|
49
- task = build t.downcase, &block.curry.(t)
50
- task.add_description "Builds the solution using the #{t} target"
49
+ desc "Builds the solution using the #{t} target"
50
+ build t.downcase, &block.curry.(t)
51
51
  end
52
52
  end
53
53
  end
@@ -1,8 +1,8 @@
1
1
  module Physique
2
2
  class DefaultTasksBuilder < TasksBuilder
3
3
  def build_tasks
4
- Rake::Task.define_task :default => [ :test ]
5
- Rake::Task.define_task :ci => [ :versionizer, :test ]
4
+ task :default => [ :test ]
5
+ task :ci => [ :versionizer, :test ]
6
6
  end
7
7
  end
8
8
  end
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/string'
2
+ require 'active_support/core_ext/array'
1
3
  require 'physique/project'
2
4
 
3
5
  module Physique
@@ -12,7 +14,8 @@ module Physique
12
14
  :instance, # Server instance name
13
15
  :name, # Database name
14
16
  :scripts_dir, # Scripts folder to examine to create tasks
15
- :dialect # Dialect to use for generating SQL
17
+ :dialect, # Dialect to use for generating SQL
18
+ :task_alias # Alias used to construct rake task names
16
19
 
17
20
  def initialize
18
21
  @lang = :cs
@@ -20,135 +23,157 @@ module Physique
20
23
  end
21
24
 
22
25
  def opts
26
+ validate_config
27
+
23
28
  Map.new({
24
- exe: @exe,
25
29
  instance: @instance,
26
30
  name: @name,
27
31
  project: @project,
28
32
  project_file: Physique::Project.get_path(@project, @lang),
29
33
  lang: @lang,
34
+ task_alias: (@task_alias || @name)
30
35
  }).apply(
31
36
  lang: :cs,
32
37
  project_dir: "src/#{@project}",
33
38
  scripts_dir: "src/#{@project}/#{@scripts_dir}"
34
39
  )
35
40
  end
41
+
42
+ private
43
+
44
+ def validate_config
45
+ raise ArgumentError, 'You must specify a database instance' if @instance.blank?
46
+ raise ArgumentError, 'You must specify a database name' if @name.blank?
47
+ raise ArgumentError, 'You must specify the FluentMigrator project' if @project.blank?
48
+ raise ArgumentError, 'You must specify a language' if @lang.blank?
49
+ raise ArgumentError, 'You must specify a scripts_dir' if @scripts_dir.blank?
50
+ end
36
51
  end
37
52
 
38
53
  class FluentMigratorTasksBuilder < TasksBuilder
39
54
  def build_tasks
40
- @options = solution.migrator
41
- return if @options.nil?
55
+ dbs = solution.fluent_migrator_dbs
56
+ return if dbs.empty?
42
57
 
43
- add_script_tasks
44
- add_default_db_tasks
45
- add_migrator_tasks
46
- add_workflow_tasks
47
- add_new_migration_task
48
- end
49
-
50
- private
58
+ dbs.each do |db|
59
+ task_namespace = db_task_name(db)
51
60
 
52
- def add_script_tasks
53
- FileList["#{@options.scripts_dir}/*.sql"].each do |f|
54
61
  namespace :db do
55
- task_name = File.basename(f, '.*')
56
- task = sqlcmd task_name do |s|
57
- s.file = f
58
- s.server_name = @options.instance
59
- s.set_variable 'DATABASE_NAME', @options.name
62
+ namespace task_namespace do
63
+ # First look at the scripts_dir and add a task for every sql file that you find
64
+ defaults = default_tasks(db)
65
+ add_script_tasks db, defaults
66
+
67
+ # Then add the default minimum required tasks in case the scripts_dir didn't contain them
68
+ add_default_db_tasks db, defaults
69
+
70
+ # Add the migrate and rollback tasks
71
+ add_migrator_tasks db
72
+
73
+ # Add the tasks to create the db from scratch
74
+ add_create_tasks
75
+
76
+ # Add a task to create a new migration in the db project
77
+ add_new_migration_task db
60
78
  end
61
- task.add_description get_script_task_description(task_name, @options.scripts_dir)
62
79
  end
80
+
81
+ # Rebuild the databases when running tests
82
+ task :test => "db:#{task_namespace}:rebuild"
63
83
  end
84
+
85
+ alias_default_tasks
64
86
  end
65
87
 
66
- def add_default_db_tasks
67
- default_tasks(@options.name).each do |task_name,sql|
68
- unless Rake::Task.task_defined? "db:#{task_name.to_s}"
69
- namespace :db do
70
- task = sqlcmd task_name do |s|
71
- s.command = sql
72
- s.server_name = @options.instance
73
- s.set_variable 'DATABASE_NAME', @options.name
74
- end
75
- task.add_description get_script_task_description(task_name, @options.scripts_dir)
76
- end
88
+ private
89
+
90
+ def add_script_tasks(db, defaults)
91
+ FileList["#{db.scripts_dir}/*.sql"].each do |f|
92
+ task_name = File.basename(f, '.*')
93
+
94
+ desc get_script_task_description(defaults, task_name, db)
95
+ sqlcmd task_name do |s|
96
+ s.file = f
97
+ s.server_name = db.instance
98
+ s.set_variable 'DATABASE_NAME', db.name
77
99
  end
78
100
  end
79
101
  end
80
102
 
81
- def default_tasks(database)
82
- { create: "CREATE DATABASE #{database}",
83
- drop: "DROP DATABASE #{database}",
84
- seed: 'SELECT 1' } # This is a no-op
103
+ def get_script_task_description(defaults, task_name, db)
104
+ default_task = defaults[task_name.to_sym]
105
+ default_task ? default_task[:description] : "Executes #{task_name}.sql on #{db.name} in the #{db.scripts_dir} folder."
85
106
  end
86
107
 
87
- def get_script_task_description(task, dir)
88
- well_known_scripts[task.to_sym] || "Executes #{task}.sql in the #{dir} folder."
108
+ def add_default_db_tasks(db, defaults)
109
+ defaults.each do |task_name,task_details|
110
+ unless Rake::Task.task_defined? "db:#{db_task_name(db)}:#{task_name.to_s}"
111
+ desc task_details[:description]
112
+ sqlcmd task_name do |s|
113
+ s.command = task_details[:command]
114
+ s.server_name = db.instance
115
+ s.set_variable 'DATABASE_NAME', db.name
116
+ end
117
+ end
118
+ end
89
119
  end
90
120
 
91
- # TODO: Refactor this to combine this with default_tasks
92
- def well_known_scripts
93
- { create: 'Creates the database',
94
- drop: 'Drops the database',
95
- seed: 'Seeds the database with test data' }
121
+ def default_tasks(database)
122
+ { create: { description: 'Create the database', command: "CREATE DATABASE #{database}" },
123
+ drop: { description: 'Drop the database', command: "DROP DATABASE #{database}"},
124
+ seed: { description: 'Seed the database with test data', command: 'SELECT 1' } } # This is a no-op
96
125
  end
97
126
 
98
- def add_migrator_tasks
127
+ def add_migrator_tasks(db)
99
128
  require 'physique/tasks/fluent_migrator'
100
129
 
101
- namespace :db do
102
- build :compile_db do |b|
103
- b.target = [ 'Build' ]
104
- b.file = solution.migrator.project_file
105
- b.prop 'Configuration', solution.compile.configuration
106
- b.logging = solution.compile.logging
107
- end
130
+ build :compile_db do |b|
131
+ b.target = [ 'Build' ]
132
+ b.file = db.project_file
133
+ b.prop 'Configuration', solution.compile.configuration
134
+ b.logging = solution.compile.logging
135
+ end
108
136
 
109
- block = lambda &method(:configure_migration)
137
+ block = lambda &method(:configure_migration)
110
138
 
111
- # Migrate up
112
- task = fluent_migrator :migrate => [ :compile_db ], &block.curry.('migrate:up')
113
- task.add_description 'Migrate database to the latest version'
139
+ # Migrate up
140
+ desc 'Migrate database to the latest version'
141
+ fluent_migrator :migrate => [ :compile_db ], &block.curry.(db, 'migrate:up')
114
142
 
115
- # Migrate down
116
- task = fluent_migrator :rollback => [ :compile_db ], &block.curry.('rollback')
117
- task.add_description 'Rollback the database to the previous version'
118
- end
143
+ # Migrate down
144
+ desc 'Rollback the database to the previous version'
145
+ fluent_migrator :rollback => [ :compile_db ], &block.curry.(db, 'rollback')
146
+
147
+ # Try the migration
148
+ desc 'Migrate and then immediately rollback'
149
+ task :try => [ :migrate, :rollback ]
119
150
  end
120
151
 
121
- def configure_migration(task, config)
122
- config.instance = solution.migrator.instance
123
- config.database = solution.migrator.name
152
+ def configure_migration(db, task, config)
153
+ config.instance = db.instance
154
+ config.database = db.name
124
155
  config.task = task
125
- config.dll = migration_dll
126
- config.exe = locate_tool(tool_in_output_folder || tool_in_nuget_package)
156
+ config.dll = migration_dll db
157
+ config.exe = locate_tool(tool_in_output_folder(db) || tool_in_nuget_package)
127
158
  config.output_to_file
128
159
  end
129
160
 
130
- def add_workflow_tasks
131
- namespace :db do
132
- # Try the migration
133
- task = Rake::Task.define_task :try => [ :migrate, :rollback ]
134
- task.add_description 'Migrate and then immediately rollback'
135
-
136
- # Setup the database from nothing
137
- task = Rake::Task.define_task :setup => [ :create, :migrate, :seed ]
138
- task.add_description 'Create the database and run all migrations'
161
+ def add_create_tasks
162
+ # Setup the database from nothing
163
+ desc 'Create the database and run all migrations'
164
+ task :setup => [ :create, :migrate, :seed ]
139
165
 
140
- # Setup the database from nothing
141
- task = Rake::Task.define_task :rebuild => [ :drop, :setup ]
142
- task.add_description 'Drop and recreate the database'
143
- end
166
+ # Drop and recreate the database
167
+ desc 'Drop and recreate the database'
168
+ task :rebuild => [ :drop, :setup ]
144
169
  end
145
170
 
146
- def migration_dll
147
- "#{solution.migrator.project_dir}/bin/#{solution.compile.configuration}/#{solution.migrator.project}.dll"
171
+ def migration_dll(db)
172
+ "#{db.project_dir}/bin/#{solution.compile.configuration}/#{db.project}.dll"
148
173
  end
149
174
 
150
- def tool_in_output_folder
151
- existing_path "#{solution.migrator.project_dir}/bin/#{solution.compile.configuration}/Migrate.exe"
175
+ def tool_in_output_folder(db)
176
+ existing_path "#{db.project_dir}/bin/#{solution.compile.configuration}/Migrate.exe"
152
177
  end
153
178
 
154
179
  def tool_in_nuget_package
@@ -160,33 +185,33 @@ module Physique
160
185
  nil
161
186
  end
162
187
 
163
- def add_new_migration_task
164
- namespace :db do
165
- task = Rake::Task.define_task :new_migration, :name, :description do |t, args|
166
- name, description = args[:name], args[:description]
188
+ def db_task_name(db)
189
+ db.task_alias.downcase
190
+ end
167
191
 
168
- unless name
169
- abort [
170
- %Q{Usage: rake "#{t.name}[name[,description]]"},
171
- desc,
172
- ].join "\n\n"
173
- end
192
+ def add_new_migration_task(db)
193
+ desc 'Create a new migration file with the specified name'
194
+ task :new_migration, :name, :description do |t, args|
195
+ name, description = args[:name], args[:description]
174
196
 
175
- project, project_dir, project_file = solution.migrator.project, solution.migrator.project_dir, solution.migrator.project_file
176
- version = migration_version
177
- migration_file_name = "#{version}_#{name}.cs"
178
- migration_content = migration_template(version, name, description, project)
197
+ unless name
198
+ abort [
199
+ %Q{Usage: rake "#{t.name}[name[,description]]"},
200
+ desc,
201
+ ].join "\n\n"
202
+ end
179
203
 
180
- # Save the new migration file
181
- save_file migration_content, "#{project_dir}/Migrations/#{migration_file_name}"
204
+ # Save the new migration file
205
+ version = migration_version
206
+ migration_file_name = "#{version}_#{name}.cs"
207
+ migration_content = migration_template(version, name, description, db.project)
208
+ save_file migration_content, "#{db.project_dir}/Migrations/#{migration_file_name}"
182
209
 
183
- # Add the new migration file to the project
184
- Albacore::Project.new(project_file).tap do |p|
185
- p.add_compile_node :Migrations, migration_file_name
186
- p.save
187
- end
210
+ # Add the new migration file to the project
211
+ Albacore::Project.new(db.project_file).tap do |p|
212
+ p.add_compile_node :Migrations, migration_file_name
213
+ p.save
188
214
  end
189
- task.add_description 'Creates a new migration file with the specified name'
190
215
  end
191
216
  end
192
217
 
@@ -198,7 +223,6 @@ module Physique
198
223
  description = ", \"#{description}\"" unless description.nil?
199
224
  return <<TEMPLATE
200
225
  using FluentMigrator;
201
- using FluentMigrator.Runner;
202
226
 
203
227
  namespace #{project_name}.Migrations
204
228
  {
@@ -214,7 +238,7 @@ namespace #{project_name}.Migrations
214
238
  {
215
239
  // Add migration rollback code here
216
240
  }
217
- }
241
+ }rake install
218
242
  }
219
243
  TEMPLATE
220
244
  end
@@ -223,5 +247,27 @@ TEMPLATE
223
247
  raise "#{file_path} already exists, cancelling" if File.exists? file_path
224
248
  File.open(file_path, 'w') { |f| f.write(content) }
225
249
  end
250
+
251
+ def alias_default_tasks
252
+ Rake.application.tasks
253
+ .select {|t| t.name.starts_with?('db') && GLOBAL_TASKS.has_key?(db_command(t))}
254
+ .group_by {|t| db_command(t) }
255
+ .each do |command,tasks|
256
+ desc GLOBAL_TASKS[command]
257
+ task "db:#{command}" => tasks.map {|t| t.name }
258
+ end
259
+ end
260
+
261
+ def db_command(task)
262
+ task.name.split(':').last.to_sym
263
+ end
264
+
265
+ GLOBAL_TASKS = {
266
+ create: 'Create all databases',
267
+ drop: 'Drop all databases',
268
+ seed: 'Seed all databases with test data',
269
+ setup: 'Build all databases and migrate them to the latest version',
270
+ rebuild: 'Drop and recreate all databases',
271
+ migrate: 'Migrates all databases to the latest version' }
226
272
  end
227
273
  end
@@ -29,17 +29,17 @@ module Physique
29
29
 
30
30
  class NugetTasksBuilder < TasksBuilder
31
31
  def build_tasks
32
- add_restore
32
+ add_restore_task
33
33
  end
34
34
 
35
35
  private
36
36
 
37
- def add_restore
38
- task = nugets_restore :restore do |r|
37
+ def add_restore_task
38
+ desc 'Restores all nugets as per the packages.config files'
39
+ nugets_restore :restore do |r|
39
40
  r.out = solution.nuget.restore_location
40
41
  r.exe = solution.nuget.exe
41
42
  end
42
- task.add_description 'Restores all nugets as per the packages.config files'
43
43
  end
44
44
  end
45
45
  end
@@ -79,8 +79,10 @@ module Physique
79
79
  return if @options.nil?
80
80
  return if @options.apps.blank?
81
81
 
82
- add_octopus_package_tasks
83
- add_octopus_publish_tasks
82
+ namespace :octo do
83
+ add_octopus_package_tasks
84
+ add_octopus_publish_tasks
85
+ end
84
86
 
85
87
  if @options.alias_tasks
86
88
  add_task_aliases
@@ -91,57 +93,52 @@ module Physique
91
93
 
92
94
  def add_octopus_package_tasks
93
95
  @options.apps.each do |a|
94
- namespace :octo do
95
- namespace :package do
96
- task = octopus_pack a.name => [:versionizer, :test] do |o|
97
- ensure_output_location solution.nuget.build_location
98
-
99
- o.project_file = a.project_file
100
- o.type = a.type
101
- o.configuration = solution.compile.configuration
102
- o.exe = solution.nuget.exe
103
- o.out = solution.nuget.build_location
104
- o.metadata = a.metadata
105
- end
106
- task.add_description "Package #{a.project} for Octopus deployment"
96
+ namespace :package do
97
+ desc "Package #{a.project} for Octopus deployment"
98
+ octopus_pack a.name => [:versionizer, :test] do |o|
99
+ ensure_output_location solution.nuget.build_location
100
+
101
+ o.project_file = a.project_file
102
+ o.type = a.type
103
+ o.configuration = solution.compile.configuration
104
+ o.exe = solution.nuget.exe
105
+ o.out = solution.nuget.build_location
106
+ o.metadata = a.metadata
107
107
  end
108
-
109
- task = Rake::Task.define_task :package => all_octopus_app_tasks('package')
110
- task.add_description 'Package all applications'
111
108
  end
112
109
  end
110
+
111
+ desc 'Package all applications'
112
+ task :package => all_octopus_app_tasks('package')
113
113
  end
114
114
 
115
115
  def add_octopus_publish_tasks
116
116
  nuget = solution.nuget
117
117
 
118
118
  @options.apps.each do |a|
119
- namespace :octo do
120
- namespace :publish do
121
- task = Rake::Task.define_task a.name => [ "package:#{a.name}" ] do
122
- package_location = Albacore::Paths.normalise_slashes "#{nuget.build_location}/#{a.project}.#{a.metadata.version}.nupkg"
123
- sh "#{nuget.exe} push #{package_location} -ApiKey #{@options.api_key} -Source #{@options.server}"
124
- end
125
- task.add_description "Publish #{a.project} app to Octopus Server"
119
+ namespace :publish do
120
+ desc "Publish #{a.project} app to Octopus Server"
121
+ task a.name => [ "package:#{a.name}" ] do
122
+ package_location = Albacore::Paths.normalise_slashes "#{nuget.build_location}/#{a.project}.#{a.metadata.version}.nupkg"
123
+ sh "#{nuget.exe} push #{package_location} -ApiKey #{@options.api_key} -Source #{@options.server}"
126
124
  end
127
-
128
- task = Rake::Task.define_task :publish => all_octopus_app_tasks('publish')
129
- task.add_description 'Publish all apps to Octopus Server'
130
125
  end
131
126
  end
127
+
128
+ desc 'Publish all apps to Octopus Server'
129
+ task :publish => all_octopus_app_tasks('publish')
132
130
  end
133
131
 
134
132
  def all_octopus_app_tasks(task)
135
- # It is assumed that this is called within the octo namespace
136
133
  @options.apps.map { |a| "#{task}:#{a.name}" }
137
134
  end
138
135
 
139
136
  def add_task_aliases
140
- task = Rake::Task.define_task :package => [ 'octo:package' ]
141
- task.add_description 'Package all applications'
137
+ desc 'Package all applications'
138
+ task :package => [ 'octo:package' ]
142
139
 
143
- task = Rake::Task.define_task :publish => [ 'octo:publish' ]
144
- task.add_description 'Publish apps to Octopus Server'
140
+ desc 'Publish apps to Octopus Server'
141
+ task :publish => [ 'octo:publish' ]
145
142
  end
146
143
  end
147
144
  end
@@ -91,9 +91,11 @@ module Physique
91
91
  @options = solution.publish_nugets
92
92
  return if @options.nil?
93
93
 
94
- add_package_nugets_task
95
- add_publish_nugets_task
96
- add_publish_nugets_local_task
94
+ namespace :nuget do
95
+ add_package_nugets_task
96
+ add_publish_nugets_task
97
+ add_publish_nugets_local_task
98
+ end
97
99
 
98
100
  if @options.alias_tasks
99
101
  add_task_aliases
@@ -103,39 +105,35 @@ module Physique
103
105
  private
104
106
 
105
107
  def add_package_nugets_task
106
- namespace :nuget do
107
- task = nugets_pack :package => [ :versionizer, :test ] do |p|
108
- ensure_output_location solution.nuget.build_location
109
-
110
- p.configuration = solution.compile.configuration
111
- p.out = solution.nuget.build_location
112
- p.exe = solution.nuget.exe
113
- p.files = @options.project_files
114
- p.gen_symbols if @options.gen_symbols
115
- p.with_metadata do |m|
116
- @options.metadata.set_fields.each do |attr|
117
- eval "m.#{attr}= @options.metadata.#{attr}"
118
- end
108
+ desc 'Package all nugets'
109
+ nugets_pack :package => [ :versionizer, :test ] do |p|
110
+ ensure_output_location solution.nuget.build_location
111
+
112
+ p.configuration = solution.compile.configuration
113
+ p.out = solution.nuget.build_location
114
+ p.exe = solution.nuget.exe
115
+ p.files = @options.project_files
116
+ p.gen_symbols if @options.gen_symbols
117
+ p.with_metadata do |m|
118
+ @options.metadata.set_fields.each do |attr|
119
+ eval "m.#{attr}= @options.metadata.#{attr}"
119
120
  end
120
121
  end
121
- task.add_description 'Package all nugets'
122
122
  end
123
123
  end
124
124
 
125
125
  def add_publish_nugets_task
126
- namespace :nuget do
127
- task = Rake::Task.define_task :publish => [ 'nuget:package' ] do
128
- raise ArgumentError, 'You must specify an :api_key to connect to the server' if @options.api_key.blank?
126
+ desc 'Publish nuget packages to feed'
127
+ task :publish => [ 'nuget:package' ] do
128
+ raise ArgumentError, 'You must specify an :api_key to connect to the server' if @options.api_key.blank?
129
129
 
130
- nuget_project_names.each do |p|
131
- sh nuget_publish_command(p, 'nupkg', @options.feed_url)
130
+ nuget_project_names.each do |p|
131
+ sh nuget_publish_command(p, 'nupkg', @options.feed_url)
132
132
 
133
- if @options.gen_symbols
134
- sh nuget_publish_command(p, 'symbols.nupkg', @options.symbols_feed_url)
135
- end
133
+ if @options.gen_symbols
134
+ sh nuget_publish_command(p, 'symbols.nupkg', @options.symbols_feed_url)
136
135
  end
137
136
  end
138
- task.add_description 'Publish nuget packages to feed'
139
137
  end
140
138
  end
141
139
 
@@ -146,13 +144,11 @@ module Physique
146
144
  def add_publish_nugets_local_task
147
145
  local_path = @options.local_path
148
146
 
149
- namespace :nuget do
150
- namespace :publish do
151
- task = Rake::Task.define_task :local => [ 'nuget:package' ] do
152
- ensure_output_location local_path
153
- FileUtils.cp FileList["#{solution.nuget.build_location}/*"], local_path
154
- end
155
- task.add_description 'Copy nuget packages to local path'
147
+ namespace :publish do
148
+ desc 'Copy nuget packages to local path'
149
+ task :local => [ 'nuget:package' ] do
150
+ ensure_output_location local_path
151
+ FileUtils.cp FileList["#{solution.nuget.build_location}/*"], local_path
156
152
  end
157
153
  end
158
154
  end
@@ -162,11 +158,11 @@ module Physique
162
158
  end
163
159
 
164
160
  def add_task_aliases
165
- task = Rake::Task.define_task :package => [ 'nuget:package' ]
166
- task.add_description 'Package all nugets'
161
+ desc 'Package all nugets'
162
+ task :package => [ 'nuget:package' ]
167
163
 
168
- task = Rake::Task.define_task :publish => [ 'nuget:publish' ]
169
- task.add_description 'Publish nuget packages to feed'
164
+ desc 'Publish nuget packages to feed'
165
+ task :publish => [ 'nuget:publish' ]
170
166
  end
171
167
  end
172
168
  end
@@ -25,19 +25,13 @@ module Physique
25
25
  configuration = solution.compile.configuration
26
26
  package_dir = solution.nuget.restore_location
27
27
 
28
- task = test_runner :test => test_dependencies do |tests|
28
+ desc 'Run unit tests'
29
+ test_runner :test => :compile do |tests|
29
30
  tests.files = FileList["**/*.Tests/bin/#{configuration}/*.Tests.dll"]
30
31
  tests.exe = locate_tool("#{package_dir}/NUnit.Runners.*/tools/nunit-console.exe")
31
32
  tests.parameters.add('/labels')
32
33
  tests.parameters.add('/trace=Verbose')
33
34
  end
34
- task.add_description 'Run unit tests'
35
- end
36
-
37
- def test_dependencies
38
- dependencies = [ :compile ]
39
- dependencies << 'db:rebuild' unless solution.migrator.nil?
40
- dependencies
41
35
  end
42
36
  end
43
37
  end
@@ -1,9 +1,11 @@
1
+ require 'rake/dsl_definition'
1
2
  require 'physique/dsl'
2
3
  require 'physique/tool_locator'
3
4
 
4
5
  module Physique
5
6
  class TasksBuilder
6
7
  include Albacore::Logging
8
+ include Rake::DSL
7
9
  include Physique::DSL
8
10
  include Physique::ToolLocator
9
11
 
@@ -19,10 +19,10 @@ module Physique
19
19
  # FileList only correctly handles forward-slashes, even on Windows
20
20
  paths = paths.gsub('\\', '/')
21
21
 
22
- info { "Extracting paths from the following pattern #{paths}" }
22
+ debug { "Extracting paths from the following pattern #{paths}" }
23
23
  paths = FileList[paths] unless paths.respond_to?(:each)
24
24
 
25
- info { "Attempting to locate tool in the following paths #{paths}" }
25
+ debug { "Attempting to locate tool in the following paths #{paths}" }
26
26
  opts = Map.options(options)
27
27
  opts = opts.apply :find_latest => true
28
28
  paths = paths.collect { |p| which(p) }.compact.sort
@@ -1,3 +1,3 @@
1
1
  module Physique
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -20,7 +20,8 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency 'bundler'
22
22
  spec.add_development_dependency 'rspec', '2.14.1'
23
+ spec.add_dependency 'rake', '~> 10'
23
24
  spec.add_dependency 'activesupport', '~> 4.1'
24
25
  spec.add_dependency 'map', '~> 6.5'
25
- spec.add_dependency 'albacore', '2.0.0.rc.12'
26
+ spec.add_dependency 'albacore', '~> 2.3'
26
27
  end
@@ -0,0 +1,42 @@
1
+ require 'physique'
2
+
3
+ describe Physique::FluentMigratorConfig do
4
+
5
+ it 'should throw when config is missing required values' do
6
+ %w(instance= name= project= lang= scripts_dir=).each do |p|
7
+ expect {
8
+ default_config do |c|
9
+ c.send p, nil
10
+ end
11
+ }.to raise_error(ArgumentError)
12
+ end
13
+ end
14
+
15
+ it 'should default to the cs programming language' do
16
+ project_name = 'Test.Database'
17
+ opts = default_config do |c|
18
+ c.project = 'Test.Database'
19
+ end
20
+ expect(opts.project_file).to eq("src/#{project_name}/#{project_name}.csproj")
21
+ end
22
+
23
+ it 'should find full project path when specifying the name and language' do
24
+ project_name = 'Test.Database'
25
+ opts = default_config do |c|
26
+ c.lang = :vb
27
+ end
28
+
29
+ expect(opts.project_file).to eq("src/#{project_name}/#{project_name}.vbproj")
30
+ end
31
+
32
+ def default_config
33
+ config = Physique::FluentMigratorConfig.new.tap do |c|
34
+ c.instance = '(local)'
35
+ c.name = 'TestDatabase'
36
+ c.project = 'Test.Database'
37
+
38
+ yield c if block_given?
39
+ end
40
+ config.opts
41
+ end
42
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: physique
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Scaduto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-11 00:00:00.000000000 Z
11
+ date: 2015-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.14.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '10'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: activesupport
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,16 +84,16 @@ dependencies:
70
84
  name: albacore
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - '='
87
+ - - ~>
74
88
  - !ruby/object:Gem::Version
75
- version: 2.0.0.rc.12
89
+ version: '2.3'
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - '='
94
+ - - ~>
81
95
  - !ruby/object:Gem::Version
82
- version: 2.0.0.rc.12
96
+ version: '2.3'
83
97
  description: Beautiful builds for .NET projects
84
98
  email:
85
99
  - rscaduto@thirdwave.it
@@ -113,7 +127,7 @@ files:
113
127
  - lib/physique/tool_locator.rb
114
128
  - lib/physique/version.rb
115
129
  - physique.gemspec
116
- - spec/config_spec.rb
130
+ - spec/fluent_migrator_config_spec.rb
117
131
  - spec/project_spec.rb
118
132
  - spec/publish_nugets_spec.rb
119
133
  - spec/solution_spec.rb
@@ -148,7 +162,7 @@ specification_version: 4
148
162
  summary: A conventional build framework supporting NUnit, FluentMigrator and Octopus
149
163
  Deploy
150
164
  test_files:
151
- - spec/config_spec.rb
165
+ - spec/fluent_migrator_config_spec.rb
152
166
  - spec/project_spec.rb
153
167
  - spec/publish_nugets_spec.rb
154
168
  - spec/solution_spec.rb
@@ -1,22 +0,0 @@
1
- require 'physique'
2
-
3
- describe Physique::FluentMigratorConfig do
4
- it 'should find full project path when specifying the name and language' do
5
- project_name = 'Test.Database'
6
- opts = Physique::FluentMigratorConfig.new.tap { |c|
7
- c.project = project_name
8
- c.lang = :vb
9
- }.opts
10
-
11
- expect(opts.project_file).to eq("src/#{project_name}/#{project_name}.vbproj")
12
- end
13
-
14
- it 'should default to the cs programming language' do
15
- project_name = 'Test.Database'
16
- opts = Physique::FluentMigratorConfig.new.tap { |c|
17
- c.project = project_name
18
- }.opts
19
-
20
- expect(opts.project_file).to eq("src/#{project_name}/#{project_name}.csproj")
21
- end
22
- end