devinstall 1.2.1 → 1.2.2

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9638aded2271f10573cb742e4381447bb55eb5a3
4
- data.tar.gz: b2b08b319de49c762356c1fb4b83dfeb66e3c213
3
+ metadata.gz: 4bb5beb672121e7653746c5657c2ab46bb7f92f0
4
+ data.tar.gz: f228e14e80ba1a181df53709035afda7831b0b3b
5
5
  SHA512:
6
- metadata.gz: c779c4149249f5b20331b4fbc80155d3c9ca335099aee8c865b84e136e614046bcd07a2ad6d8705c1a07233472e13642a13e115b9fe15652954e6d934897c2e1
7
- data.tar.gz: 0e3de9efec78707a0e7686cebba326b2bfad3dd0d1fcbbef6d5bed9a0b9a55de0f29204622b7e1ddcb138e7a0b6bf8df37ba47dfc0eabb5eda38769c0b90b9c4
6
+ metadata.gz: ff9e44b19f0197ade70359e1b34167bd5d112bf456b59d5ec20d580665360b764ab56cb6784f4825f6e440b54792105fa8571f22c3a08e18e008c86864cd6b54
7
+ data.tar.gz: 9000670caa9ab71c0240e950de774c0b416fc59002d7e7f5ac887511eb2531ef6aba8cf0fbba33c3b2d1cc3288a3e5fa7ff4d80b7fd6801ecb658609805a5fac
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ #ruby=2.0.0
2
+ #ruby-gemset=devinstall
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in devinstall.gemspec
data/Rakefile CHANGED
@@ -1 +1,16 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc 'Run all examples'
5
+ RSpec::Core::RakeTask.new(:spec) do |t|
6
+ t.pattern = './spec/spec_helper.rb'
7
+ t.rspec_opts = %w{--colour --format documentation}
8
+ end
9
+
10
+ desc 'Run tests with SimpleCov'
11
+ task :coverage do
12
+ require 'simplecov'
13
+ require 'simplecov-gem-adapter'
14
+ SimpleCov.start 'gem'
15
+ Rake::Task[:spec].execute
16
+ end
data/bin/pkg-tool CHANGED
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'bundler/setup'
3
3
  require 'devinstall'
4
-
5
- include Cli
6
-
4
+ require 'devinstall/cli'
data/devinstall.gemspec CHANGED
@@ -20,7 +20,9 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency 'bundler'
22
22
  spec.add_development_dependency 'rake'
23
- spec.add_development_dependency 'getopt'
24
23
  spec.add_development_dependency 'rspec'
25
- spec.add_development_dependency 'commander'
24
+ spec.add_development_dependency 'simplecov'
25
+ spec.add_development_dependency 'simplecov-gem-adapter'
26
+ spec.add_dependency 'getopt'
27
+ spec.add_dependency 'commander'
26
28
  end
data/lib/devinstall.rb CHANGED
@@ -3,6 +3,5 @@ require 'devinstall/deep_symbolize'
3
3
  require 'devinstall/utils'
4
4
  require 'devinstall/settings'
5
5
  require 'devinstall/package'
6
- require 'devinstall/cli'
7
6
  require 'devinstall/provider'
8
7
 
@@ -3,90 +3,87 @@ require 'getopt/long'
3
3
  require 'devinstall/settings'
4
4
  require 'commander/import'
5
5
 
6
- module Cli
6
+ program :name, 'DevInstall'
7
+ program :version, Devinstall::VERSION
8
+ program :description, 'Poor man builder/installer'
7
9
 
8
- program :name, 'DevInstall'
9
- program :version, Devinstall::VERSION
10
- program :description, 'Poor man builder/installer'
11
-
12
- global_option('--config FILE' 'Configuration file to be used') do |file|
13
- unless Devinstall::Settings.instance.load! file
14
- puts "Couldn't find #{file}"
15
- exit!
16
- end
10
+ global_option('--config FILE' 'Configuration file to be used') do |file|
11
+ unless Devinstall::Settings.instance.load! file
12
+ puts "Couldn't find #{file}"
13
+ exit!
17
14
  end
