bozo-scripts 0.5.1 → 0.6.0

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWE5NjQ0YjQ3ZDU1ZmMxYWZkMWFmOTc5YzliNWM5YWFmZTdjMTljYg==
4
+ NWM1NGNlOTgzNTVjZmM3NzkyMjE1YjZkODkyYmFkMzQwMDI4YmNlZQ==
5
5
  data.tar.gz: !binary |-
6
- NTU5ZmU1MjE5YmFkODg1ZmI4Nzk0MmFiYzY2ZWJmNmNkOTEyY2NjOQ==
6
+ OTJiODk1OWFmN2JkYjI0YjIxMGI3YTFiM2EwZWY1ZGM3NGUxMGRkMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Njk2YjAyZjM5MjU4MTcwYWMwYWQ3YTU1MjI4MjhkZmNhOTI2YjcxNDY1ZmJl
10
- MzgyNTg5MmYzODJiYjc5Y2ZlNmQwZjE0OThkMWEzODQ4OTRhMDg5MTc2ODNl
11
- Y2QxYjg2ODc2NmU0N2QyMjQxMWNmMjYxMmY3ZDRhZWVhMjljNTE=
9
+ OTZhOTk2M2UxYmVhYjgzMDE3N2FlMWMzNzRjMGRkMzQxZTA0YmViZWZkNTlh
10
+ MTYyMzBmY2RjZTBhZTY0OTMxNDZlMzRlYjAwMjdlNzU0YzRlZGIyZDkyYjRh
11
+ ZTgyMmQ0NmI2NjkwNDI0MjdjNzQzZGY2OWRkMzFmY2U5NDk4MmQ=
12
12
  data.tar.gz: !binary |-
13
- N2IzZWU5NzlmYmM1ZDE0NDYyNTJjN2Y1N2ExMjJlNWQ3ZDU1MTc1YjdhODRl
14
- MGRmZTRlNTRiZDg5YTNmMDNkYzI5ZmU4ZmZmNDc0NmUzNmU2ZWJkNzBlNDQ0
15
- ZGY4NjIyOWVhMzY5ODE3ZjViNjY1MmZkN2IxOGNiMDdlZDlmNmM=
13
+ NDY2Y2NiYTgyNzY0ODE0Y2FlYmYyMzBhOGQzM2RlY2U5YWZiMDRkNGY0NGFh
14
+ ODEwMzFkMjM4NWEwZDFlNWVjMWM2YWUyYWRhZjg0MGQzYWYyNzQwNmMwZTA5
15
+ MDg2NWQzNWRhNjRjOWI1YTk0ZWQ2ODQ1N2VkZWM1NzMyZjk0OWM=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.6.0
@@ -16,7 +16,7 @@ module Bozo::Hooks
16
16
  program_files_path = ENV['ProgramFiles(x86)']
17
17
  end
18
18
 
19
- File.join(program_files_path, 'Microsoft Fxcop 10.0', 'FxCopCmd.exe') unless program_files_path.nil?
19
+ File.join(program_files_path, 'Microsoft Fxcop 10.0', 'fxcopcmd.exe') unless program_files_path.nil?
20
20
  end
21
21
 
22
22
  def initialize
@@ -52,8 +52,8 @@ module Bozo::Hooks
52
52
  def post_compile
53
53
  config = config_with_defaults
54
54
 
55
- raise no_executable_path_specified if config[:path].nil?
56
- raise no_executable_exists unless File.exists?(config[:path])
55
+ raise no_executable_path_specified if path.nil?
56
+ raise no_executable_exists unless File.exists?(path)
57
57
 
58
58
  if config[:project].nil?
59
59
  execute_projects config
@@ -80,11 +80,11 @@ module Bozo::Hooks
80
80
  # @param [Hash] config
81
81
  # The fxcop configuration
82
82
  def execute_projects(config)
