redmine_plugin_support 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -7,22 +7,16 @@ require 'rake/tasklib'
7
7
  require 'redmine_plugin_support/redmine_helper'
8
8
  require 'redmine_plugin_support/general_task'
9
9
  require 'redmine_plugin_support/environment_task'
10
- require 'redmine_plugin_support/database_task'
11
- require 'redmine_plugin_support/cucumber_task'
12
- require 'redmine_plugin_support/metrics_task'
13
- require 'redmine_plugin_support/rdoc_task'
14
- require 'redmine_plugin_support/release_task'
15
- require 'redmine_plugin_support/rspec_task'
16
- require 'redmine_plugin_support/stats_task'
17
- require 'redmine_plugin_support/test_unit_task'
18
10
 
19
11
  module RedminePluginSupport
20
- VERSION = '0.0.4'
12
+ VERSION = '0.0.5'
21
13
 
22
14
  @@options = { }
23
15
 
24
16
  class Base
25
17
  include Singleton
18
+ include Rake::DSL
19
+ extend Rake::DSL
26
20
 
27
21
  attr_accessor :project_name
28
22
  attr_accessor :tasks
@@ -49,20 +43,28 @@ module RedminePluginSupport
49
43
  plugin.tasks.each do |task|
50
44
  case task
51
45
  when :db
46
+ require 'redmine_plugin_support/database_task'
52
47
  RedminePluginSupport::DatabaseTask.new(:db)
53
48
  when :doc
49
+ require 'redmine_plugin_support/rdoc_task'
54
50
  RedminePluginSupport::RDocTask.new(:doc)
55
51
  when :spec
52
+ require 'redmine_plugin_support/rspec_task'
56
53
  RedminePluginSupport::RspecTask.new(:spec)
57
54
  when :test
55
+ require 'redmine_plugin_support/test_unit_task'
58
56
  RedminePluginSupport::TestUnitTask.new(:test)
59
57
  when :cucumber
58
+ require 'redmine_plugin_support/cucumber_task'
60
59
  RedminePluginSupport::CucumberTask.new(:features)
61
60
  when :release
61
+ require 'redmine_plugin_support/release_task'
62
62
  RedminePluginSupport::ReleaseTask.new(:release)
63
63
  when :stats
64
+ require 'redmine_plugin_support/stats_task'
64
65
  RedminePluginSupport::StatsTask.new(:stats)
65
66
  when :metrics
67
+ require 'redmine_plugin_support/metrics_task'
66
68
  RedminePluginSupport::MetricsTask.new(:metrics)
67
69
  when :clean
68
70
  require 'rake/clean'
@@ -1,8 +1,9 @@
1
- require 'cucumber/rake/task'
2
-
3
1
  module RedminePluginSupport
4
2
  class CucumberTask < GeneralTask
5
3
  def define
4
+
5
+ require 'cucumber/rake/task'
6
+
6
7
  # TODO: Requires webrat to be installed as a plugin....
7
8
  Cucumber::Rake::Task.new(:features) do |t|
8
9
  t.cucumber_opts = "--format pretty"
@@ -174,6 +174,55 @@ module RedminePluginSupport
174
174
  end
175
175
  end
176
176
 
177
+ def create_database(config)
178
+ begin
179
+ if config['adapter'] =~ /sqlite/
180
+ if File.exist?(config['database'])
181
+ $stderr.puts "#{config['database']} already exists"
182
+ else
183
+ begin
184
+ # Create the SQLite database
185
+ ActiveRecord::Base.establish_connection(config)
186
+ ActiveRecord::Base.connection
187
+ rescue
188
+ $stderr.puts $!, *($!.backtrace)
189
+ $stderr.puts "Couldn't create database for #{config.inspect}"
190
+ end
191
+ end
192
+ return # Skip the else clause of begin/rescue
193
+ else
194
+ ActiveRecord::Base.establish_connection(config)
195
+ ActiveRecord::Base.connection
196
+ end
197
+ rescue
198
+ case config['adapter']
199
+ when 'mysql'
200
+ @charset = ENV['CHARSET'] || 'utf8'
201
+ @collation = ENV['COLLATION'] || 'utf8_unicode_ci'
202
+ begin
203
+ ActiveRecord::Base.establish_connection(config.merge('database' => nil))
204
+ ActiveRecord::Base.connection.create_database(config['database'], :charset => (config['charset'] || @charset), :collation => (config['collation'] || @collation))
205
+ ActiveRecord::Base.establish_connection(config)
206
+ rescue
207
+ $stderr.puts "Couldn't create database for #{config.inspect}, charset: #{config['charset'] || @charset}, collation: #{config['collation'] || @collation} (if you set the charset manually, make sure you have a matching collation)"
208
+ end
209
+ when 'postgresql'
210
+ @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8'
211
+ begin
212
+ ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
213
+ ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding))
214
+ ActiveRecord::Base.establish_connection(config)
215
+ rescue
216
+ $stderr.puts $!, *($!.backtrace)
217
+ $stderr.puts "Couldn't create database for #{config.inspect}"
218
+ end
219
+ end
220
+ else
221
+ $stderr.puts "#{config['database']} already exists"
222
+ end
223
+ end
224
+
225
+
177
226
  def set_firebird_env(config)
178
227
  ENV["ISC_USER"] = config["username"].to_s if config["username"]
179
228
  ENV["ISC_PASSWORD"] = config["password"].to_s if config["password"]
@@ -1,11 +1,11 @@
1
- gem 'rspec'
2
- gem 'rspec-rails'
3
- require 'spec/rake/spectask'
4
-
5
1
  module RedminePluginSupport
6
2
  class RspecTask < GeneralTask
7
3
  def define
8
4
 
5
+ gem 'rspec'
6
+ gem 'rspec-rails'
7
+ require 'spec/rake/spectask'
8
+
9
9
  desc "Run all specs in spec directory (excluding plugin specs)"
10
10
  Spec::Rake::SpecTask.new(:spec) do |t|
11
11
  t.spec_opts = ['--options', "\"#{RedmineHelper.plugin_root}/spec/spec.opts\""]
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_plugin_support
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 21
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 4
9
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
10
11
  platform: ruby
11
12
  authors:
12
13
  - Eric Davis
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-10 00:00:00 -07:00
18
+ date: 2011-12-14 00:00:00 -08:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: thoughtbot-shoulda
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -66,31 +69,34 @@ homepage: http://github.com/edavis10/redmine_plugin_support
66
69
  licenses: []
67
70
 
68
71
  post_install_message:
69
- rdoc_options:
70
- - --charset=UTF-8
72
+ rdoc_options: []
73
+
71
74
  require_paths:
72
75
  - lib
73
76
  required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
74
78
  requirements:
75
79
  - - ">="
76
80
  - !ruby/object:Gem::Version
81
+ hash: 3
77
82
  segments:
78
83
  - 0
79
84
  version: "0"
80
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
81
87
  requirements:
82
88
  - - ">="
83
89
  - !ruby/object:Gem::Version
90
+ hash: 3
84
91
  segments:
85
92
  - 0
86
93
  version: "0"
87
94
  requirements: []
88
95
 
89
96
  rubyforge_project: redmine_plugin_support
90
- rubygems_version: 1.3.6
97
+ rubygems_version: 1.3.7
91
98
  signing_key:
92
99
  specification_version: 3
93
100
  summary: Libraries to automate the creation and management of Redmine plugins
94
- test_files:
95
- - test/test_helper.rb
96
- - test/redmine_plugin_support_test.rb
101
+ test_files: []
102
+