15
+ end
18
16
 
19
- global_option('--verbose', 'Verbose output') { $verbose=true }
20
- global_option('--dry-run', 'Dry-run; don\'t run commands, just pretend to') { $dry=true }
21
- global_option('--type STRING', 'Package type (deb, rpm, tgz). Currently only deb')
22
- global_option('--env STRING', 'Package environment to be built for')
17
+ global_option('--verbose', 'Verbose output') { $verbose=true }
18
+ global_option('--dry-run', 'Dry-run; don\'t run commands, just pretend to') { $dry=true }
19
+ global_option('--type STRING', 'Package type (deb, rpm, tgz). Currently only deb')
20
+ global_option('--env STRING', 'Package environment to be built for')
23
21
 
24
- def load_defaults
25
- %w(./devinstall.yml ./.devinstall.yml ~/.devinstall).each do |f|
26
- Devinstall::Settings.instance.load! f and return true
27
- end
28
- puts "Couldn't find default config file and no --config option given at command line"
29
- exit!
22
+ def load_defaults
23
+ %w(./devinstall.yml ./.devinstall.yml ~/.devinstall).each do |f|
24
+ Devinstall::Settings.instance.load! f and return true
30
25
  end
26
+ puts "Couldn't find default config file and no --config option given at command line"
27
+ exit!
28
+ end
31
29
 
32
- command :build do |c|
33
- c.action do |args, options|
34
- config=Devinstall::Settings.instance
35
- load_defaults unless options.config
36
- type = options.type ? options.type.to_sym : config.defaults(:type)
37
- env = options.env ? options.env.to_sym : config.defaults(:env)
30
+ command :build do |c|
31
+ c.action do |args, options|
32
+ config=Devinstall::Settings.instance
33
+ load_defaults unless options.config
34
+ type = options.type ? options.type.to_sym : config.defaults(:type)
35
+ env = options.env ? options.env.to_sym : config.defaults(:env)
38
36
 
39
- args.each do |p|
40
- pk=Devinstall::Package.new(p, type, env)
41
- pk.build
42
- end
37
+ args.each do |p|
38
+ pk=Devinstall::Package.new(p, type, env)
39
+ pk.build
43
40
  end
44
41
  end
42
+ end
45
43
 
46
- command :install do |c|
47
- c.action do |args, options|
48
- config=Devinstall::Settings.instance
49
- load_defaults unless options.config
50
- type = options.type ? options.type.to_sym : config.defaults(:type)
51
- env = options.env ? options.env.to_sym : config.defaults(:env)
44
+ command :install do |c|
45
+ c.action do |args, options|
46
+ config=Devinstall::Settings.instance
47
+ load_defaults unless options.config
48
+ type = options.type ? options.type.to_sym : config.defaults(:type)
49
+ env = options.env ? options.env.to_sym : config.defaults(:env)
52
50
 
53
- args.each do |p|
54
- pk=Devinstall::Package.new(p, type, env)
55
- pk.build
56
- pk.install
57
- end
51
+ args.each do |p|
52
+ pk=Devinstall::Package.new(p, type, env)
53
+ pk.build
54
+ pk.install
58
55
  end
59
56
  end
57
+ end
60
58
 
61
- command :test do |c|
62
- c.action do |args, options|
63
- config=Devinstall::Settings.instance
64
- load_defaults unless options.config
65
- type = options.type ? options.type.to_sym : config.defaults(:type)
66
- env = options.env ? options.env.to_sym : config.defaults(:env)
59
+ command :test do |c|
60
+ c.action do |args, options|
61
+ config=Devinstall::Settings.instance
62
+ load_defaults unless options.config
63
+ type = options.type ? options.type.to_sym : config.defaults(:type)
64
+ env = options.env ? options.env.to_sym : config.defaults(:env)
67
65
 
68
- args.each do |p|
69
- pk=Devinstall::Package.new(p, type, env)
70
- pk.run_tests
71
- end
66
+ args.each do |p|
67
+ pk=Devinstall::Package.new(p, type, env)
68
+ pk.run_tests
72
69
  end