83
- log_debug "Executing projects with '#{config[:path]}'" if config[:framework_versions].any?
83
+ log_debug "Executing projects with '#{path}'" if config[:framework_versions].any?
84
84
 
85
85
  config[:framework_versions].each do |framework_version|
86
86
  args = []
87
- args << '"' + config[:path] + '"'
87
+ args << '"' + path + '"'
88
88
  args << "/out:#{output_path}\\#{Time.now.to_i}-#{framework_version}-FxCop-report.xml"
89
89
  args << "/types:" + config[:types].join(',') unless config[:types].empty?
90
90
 
@@ -108,16 +108,12 @@ module Bozo::Hooks
108
108
  def execute_fxcop_project(config)
109
109
  log_debug "Executing fxcop project '#{config[:project]}' with '#{path}'"
110
110
 
111
- output_file = File.join(out_path, File.basename(config[:project], '.*') + '-FxCop-report.xml' )
112
-
113
111
  args = []
114
- args << '"' + config[:path] + '"'
115
- args << "/out:\"#{output_file}\""
112
+ args << '"' + path + '"'
113
+ args << "/out:\"#{output_path}\\#{File.basename(config[:project], '.*')}-FxCop-report.xml\""
116
114
  args << "/project:\"#{config[:project]}\""
117
115
  args << "/types:" + config[:types].join(',') unless config[:types].empty?
118
116
 
119
- FileUtils.mkdir_p(output_path)
120
-
121
117
  execute_command :fx_cop, args
122
118
  end
123
119
 
