backup_jenkins 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,7 +7,26 @@ require "bundler/gem_tasks"
7
7
 
8
8
  RSpec::Core::RakeTask.new(:spec) do |spec|
9
9
  spec.pattern = "spec/**/*_spec.rb"
10
- spec.rspec_opts = ["--backtrace --format CI::Reporter::RSpec"]
10
+ end
11
+
12
+ namespace :spec do
13
+ task :set_coverage do
14
+ ENV["COVERAGE"] = "true"
15
+ end
16
+
17
+ desc "Run with coverage"
18
+ task :rcov => :set_coverage do
19
+ Rake::Task[:spec].invoke
20
+ end
21
+
22
+ desc "Run for ci (with reports)"
23
+ RSpec::Core::RakeTask.new(:ci) do |spec|
24
+ spec.pattern = "spec/**/*_spec.rb"
25
+ spec.rspec_opts = ["--backtrace --format CI::Reporter::RSpec"]
26
+ end
27
+
28
+ desc "Run with coverage and reports"
29
+ task :rcov_and_ci => [:set_coverage, :ci]
11
30
  end
12
31
 
13
32
  desc "Clean backup and swap files, and artifacts"
@@ -7,18 +7,7 @@ module BackupJenkins
7
7
  end
8
8
 
9
9
  def valid?
10
- ! (
11
- aws["access_key"].nil? ||
12
- aws["secret"].nil? ||
13
- aws["bucket_name"].nil? ||
14
- backup["dir_base"].nil? ||
15
- backup["file_name_base"].nil? ||
16
- backup["backups_to_keep"].nil? ||
17
- backup["backups_to_keep"]["remote"].nil? ||
18
- backup["backups_to_keep"]["local"].nil? ||
19
- jenkins["home"].nil? ||
20
- verbose.nil?
21
- )
10
+ !verbose.nil? && jenkins_valid? && aws_valid? && backup_valid?
22
11
  end
23
12
 
24
13
  def method_missing(meth, *args, &block)
@@ -66,5 +55,20 @@ module BackupJenkins
66
55
  def config_file_example_path
67
56
  File.expand_path('../../../config/config-example.yml', __FILE__)
68
57
  end
58
+
59
+ def aws_valid?
60
+ aws["access_key"] && aws["secret"] && aws["bucket_name"]
61
+ end
62
+
63
+ def jenkins_valid?
64
+ !!jenkins["home"]
65
+ end
66
+
67
+ def backup_valid?
68
+ backup["dir_base"] && backup["file_name_base"] &&
69
+ backup["backups_to_keep"] &&
70
+ backup["backups_to_keep"]["remote"] &&
71
+ backup["backups_to_keep"]["local"]
72
+ end
69
73
  end
70
74
  end
@@ -16,7 +16,8 @@ module BackupJenkins
16
16
  end
17
17
 
18
18
  "".tap do |output|
19
- by_host.each do |host, data|
19
+ by_host.keys.sort.each do |host|
20
+ data = by_host[host]
20
21
  output << host.capitalize << ":" << $/
21
22
  data.each do |datum|
22
23
  output << sprintf(" - %s key: %s (%0.2f MB)#{$/}", *datum)
@@ -1,3 +1,3 @@
1
1
  module BackupJenkins
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -96,7 +96,6 @@ describe BackupJenkins::Backup do
96
96
  subject.stub(:tarball_filename).and_return("tarball")
97
97
  subject.stub(:backup_directory).and_return("directory")
98
98
 
99
- STDOUT.should_receive(:puts).twice
100
99
  subject.should_receive(:remove_temporary_files)
101
100
  FileUtils.should_receive(:rm_rf).with("tarball")
102
101
 
@@ -105,8 +104,7 @@ describe BackupJenkins::Backup do
105
104
 
106
105
  it "should recover from file not found" do
107
106
  subject.stub(:backup_directory).and_return("directory")
108
- subject.should_receive(:remove_temporary_files).and_raise(Errno::ENOENT)
109
- STDOUT.should_receive(:puts).twice
107
+ subject.should_receive(:remove_temporary_files).and_raise(Errno::ENOENT.new)
110
108
  subject.clean_up
111
109
  end
112
110
  end
@@ -191,7 +189,6 @@ describe BackupJenkins::Backup do
191
189
  it "should clean up if Interrupt" do
192
190
  subject.should_receive(:copy_files).and_raise(Interrupt)
193
191
  subject.should_receive(:clean_up)
194
- STDOUT.should_receive(:puts)
195
192
  subject.do_backup
196
193
  end
197
194
  end
@@ -35,14 +35,14 @@ describe BackupJenkins::Config do
35
35
  end
36
36
 
37
37
  it "should exit with non 0 on error" do
38
- YAML.should_receive(:load_file).and_raise(Errno::ENOENT)
38
+ YAML.should_receive(:load_file).and_raise(Errno::ENOENT.new)
39
39
  expect{ subject }.to raise_error SystemExit
40
40
  end
41
41
 
42
42
  it "should print some helpful text if config file doesn't exist" do
43
43
  subject.should_receive(:default_config_file_path).and_return("config")
44
44
 
45
- YAML.should_receive(:load_file).and_raise(Errno::ENOENT)
45
+ YAML.should_receive(:load_file).and_raise(Errno::ENOENT.new)
46
46
  File.should_receive(:read).and_return("sample")
47
47
 
48
48
  STDERR.should_receive(:puts).with("Please create a config file in config")
data/spec/spec_helper.rb CHANGED
@@ -5,12 +5,14 @@
5
5
  #
6
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
7
 
8
- require 'simplecov'
9
- require 'simplecov-rcov'
10
- SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
11
- SimpleCov.start do
12
- add_filter "spec"
13
- add_filter "vendor/bundler_gems"
8
+ if ENV["COVERAGE"]
9
+ require 'simplecov'
10
+ require 'simplecov-rcov'
11
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
12
+ SimpleCov.start do
13
+ add_filter "spec"
14
+ add_filter "vendor/bundler_gems"
15
+ end
14
16
  end
15
17
 
16
18
  require 'backup_jenkins'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup_jenkins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
16
- requirement: &30152060 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *30152060
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &30151640 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *30151640
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: Simple Jenkins config and plugin backup to S3
37
47
  email:
38
48
  - jcmuller@gmail.com
@@ -85,14 +95,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
95
  version: '0'
86
96
  requirements: []
87
97
  rubyforge_project:
88
- rubygems_version: 1.8.15
98
+ rubygems_version: 1.8.24
89
99
  signing_key:
90
100
  specification_version: 3
91
101
  summary: This gem allows you to get a backup instance of jenkins up and running pretty
92
102
  quickly
93
103
  test_files:
94
- - spec/lib/backup_jenkins/formatter_spec.rb
104
+ - spec/lib/backup_jenkins/aws_spec.rb
95
105
  - spec/lib/backup_jenkins/backup_spec.rb
96
106
  - spec/lib/backup_jenkins/cli_spec.rb
97
107
  - spec/lib/backup_jenkins/config_spec.rb
98
- - spec/lib/backup_jenkins/aws_spec.rb
108
+ - spec/lib/backup_jenkins/formatter_spec.rb