73
70
  end
71
+ end
74
72
 
75
- command :upload do |c|
76
- c.action do |args, options|
77
- config=Devinstall::Settings.instance
78
- load_defaults unless options.config
79
- type = options.type ? options.type.to_sym : config.defaults(:type)
80
- env = options.env ? options.env.to_sym : config.defaults(:env)
73
+ command :upload do |c|
74
+ c.action do |args, options|
75
+ config=Devinstall::Settings.instance
76
+ load_defaults unless options.config
77
+ type = options.type ? options.type.to_sym : config.defaults(:type)
78
+ env = options.env ? options.env.to_sym : config.defaults(:env)
81
79
 
82
- args.each do |p|
83
- pk=Devinstall::Package.new(p, type, env)
84
- pk.build
85
- pk.run_tests
86
- pk.upload
87
- end
80
+ args.each do |p|
81
+ pk=Devinstall::Package.new(p, type, env)
82
+ pk.build
83
+ pk.run_tests
84
+ pk.upload
88
85
  end
89
86
  end
90
-
91
87
  end
92
88
 
89
+
@@ -0,0 +1,24 @@
1
+ require 'devinstall/utils'
2
+ ## Work in progress
3
+ module Pkg
4
+ module RpmWorking
5
+ # @type=:rpm
6
+ include Utils
7
+
8
+ def get_info(pkg, type, env)
9
+ config=Devinstall::Settings.instance
10
+ folder=config.local(:folder, pkg: pkg, type: type, env: env)
11
+ rpm_spec = File.expand_path "#{folder}/#{pkg}.rpm.spec"
12
+ unless File.exists? rpm_spec
13
+ exit! "No 'debian/changelog' found in specified :local:folder (#{folder})"
14
+ end
15
+ package_version = File.open(rpm_spec, 'r') { |f| f.gets.chomp.sub(/^.*\((.*)\).*$/, '\1') }
16
+ package_release = config.build(pkg: pkg, type: type, env: env)[:arch]
17
+ {version: package_version,
18
+ files: {rpm: "#{pkg}.#{package_version}.#{package_release}.rpm"},
19
+ to_install: [:rpm],
20
+ to_upload: [:rpm]
21
+ }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,38 @@
1
+ require 'devinstall/utils'
2
+ require 'devinstall/settings'
3
+
4
+ module Provider
5
+ module Local
6
+ include Utils
7
+
8
+ SETTINGS = {
9
+ local: [:copy, :sudo],
10
+ }
11
+
12
+ def upload_sources(cfg, src, dst)
13
+ config =Devinstall::Settings.instance
14
+ copy_command=config.local[:copy]
15
+ command("#{copy_command} #{src} #{dst}") unless src == dst
16
+ end
17
+
18
+ def download_file(cfg, file, local)
19
+ config=Devinstall::Settings.instance
20
+ copy_command=config.local[:copy]
21
+ command("#{copy_command} #{cfg[:target]}/#{file.to_s} #{local}")
22
+ end
23
+
24
+ def upload_file(cfg, file, local)
25
+ config=Devinstall::Settings.instance
26
+ copy_command=config.local[:copy]
27
+ command("#{copy_command} #{local}/#{file} #{cfg[:folder]}")
28
+ end
29
+
30
+ def exec_command(cfg, command)
31
+ config=Devinstall::Settings.instance
32
+ sudo=config.local[:sudo]
33
+ command("#{sudo} #{command}")
34
+ end
35
+
36
+ end #Local
37
+ end #Provider
38
+
@@ -53,31 +53,31 @@ module Devinstall
53
53
  end ## Class Action
54
54
 
55
55
  def load! (filename)
56
- if File.exist?(File.expand_path(filename))
57
- unless FILES.include? filename
58
- FILES << filename
59
- data = YAML::load_file(filename).deep_symbolize
60
- merger = proc do |_, v1, v2|
61
- Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2
62
- end
63
- SETTINGS.merge! data, &merger
56
+ if FILES.include? filename
57
+ true
58
+ else
59
+ FILES << filename
60
+ data = YAML::load_file(filename).deep_symbolize
61
+ merger = proc do |_, v1, v2|
62
+ Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2
64
63
  end