@@ -0,0 +1,72 @@
1
+ module Bozo::Preparers
2
+
3
+ # Executes a sql script
4
+ #
5
+ # == Hook configuration
6
+ #
7
+ # prepare :sql_server do |t|
8
+ # t.variable 'DatabaseName', 'MyDatabase'
9
+ # t.variable 'MySecondVariable', 'HelloWorld'
10
+ # t.script 'my/specific/script.sql' # must be a specific file
11
+ # t.connection_string { |c| c[:config_value] } # a function taking the configuration as an argument
12
+ # end
13
+ #
14
+ # The variables are accessible via `$(KEY)` in the sql script.
15
+ class SqlServer
16
+
17
+ def execute
18
+ configuration = load_config
19
+
20
+ execute_command :sqlcmd, generate_args(configuration)
21
+ end
22
+
23
+ def variable(key, value)
24
+ @variables ||= {}
25
+ @variables[key] = value
26
+ end
27
+
28
+ def script(value)
29
+ @script = value
30
+ end
31
+
32
+ def connection_string(&value)
33
+ @connection_string = value
34
+ end
35
+
36
+ private
37
+
38
+ def generate_args(configuration)
39
+ connection_string = @connection_string.call(configuration)
40
+
41
+ if connection_string.nil? || connection_string.length == 0
42
+ raise Exception.new('No connection string specified')
43
+ end
44
+
45
+ args = []
46
+ args << 'sqlcmd'
47
+ args << "-S #{connection_string}"
48
+ args << "-i #{@script}"
49
+ @variables.each do |key, value|
50
+ args << "-v #{key}=#{value}"
51
+ end
52
+
53
+ args
54
+ end
55
+
56
+ def load_config
57
+ default_files = ['default.rb', "#{environment}.rb"]
58
+ default_files << "#{env['MACHINENAME']}.rb" if env['MACHINENAME']
59
+
60
+ configuration = Bozo::Configuration.new
61
+
62
+ default_files.each do |file|
63
+ path = File.join('config', file)
64
+ configuration.load path if File.exist? path
65
+ end
66
+
67
+ configuration
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,93 @@
1
+ module Bozo::Preparers
2
+
3
+ # Executes a sql script
4
+ #
5
+ # == Hook configuration
6
+ #
7
+ # prepare :sql_server do |t|
8
+ # t.variable 'DatabaseName', 'MyDatabase'
9
+ # t.variable 'MySecondVariable', 'HelloWorld'
10
+ # t.script 'my/specific/script.sql' # must be a specific file
11
+ # t.connection_string { |c| c[:config_value] } # a function taking the configuration as an argument
12
+ # end
13
+ #
14
+ # The variables are accessible via `$(KEY)` in the sql script.
15
+ class SqlServer
16
+
17
+ def execute
18
+ configuration = load_config
19
+
20
+ execute_command :sqlcmd, generate_args(configuration)
21
+ end
22
+
23
+ def variable(key, value)
24
+ @variables ||= {}
25
+ @variables[key] = value
26
+ end
27
+
28
+ def script(value)
29
+ @script = value
30
+ end
31
+
32
+ def database_name(name)
33
+ @database_name = name
34
+ end
35
+
36
+ def connection_string(&value)
37
+ @connection_string = value
38
+ end
39
+
40
+ private
41
+
42
+ def generate_args(configuration)
43
+ connection_string = @connection_string.call(configuration)
44
+
45
+ if connection_string.nil? || connection_string.length == 0
46
+ raise Exception.new('No connection string specified')
47
+ end
48
+
49
+ args = []
50
+ args << 'sqlcmd'
51
+ args << "-S #{connection_string}"
52
+ args << "-i #{@script}"
53
+ @variables.each do |key, value|
54
+ args << "-v #{key}=#{value}"
55
+ end
56
+
57
+ args
58
+ end
59
+
60
+ def load_config
61
+ default_files = ['default.rb', "#{environment}.rb"]
62
+ default_files << "#{env['MACHINENAME']}.rb" if env['MACHINENAME']
63
+
64
+ configuration = Bozo::Configuration.new
65
+
66
+ default_files.each do |file|
67
+ path = File.join('config', file)
68
+ configuration.load path if File.exist? path
69
+ end
70
+
71
+ configuration
72
+ end
73
+
74
+ def default_script
75
+ <<-SQL
76
+ IF EXISTS(select * from sys.databases where name='#{@database_name}')
77
+ BEGIN
78
+ -- handle when the database cannot be dropped because it is currently in use
79
+ ALTER DATABASE #{@database_name} SET SINGLE_USER WITH ROLLBACK IMMEDIATE
80
+
81
+ DROP DATABASE #{@database_name}
82
+ END
83
+ GO
84
+
85
+ -- Create DB
86
+ CREATE DATABASE [#{@database_name}]
87
+ GO
88
+ SQL
89
+ end
90
+
91
+ end
92
+
93
+ end
data/lib/bozo_scripts.rb CHANGED
@@ -20,6 +20,7 @@ require 'bozo/packagers/rubygems'
20
20
  require 'bozo/packagers/nuget'
21
21
  require 'bozo/preparers/common_assembly_info'
22
22
  require 'bozo/preparers/file_templating'
23
+ require 'bozo/preparers/sql_server'
23
24
  require 'bozo/publishers/file_copy'
24
25
  require 'bozo/publishers/nuget'
25
26
  require 'bozo/publishers/rubygems'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bozo-scripts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garry Shutler
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-22 00:00:00.000000000 Z
12
+ date: 2015-08-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -109,6 +109,8 @@ files:
109
109
  - lib/bozo/packagers/rubygems.rb
110
110
  - lib/bozo/preparers/common_assembly_info.rb
111
111
  - lib/bozo/preparers/file_templating.rb
112
+ - lib/bozo/preparers/sql_server.rb
113
+ - lib/bozo/preparers/sql_server.rb~
112
114
  - lib/bozo/publishers/file_copy.rb
113
115
  - lib/bozo/publishers/nuget.rb
114
116
  - lib/bozo/publishers/rubygems.rb
@@ -139,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
141
  version: '0'
140
142
  requirements: []
141
143
  rubyforge_project: bozo-scripts
142
- rubygems_version: 2.4.6
144
+ rubygems_version: 2.4.8
143
145
  signing_key:
144
146
  specification_version: 4
145
147
  summary: Zopa build system scripts