65
- end
64
+ SETTINGS.merge! data, &merger
65
+ end if File.exist?(File.expand_path(filename))
66
66
  end
67
67
 
68
68
  def method_missing (method, *args)
69
69
  raise UnknownKeyError, "Undefined section '#{method}'" unless method_defined? method
70
70
  key = (args.shift or {})
71
71
  rest = (Hash === key) ? key : (args.shift or {})
72
- pkg = rest[:pkg]
72
+ pkg = rest[:pkg]
73
73
  if pkg.nil?
74
- raise UnknownKeyError, "Unknown key #{key}" unless key_defined? method,key
75
- return SETTINGS[method][key] rescue raise "#{method}: Package must be defined"
74
+ raise UnknownKeyError, "Unknown key #{key}" unless key_defined? method, key
75
+ return SETTINGS[method][key] rescue raise "#{method}: Package must be defined"
76
76
  end
77
77
  type = rest[:type] || defaults(:type)
78
78
  env = rest[:env] || defaults(:env)
79
79
  return Action.new(method, pkg, type, env) if Hash === key
80
- raise UnknownKeyError, "Unknown key #{key}" unless key_defined? method,key
80
+ raise UnknownKeyError, "Unknown key #{key}" unless key_defined? method, key
81
81
  global_or_local(method, key, pkg, type, env) or
82
82
  raise KeyNotDefinedError, "Undefined key '#{method}:#{key}' or alternate for ['#{pkg}' '#{type}' '#{env}']"
83
83
  end
@@ -116,14 +116,14 @@ module Devinstall
116
116
  def key_defined?(method, key)
117
117
  method, key = (method.to_sym rescue method), (key.to_sym rescue key)
118
118
  method_defined? method and
119
- (MDEFS[method].include? key rescue false) or
120
- PROVIDERS.inject(false){|res,(_,v)| res or (v[method].include? key rescue false)}
119
+ (MDEFS[method].include? key rescue false) or
120
+ PROVIDERS.inject(false) { |res, (_, v)| res or (v[method].include? key rescue false) }
121
121
  end
122
122
 
123
123
  def method_defined?(method)
124
124
  method = (method.to_sym rescue method)
125
125
  (MDEFS.has_key?(method) or
126
- PROVIDERS.inject(false){|res,(k,_)| res or PROVIDERS[k].has_key? method}) and
126
+ PROVIDERS.inject(false) { |res, (k, _)| res or PROVIDERS[k].has_key? method }) and
127
127
  SETTINGS.has_key? method
128
128
  end
129
129
 
@@ -1,3 +1,3 @@
1
1
  module Devinstall
2
- VERSION = '1.2.1' # Working!
2
+ VERSION = '1.2.2' # Working!
3
3
  end
@@ -0,0 +1,7 @@
1
+ devinstall (1.2.1) wheezy; urgency=low
2
+
3
+ * fix LBSM-161
4
+ * qa revision
5
+
6
+ -- Dragos Boca <dragos@localhost> Thu, 18 Apr 2013 17:55:21 +0300
7
+
@@ -0,0 +1,73 @@
1
+ ssh:
2
+ rsync: /usr/bin/rsync
3
+ scp: /usr/bin/scp
4
+ sudo: sshsudo
5
+ ssh: /usr/bin/ssh
6
+ defaults:
7
+ package: devinstall
8
+ # env: dev
9
+ type: deb
10
+ tests:
11
+ # dev is the environment
12
+ provider: ssh
13
+ host: dboca.dev.local
14
+ folder: rs
15
+ target: rs ## this is a new addition
16
+ user: dboca
17
+ command: "cd %f && make devtest"
18
+ local:
19
+ # folder - source folder
20
+ # temp - temporary folder
21
+ folder: ~/projects/devinstall/spec/assets
22
+ temp: ~/.tmp
23
+ build:
24
+ # host - build machine
25
+ # folder - rsync to?
26
+ # target - the folder where packages will be generated (defaults to folder)
27
+ # user - for ssh / rsync
28
+ # arch is the architecture for the generated package (like amd64 or i686)
29
+ # provider can be ssh or local (in the future vagrant and openstack)
30
+ # note: the ssh in provider have nothing to do with ssh command in base
31
+ provider: ssh
32
+ user: dboca
33
+ host: vm-dboca.dev.local
34
+ folder: rs
35
+ target: rs
36
+ arch: all
37
+ type: deb
38
+ install:
39
+ # host - dev/prod deploy and install host
40
+ # user - for scp / ssh / rsync (defaults to base[user])
41
+ # environment - live/qa/dev/...
42
+ provider: ssh ## Not implemented but compulsory for build, install, repos, tests
43
+ user: dboca
44
+ host:
45
+ - server1.lan
46
+ - server2.lan
47
+ folder: /home/dboca ## folder for scp/dpkg -i
48
+ type: deb
49
+ arch: all
50
+ repos:
51
+ # for repository deployment
52
+ # in a repository should be all packages for all architectures so we don't have an 'arch:' field
53
+ provider: ssh
54
+ user: dboca
55
+ host: dboca.repo.lan
56
+ folder: /srv/repo/incoming
57
+ type: deb
58
+ packages:
59
+ devinstall:
60
+ # might contain all the sections above (local, build, install, repos, tests)
61
+ # type:build:command and type:install:command are mandatory
62
+ # in build_command the folowing expansions are made:
63
+ # %f build[folder]
64
+ # %t build[target]
65
+ # %p package (current package)
66
+ # %T type (deb, rpm, tar.gz ,...)
67
+ # %a only make sense for install and is the installed file
68
+ deb:
69
+ build:
70
+ command: "cd %f/%p && dpkg-buildpackage"
71
+ install:
72
+ command: "dpkg -i %a"
73
+
@@ -0,0 +1,74 @@
1
+ ssh:
2
+ rsync: /usr/bin/rsync
3
+ scp: /usr/bin/scp
4
+ sudo: sshsudo
5
+ ssh: /usr/bin/ssh
6
+ defaults:
7
+ package: devinstall
8
+ # env: dev
9
+ type: deb
10
+ tests:
11
+ # dev is the environment
12
+ # provider: ssh
13
+ dev:
14
+ host: dboca.dev.local
15
+ folder: rs
16
+ target: rs ## this is a new addition
17
+ user: dboca
18
+ # command: "cd %f && make devtest"
19
+ local:
20
+ # folder - source folder
21
+ # temp - temporary folder
22
+ folder: ~/projects/devinstall/spec/assets
23
+ temp: ~/.tmp
24
+ build:
25
+ # host - build machine
26
+ # folder - rsync to?
27
+ # target - the folder where packages will be generated (defaults to folder)
28
+ # user - for ssh / rsync
29
+ # arch is the architecture for the generated package (like amd64 or i686)
30
+ # provider can be ssh or local (in the future vagrant and openstack)
31
+ # note: the ssh in provider have nothing to do with ssh command in base
32
+ provider: local
33
+ user: dboca
34
+ host: vm-dboca.dev.local
35
+ folder: rs
36
+ target: rs
37
+ arch: all
38
+ type: deb
39
+ install:
40
+ # host - dev/prod deploy and install host
41
+ # user - for scp / ssh / rsync (defaults to base[user])
42
+ # environment - live/qa/dev/...
43
+ provider: ssh ## Not implemented but compulsory for build, install, repos, tests
44
+ user: dboca
45
+ host:
46
+ - server1.lan
47
+ - server2.lan
48
+ folder: /home/dboca ## folder for scp/dpkg -i
49
+ type: deb
50
+ arch: all
51
+ repos:
52
+ # for repository deployment
53
+ # in a repository should be all packages for all architectures so we don't have an 'arch:' field
54
+ provider: ssh
55
+ user: dboca
56
+ host: dboca.repo.lan
57
+ folder: /srv/repo/incoming
58
+ type: deb
59
+ packages:
60
+ devinstall:
61
+ # might contain all the sections above (local, build, install, repos, tests)
62
+ # type:build:command and type:install:command are mandatory
63
+ # in build_command the folowing expansions are made:
64
+ # %f build[folder]
65
+ # %t build[target]
66
+ # %p package (current package)
67
+ # %T type (deb, rpm, tar.gz ,...)
68
+ # %a only make sense for install and is the installed file
69
+ deb:
70
+ build:
71
+ command: "cd %f/%p && dpkg-buildpackage"
72
+ install:
73
+ command: "dpkg -i %a"
74
+
@@ -0,0 +1,28 @@
1
+ require 'devinstall/settings'
2
+
3
+ def clean_config
4
+ Devinstall::Settings::FILES.clear
5
+ Devinstall::Settings::SETTINGS.clear
6
+ Devinstall::Settings::PROVIDERS.clear
7
+ end
8
+
9
+ def capture_output
10
+ old_output=$stdout
11
+ $stdout =StringIO.new
12
+ yield
13
+ res =$stdout.string
14
+ $stdout=old_output
15
+ res
16
+ end
17
+
18
+ RSpec.configure do |c|
19
+ c.before(:all) do
20
+ @config=Devinstall::Settings.instance
21
+ clean_config
22
+ @package, @type, @env, @action = :devinstall, :deb, nil, :install
23
+ $verbose =true
24
+ end
25
+ end
26
+
27
+ Dir[File.expand_path('../support/**/*_spec.rb', __FILE__)].sort.each { |f| require f }
28
+
@@ -0,0 +1,61 @@
1
+ require 'rspec'
2
+ require 'devinstall'
3
+
4
+ describe 'Settings' do
5
+
6
+ it 'should load an existig file' do
7
+ expect(@config.load!('./spec/assets/example_02.yml')).to be_true
8
+ end
9
+
10
+ it 'should not load an unexisting file' do
11
+ expect(@config.load!('doc/unexisting.yml')).to be_false
12
+ end
13
+
14
+ it 'should load at init' do
15
+ expect(@config).to be_an_instance_of(Devinstall::Settings)
16
+ [:defaults, :local, :build, :install, :tests, :repos].each do |p|
17
+ expect(@config.respond_to? p).to be_true
18
+ end # all sections loaded!
19
+ end
20
+
21
+ it 'should have a method defaults' do
22
+ expect(@config.respond_to? :defaults).to be_true
23
+ end
24
+
25
+ it 'the method "defaults" should have only one argument' do
26
+ expect(@config.defaults(:type)).to eq 'deb'
27
+ end
28
+
29
+ it 'should instantiate a new "Action" when hashes are given' do
30
+ expect(@config.build(type: 'deb', env: 'dev', pkg: @package)).to be_an_instance_of(Devinstall::Settings::Action)
31
+ end
32
+
33
+ it 'should instantiata a new "Action" when partial hashes are given' do
34
+ expect(@config.build(pkg: @package)).to be_an_instance_of(Devinstall::Settings::Action)
35
+ end
36
+
37
+ it 'should raise "UnknownKeys" errors for unknown keys' do
38
+ expect { @config.defaults :none }.to raise_error(Devinstall::UnknownKeyError)
39
+ end
40
+
41
+ it 'should raise "KeyNotDefinedError" errors for undefined keys' do
42
+ expect { @config.tests(:provider, pkg: @package) }.to raise_error(Devinstall::KeyNotDefinedError)
43
+ end
44
+
45
+ it 'should produce a value if all arguments are valid' do
46
+ expect(@config.build(:command, pkg: @package)).to eq('cd %f/%p && dpkg-buildpackage')
47
+ end
48
+
49
+ describe 'Action' do
50
+ it 'should have a [] method' do
51
+ rr=@config.build(pkg: @package, type: @type, env: @env)
52
+ expect(rr[:target]).to eq('rs')
53
+ end
54
+
55
+ it 'should enumerate all defined values' do
56
+ ar=[]
57
+ @config.build(pkg: @package, type: @type, env: @env).each { |k, _| ar << k }
58
+ expect(ar.sort == [:folder, :command, :provider, :type, :arch, :target].sort).to be_true
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,44 @@
1
+ require 'rspec'
2
+ require 'devinstall'
3
+
4
+ describe 'Packages' do
5
+ before(:all) do
6
+ Devinstall::Settings.instance.load! './spec/assets/example_01.yml' ## use defaults for type and env
7
+ end
8
+
9
+ it 'should include the correct file' do
10
+ pk=Devinstall::Package.new(@package, @type, @env)
11
+ expect(pk.singleton_class.include?(Pkg::Deb)).to be_true
12
+ end
13
+
14
+ describe 'pkg_deb' do
15
+ it 'should pretend to build a package' do
16
+ $dry=true
17
+ pk =Devinstall::Package.new(@package, @type, @env)
18
+ out = capture_output { pk.build(@package, @type, @env) }
19
+ expect(out).to match /^Building/
20
+ end
21
+
22
+ it 'should pretend to upload a package' do
23
+ $dry=true
24
+ pk =Devinstall::Package.new(@package, @type, @env)
25
+ out = capture_output { pk.upload(@package, @type, @env) }
26
+ expect(out).to match /^Upload/
27
+ end
28
+
29
+ it 'should pretend to test a package' do
30
+ $dry=true
31
+ pk =Devinstall::Package.new(@package, @type, @env)
32
+ out = capture_output { pk.run_tests(@package, @type, @env) }
33
+ expect(out).to match /^Running/
34
+ end
35
+
36
+ it 'should pretend to install a package' do
37
+ $dry=true
38
+ pk =Devinstall::Package.new(@package, @type, @env)
39
+ out = capture_output { pk.install(@package, @type, @env) }
40
+ expect(out).to match /^Installing/
41
+ end
42
+
43
+ end
44
+ end
@@ -2,9 +2,9 @@ require 'rspec'
2
2
  require 'devinstall'
3
3
 
4
4
  describe 'Provider' do
5
- before do
6
- @package, @type, @env, @action = :devinstall, :deb, :dev, :install
7
- # config=Devinstall::Settings.instance
5
+
6
+ before(:all) do
7
+ Devinstall::Settings.instance.load! './spec/assets/example_01.yml' ## use defaults for type and env
8
8
  end
9
9
 
10
10
  it 'should load the correct (Provider::Ssh) plugin' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devinstall
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dragos Boca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-07 00:00:00.000000000 Z
11
+ date: 2013-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: getopt
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '>='
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '>='
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: commander
70
+ name: simplecov-gem-adapter
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '>='
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: getopt
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: commander
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  description: package builder and installer
84
112
  email:
85
113
  - dboca@mail.com
@@ -102,14 +130,20 @@ files:
102
130
  - lib/devinstall/deep_symbolize.rb
103
131
  - lib/devinstall/package.rb
104
132
  - lib/devinstall/pkg/pkg_deb.rb
133
+ - lib/devinstall/pkg/pkg_rpm.rb
105
134
  - lib/devinstall/provider.rb
135
+ - lib/devinstall/provider/provider_local.rb
106
136
  - lib/devinstall/provider/provider_ssh.rb
107
137
  - lib/devinstall/settings.rb
108
138
  - lib/devinstall/utils.rb
109
139
  - lib/devinstall/version.rb
110
- - spec/pkg_spec.rb
111
- - spec/provider_spec.rb
112
- - spec/settings_spec.rb
140
+ - spec/assets/devinstall/debian/changelog
141
+ - spec/assets/example_01.yml
142
+ - spec/assets/example_02.yml
143
+ - spec/spec_helper.rb
144
+ - spec/support/01_settings_spec.rb
145
+ - spec/support/02_pkg_spec.rb
146
+ - spec/support/03_provider_spec.rb
113
147
  homepage: http://github.com/dboca/devinstall
114
148
  licenses:
115
149
  - MIT
@@ -136,6 +170,10 @@ specification_version: 4
136
170
  summary: Copy the source files to a build host, build the packages and install builded
137
171
  packages
138
172
  test_files:
139
- - spec/pkg_spec.rb
140
- - spec/provider_spec.rb
141
- - spec/settings_spec.rb
173
+ - spec/assets/devinstall/debian/changelog
174
+ - spec/assets/example_01.yml
175
+ - spec/assets/example_02.yml
176
+ - spec/spec_helper.rb
177
+ - spec/support/01_settings_spec.rb
178
+ - spec/support/02_pkg_spec.rb
179
+ - spec/support/03_provider_spec.rb
data/spec/pkg_spec.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'rspec'
2
- require 'devinstall'
3
-
4
- describe 'Packages' do
5
- config=Devinstall::Settings.instance
6
- config.load! './doc/example.yml' ## use defaults for type and env
7
-
8
- package=:devinstall
9
- type=:deb
10
- env=nil
11
-
12
- it 'should include the correct file' do
13
- pk=Devinstall::Package.new(package, type, env)
14
- expect(pk.singleton_class.include?(Pkg::Deb)).to be_true
15
- end
16
- end
@@ -1,80 +0,0 @@
1
- require 'rspec'
2
-
3
- require 'devinstall/settings'
4
-
5
- describe 'Settings' do
6
- config=Devinstall::Settings.instance
7
- config.load! './doc/example.yml' ## use defaults for type and env
8
-
9
- package=:devinstall
10
- type=:deb
11
- env=nil
12
-
13
- $verbose=true
14
-
15
- it 'should load an existig file' do
16
- expect(config.load!('doc/example.yml')).to be_true
17
- end
18
-
19
- it 'should not load an unexisting file' do
20
- expect(config.load!('doc/unexisting.yml')).to be_false
21
- end
22
-
23
- it 'should load at init' do
24
- expect(config).to be_an_instance_of(Devinstall::Settings)
25
- [:defaults, :local, :build, :install, :tests, :repos].each do |p|
26
- expect(config.respond_to? p).to be_true
27
- end # all sections loaded!
28
- end
29
-
30
- it 'should have a method defaults' do
31
- expect(config.respond_to? :defaults).to be_true
32
- end
33
-
34
- it 'the method "defaults" should have only one argument' do
35
- expect(config.defaults(:type)).to eq "deb"
36
- end
37
-
38
- it 'should instantiate a new "Action" when hashes are given' do
39
- expect(config.build(type:'deb', env:'dev', pkg:package)).to be_an_instance_of(Devinstall::Settings::Action)
40
- end
41
-
42
- it 'should instantiata a new "Action" when partial hashes are given' do
43
- expect(config.build(pkg:package)).to be_an_instance_of(Devinstall::Settings::Action)
44
- end
45
-
46
- it 'should raise "UnknownKeys" errors for unknown keys' do
47
- expect{config.defaults :none}.to raise_error(Devinstall::UnknownKeyError)
48
- end
49
-
50
- it 'should raise "KeyNotDefinedError" errors for undefined keys' do
51
- expect{config.tests(:provider, pkg:package)}.to raise_error(Devinstall::KeyNotDefinedError)
52
- end
53
-
54
- it 'should produce a value if all arguments are valid' do
55
- expect(config.build(:command, pkg:package)).to eq('cd %f/%p && dpkg-buildpackage')
56
- end
57
- end
58
- describe "Action" do
59
- config=Devinstall::Settings.instance
60
- config.load! './doc/example.yml' ## use defaults for type and env
61
-
62
- package=:devinstall
63
- type=:deb
64
- env=nil
65
-
66
- $verbose=true
67
-
68
- it 'should have a [] method' do
69
- rr=config.build(pkg:package, type:type, env:env)
70
- expect(rr[:target]).to eq('rs')
71
- end
72
-
73
- it 'should enumerate all defined values' do
74
- ar=[]
75
- config.build(pkg:package, type:type, env:env).each do |k,_|
76
- ar << k
77
- end
78
- expect(ar.sort == [:folder, :command, :provider, :type, :arch, :target].sort ).to be_true
79
- end
80
- end