albacore 2.0.0.rc.13 → 2.0.0.rc.14
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -0
- data/lib/albacore/app_spec.rb +176 -0
- data/lib/albacore/dsl.rb +11 -0
- data/lib/albacore/fpm_app_spec.rb +118 -0
- data/lib/albacore/project.rb +14 -2
- data/lib/albacore/version.rb +1 -1
- data/spec/app_spec_spec.rb +145 -0
- data/spec/dsl_spec.rb +1 -1
- data/spec/fpm_app_spec_spec.rb +156 -0
- data/spec/testdata/Project/Project.appspec +1 -0
- metadata +11 -3
data/README.md
CHANGED
@@ -337,6 +337,19 @@ filesystem:
|
|
337
337
|
+ Files not in src/MyMvcSite/MyMvcSite.csproj but on filesystem:
|
338
338
|
file_missing_in_csproj.png
|
339
339
|
|
340
|
+
## Writing Code
|
341
|
+
|
342
|
+
1. Add a rspec spec in specs/
|
343
|
+
1. Run `bundle exec rspec spec` to verify test fails
|
344
|
+
1. Implement feature you want
|
345
|
+
1. Run the tests again, have them pass
|
346
|
+
1. Make a PR from your feature branch against `master`
|
347
|
+
|
348
|
+
Document your code with
|
349
|
+
[YARD](http://rubydoc.info/gems/yard/file/docs/GettingStarted.md) as you're
|
350
|
+
writing it: it's much easier to write the documentation together with the code
|
351
|
+
than afterwards.
|
352
|
+
|
340
353
|
## Docs: Zippy
|
341
354
|
|
342
355
|
This is a simple example which uses rubyzip to recursively generate a zip file
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'albacore/logging'
|
3
|
+
require 'xsemver'
|
4
|
+
|
5
|
+
module Albacore
|
6
|
+
# a spec object
|
7
|
+
class AppSpec
|
8
|
+
include ::Albacore::Logging
|
9
|
+
|
10
|
+
# Create a new app spec from yaml data; will use heuristics to let the
|
11
|
+
# developer avoid as much typing and definition mongering as possible; for
|
12
|
+
# details see the unit tests and the documentation for this class.
|
13
|
+
#
|
14
|
+
# @descriptor_path [String] The location of the descriptor file (the .appspec)
|
15
|
+
# @data [String] A yaml-containing string
|
16
|
+
# @semver [::XSemVer] An optional semver instance that can be queried for what
|
17
|
+
# version the package has.
|
18
|
+
def initialize descriptor_path, data, semver = nil
|
19
|
+
raise ArgumentError, 'data is nil' unless data
|
20
|
+
@path = descriptor_path
|
21
|
+
@conf = YAML.load(data) || Hash.new
|
22
|
+
|
23
|
+
project_path = resolve_project descriptor_path, @conf
|
24
|
+
raise ArgumentError, "couldn't find project, descriptor_path: #{descriptor_path.inspect}" unless valid_path project_path
|
25
|
+
|
26
|
+
@proj = Project.new project_path
|
27
|
+
@semver = semver
|
28
|
+
end
|
29
|
+
|
30
|
+
# Resolves the project file given an optional descriptor path or a
|
31
|
+
# configuration hash or both. One of the other of the parameters need to
|
32
|
+
# exist, or an error will be thrown.
|
33
|
+
#
|
34
|
+
# @param descriptor_path May be nil
|
35
|
+
# @param conf [#[]] A hash or something indexable
|
36
|
+
def resolve_project descriptor_path, conf
|
37
|
+
trace { "trying to resolve project, descriptor_path: #{descriptor_path.inspect}, conf: #{conf.inspect} [AppSpec#resolve_path]" }
|
38
|
+
|
39
|
+
project_path = conf['project_path']
|
40
|
+
return File.join File.dirname(descriptor_path), project_path if project_path and valid_path descriptor_path
|
41
|
+
|
42
|
+
trace { 'didn\'t have both a project_path and a descriptor_path that was valid [AppSpec#resolve_project]' }
|
43
|
+
return project_path if project_path
|
44
|
+
find_first_project descriptor_path
|
45
|
+
end
|
46
|
+
|
47
|
+
# Given a descriptor path, tries to find the first matching project file. If
|
48
|
+
# you have multiple project files, the order of which {Dir#glob} returns
|
49
|
+
# values will determine which is chosen
|
50
|
+
def find_first_project descriptor_path
|
51
|
+
trace { "didn't have a valid project_path, trying to find first project at #{descriptor_path.inspect}" }
|
52
|
+
dir = File.dirname descriptor_path
|
53
|
+
abs_dir = File.expand_path dir
|
54
|
+
Dir.glob(File.join(abs_dir, '*proj')).first
|
55
|
+
end
|
56
|
+
|
57
|
+
# path of the *.appspec
|
58
|
+
attr_reader :path
|
59
|
+
|
60
|
+
# the loaded configuration in that appspec
|
61
|
+
attr_reader :conf
|
62
|
+
|
63
|
+
# the project the spec applies to
|
64
|
+
attr_reader :proj
|
65
|
+
|
66
|
+
# gets the fully qualified path of the directory where the appspec file is
|
67
|
+
def dir_path
|
68
|
+
File.expand_path(File.dirname(@path))
|
69
|
+
end
|
70
|
+
|
71
|
+
# title for puppet, title for app, title for process running on server
|
72
|
+
def title
|
73
|
+
t = conf['title'] || proj.title
|
74
|
+
t.downcase
|
75
|
+
end
|
76
|
+
|
77
|
+
# the description that is used when installing and reading about the package in the
|
78
|
+
# package manager
|
79
|
+
def description
|
80
|
+
conf['description'] || proj.description
|
81
|
+
end
|
82
|
+
|
83
|
+
# gets the uri source of the project
|
84
|
+
def uri
|
85
|
+
conf['uri'] || git_source
|
86
|
+
end
|
87
|
+
|
88
|
+
# gets the category this package is in, both for the RPM and for puppet and
|
89
|
+
# for possibly assigning to a work-stealing cluster or to start the app in
|
90
|
+
# the correct node-cluster if you have that implemented
|
91
|
+
def category
|
92
|
+
conf['category'] || 'apps'
|
93
|
+
end
|
94
|
+
|
95
|
+
# gets the license that the app is licensed under
|
96
|
+
def license
|
97
|
+
conf['license'] || proj.license
|
98
|
+
end
|
99
|
+
|
100
|
+
# gets the version with the following priorities:
|
101
|
+
# - semver version passed in c'tor
|
102
|
+
# - ENV['BUILD_VERSION']
|
103
|
+
# - .appspec's version
|
104
|
+
# - .xxproj's version
|
105
|
+
# - semver from disk
|
106
|
+
# - if all above fails; use '1.0.0'
|
107
|
+
def version
|
108
|
+
semver_version || ENV['BUILD_VERSION'] || conf['version'] || proj.version || semver_disk_version || '1.0.0'
|
109
|
+
end
|
110
|
+
|
111
|
+
# gets the binary folder, first from .appspec then from proj given a configuration
|
112
|
+
# mode (default: Release)
|
113
|
+
def bin_folder configuration = 'Release'
|
114
|
+
conf['bin'] || proj.output_path(configuration)
|
115
|
+
end
|
116
|
+
|
117
|
+
# gets the folder that is used to keep configuration that defaults
|
118
|
+
# to the current (.) directory
|
119
|
+
def conf_folder
|
120
|
+
conf['conf_folder'] || '.'
|
121
|
+
end
|
122
|
+
|
123
|
+
# gets an enumerable list of paths that are the 'main' contents of the package
|
124
|
+
#
|
125
|
+
def contents
|
126
|
+
conf['contents'] || []
|
127
|
+
end
|
128
|
+
|
129
|
+
# TODO: support a few of these: https://github.com/bernd/fpm-cookery/wiki/Recipe-Specification
|
130
|
+
|
131
|
+
# load the App Spec from a descriptor path
|
132
|
+
def self.load descriptor_path
|
133
|
+
raise ArgumentError, 'missing parameter descriptor_path' unless descriptor_path
|
134
|
+
raise ArgumentError, 'descriptor_path does not exist' unless File.exists? descriptor_path
|
135
|
+
AppSpec.new(descriptor_path, File.read(descriptor_path))
|
136
|
+
end
|
137
|
+
|
138
|
+
# Customizing the to_s implementation to make the spec more amenable for printing
|
139
|
+
def to_s
|
140
|
+
"AppSpec[#{title}], #{@conf.keys.length} keys]"
|
141
|
+
end
|
142
|
+
|
143
|
+
private
|
144
|
+
# determines whether the passed path is valid and existing
|
145
|
+
def valid_path path
|
146
|
+
path and File.exists? path
|
147
|
+
end
|
148
|
+
|
149
|
+
# gets the source from the current git repository: finds the first remote and uses
|
150
|
+
# that as the source of the RPM
|
151
|
+
def git_source
|
152
|
+
`git remote -v`.
|
153
|
+
split(/\n/).
|
154
|
+
map(&:chomp).
|
155
|
+
map { |s| s.split(/\t/)[1].split(/ /)[0] }.
|
156
|
+
first
|
157
|
+
end
|
158
|
+
|
159
|
+
# Gets the semver version in %M.%m.%p form or nil if a semver isn't given
|
160
|
+
# in the c'tor of this class. If we have gotten an explicit version in the constructor,
|
161
|
+
# let's assume that version should be used in front of anything else and that the calling
|
162
|
+
# libraries know what they are doing.
|
163
|
+
def semver_version
|
164
|
+
return @semver.format '%M.%m.%p' if @semver
|
165
|
+
nil
|
166
|
+
end
|
167
|
+
|
168
|
+
# if everything else fails, return the semver from disk
|
169
|
+
def semver_disk_version
|
170
|
+
v = XSemVer::SemVer.find
|
171
|
+
v.format '%M.%m.%p' if v
|
172
|
+
rescue SemVerMissingError
|
173
|
+
nil
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
data/lib/albacore/dsl.rb
CHANGED
@@ -20,6 +20,7 @@ module Albacore
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def asmver_files *args, &block
|
23
|
+
require 'albacore/task_types/asmver'
|
23
24
|
Albacore.define_task *args do
|
24
25
|
c = Albacore::Asmver::MultipleFilesConfig.new
|
25
26
|
yield c
|
@@ -93,6 +94,16 @@ module Albacore
|
|
93
94
|
t.execute
|
94
95
|
end
|
95
96
|
end
|
97
|
+
|
98
|
+
# Generate .rpm or .deb files from .appspec files
|
99
|
+
def fpm_gen *args, &block
|
100
|
+
require 'albacore/fpm_app_spec'
|
101
|
+
Albacore.define_task *args do
|
102
|
+
c = ::Albacore::FpmAppSpec::Config.new
|
103
|
+
yield c
|
104
|
+
::Albacore::FpmAppSpec::Task.new(c.opts).execute
|
105
|
+
end
|
106
|
+
end
|
96
107
|
end
|
97
108
|
end
|
98
109
|
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'albacore/app_spec'
|
2
|
+
require 'map'
|
3
|
+
|
4
|
+
module Albacore
|
5
|
+
class InvalidAppSpecError < ::StandardError
|
6
|
+
end
|
7
|
+
|
8
|
+
# An object that is capable of generating FPM commands - use by giving it a
|
9
|
+
# spec and then calling #execute or #generate_flags. You may use this object
|
10
|
+
# to package a directory.
|
11
|
+
#
|
12
|
+
class FpmAppSpec
|
13
|
+
include ::Albacore::Logging
|
14
|
+
|
15
|
+
# Initialize the object with an ::Albacore::AppSpec
|
16
|
+
#
|
17
|
+
# @param [::Albacore::AppSpec] app_spec The required package metadata.
|
18
|
+
# @param [PathWrap, String] output_dir_path The output path of the rpm/deb
|
19
|
+
# package.
|
20
|
+
def initialize app_spec, output_dir_path = '.'
|
21
|
+
raise ArgumentError, 'missing app_spec parameter' unless app_spec
|
22
|
+
@spec = app_spec
|
23
|
+
@out = output_dir_path
|
24
|
+
end
|
25
|
+
|
26
|
+
# Generate flags for FPM - if you don't want to execute directly with the object
|
27
|
+
# you can use this method to generate what you should give to FPM yourself
|
28
|
+
#
|
29
|
+
def generate_flags overrides = {}
|
30
|
+
{ '-s' => 'dir',
|
31
|
+
'-t' => 'rpm',
|
32
|
+
'--name' => @spec.title,
|
33
|
+
'--description' => @spec.description,
|
34
|
+
'--url' => @spec.uri,
|
35
|
+
'--category' => @spec.category,
|
36
|
+
'--version' => @spec.version,
|
37
|
+
'--epoch' => 1,
|
38
|
+
'--license' => @spec.license,
|
39
|
+
'-C' => @spec.dir_path,
|
40
|
+
'--depends' => 'mono',
|
41
|
+
'--rpm-digest' => 'sha256',
|
42
|
+
'--package' => @out
|
43
|
+
}.merge(overrides).reject { |_, v| v.nil? }
|
44
|
+
end
|
45
|
+
|
46
|
+
# Generates the flags and flatten them to an array that is possible to feed
|
47
|
+
# into the #system command
|
48
|
+
#
|
49
|
+
def generate_flags_flat overrides = {}
|
50
|
+
generate_flags(overrides).map { |k, v| [k, v] }.concat(%w|--force .|).flatten
|
51
|
+
end
|
52
|
+
|
53
|
+
# gets the filename that the resulting file will have, based on the flags
|
54
|
+
# to be passed to fpm
|
55
|
+
def filename flags = nil
|
56
|
+
flags ||= generate_flags
|
57
|
+
# TODO: handle OS architecture properly by taking from context
|
58
|
+
"#{flags['--name']}-#{flags['--version']}-#{flags['--epoch']}.x86_64.rpm"
|
59
|
+
end
|
60
|
+
|
61
|
+
# Calls FPM with the flags generated
|
62
|
+
def generate
|
63
|
+
::Albacore::CrossPlatformCmd.system 'fpm', generate_flags_flat
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class FpmAppSpec::Config
|
68
|
+
# create a new configuration for multiple xxproj-s to be packed with fpm into .deb/.rpm
|
69
|
+
def initialize
|
70
|
+
@bundler = true
|
71
|
+
end
|
72
|
+
|
73
|
+
# turn off the using of bundler; bundler will be used by default
|
74
|
+
def no_bundler
|
75
|
+
@bundler = false
|
76
|
+
end
|
77
|
+
|
78
|
+
# set the output path, defaults to '.'
|
79
|
+
def out=
|
80
|
+
end
|
81
|
+
|
82
|
+
# give the configuration a list of files to match
|
83
|
+
def files=
|
84
|
+
end
|
85
|
+
|
86
|
+
def opts
|
87
|
+
Map.new bundler: @bundler
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# task implementation that can be #execute'd
|
92
|
+
class FpmAppSpec::Task
|
93
|
+
include ::Albacore::CrossPlatformCmd
|
94
|
+
|
95
|
+
# create a new task instance with the given opts
|
96
|
+
def initialize opts
|
97
|
+
raise ArgumentError, 'opts is nil' if opts.nil?
|
98
|
+
@opts = opts
|
99
|
+
end
|
100
|
+
|
101
|
+
# this runs fpm and does some file copying
|
102
|
+
def execute
|
103
|
+
# TODO: supporting multiple projects
|
104
|
+
|
105
|
+
if opts.get :bundler
|
106
|
+
system 'bundle', %w|exec fpm|.concat(opts.get(:fpm_spec).generate_flags_flat)
|
107
|
+
else
|
108
|
+
system 'fpm', opts.get(:fpm_spec).generate_flags_flat
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
# TODO: finish
|
114
|
+
def specs
|
115
|
+
@opts.files
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
data/lib/albacore/project.rb
CHANGED
@@ -28,6 +28,9 @@ module Albacore
|
|
28
28
|
prop || asmname
|
29
29
|
end
|
30
30
|
|
31
|
+
# The same as #name
|
32
|
+
alias_method :title, :name
|
33
|
+
|
31
34
|
# get the assembly name specified in the project file
|
32
35
|
def asmname
|
33
36
|
read_property 'AssemblyName'
|
@@ -35,14 +38,23 @@ module Albacore
|
|
35
38
|
|
36
39
|
# gets the version from the project file
|
37
40
|
def version
|
38
|
-
read_property
|
41
|
+
read_property 'Version'
|
39
42
|
end
|
40
43
|
|
41
44
|
# gets any authors from the project file
|
42
45
|
def authors
|
43
|
-
read_property
|
46
|
+
read_property 'Authors'
|
44
47
|
end
|
45
48
|
|
49
|
+
def description
|
50
|
+
read_property 'Description'
|
51
|
+
end
|
52
|
+
|
53
|
+
# the license that the project has defined in the metadata in the xxproj file.
|
54
|
+
def license
|
55
|
+
read_property 'License'
|
56
|
+
end
|
57
|
+
|
46
58
|
# gets the output path of the project given the configuration or raise
|
47
59
|
# an error otherwise
|
48
60
|
def output_path conf
|
data/lib/albacore/version.rb
CHANGED
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'xsemver'
|
2
|
+
require 'albacore/app_spec'
|
3
|
+
|
4
|
+
describe ::Albacore::AppSpec, 'public API with defaults' do
|
5
|
+
subject do
|
6
|
+
::Albacore::AppSpec.new 'missing-path', %{
|
7
|
+
---
|
8
|
+
title: superapp.now
|
9
|
+
project_path: spec/testdata/Project/Project.fsproj
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
%w|title description uri category version license dir_path to_s|.map { |w| :"#{w}" }.each do |s|
|
14
|
+
it "should respond to ##{s}" do
|
15
|
+
subject.should respond_to s
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should be possible to always call ##{s}" do
|
19
|
+
subject.method(s).call
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have correct title' do
|
24
|
+
subject.title.should eq 'superapp.now'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have nil license' do
|
28
|
+
subject.license.should be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should have nil description' do
|
32
|
+
subject.description.should be_nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should never have nil uri, since we\'re in the albacore git repo and it defaults to the current repo' do
|
36
|
+
subject.uri.should include 'albacore.git'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should have "apps" category, since it\'s not specified anywhere' do
|
40
|
+
subject.category.should eq 'apps'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should have a nil version' do
|
44
|
+
subject.version.should eq('1.0.0')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should have non-nil #bin_folder' do
|
48
|
+
subject.bin_folder.should_not be_nil
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should have non-nil #conf_folder' do
|
52
|
+
subject.conf_folder.should_not be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should have non-nil #contents' do
|
56
|
+
subject.contents.should_not be_nil
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should have a #contents that responds to #each' do
|
60
|
+
subject.contents.should respond_to :each
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe ::Albacore::AppSpec, 'public API with required fields' do
|
65
|
+
subject do
|
66
|
+
::Albacore::AppSpec.new 'missing-.appspec-path', %{
|
67
|
+
---
|
68
|
+
title: superapp.now
|
69
|
+
project_path: spec/testdata/Project/Project.fsproj
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
# TODO: create a spike that actually works and document what is required here
|
74
|
+
end
|
75
|
+
|
76
|
+
describe ::Albacore::AppSpec, 'when getting version from semver' do
|
77
|
+
subject do
|
78
|
+
::Albacore::AppSpec.new 'missing-.appspec-path', %{
|
79
|
+
---
|
80
|
+
title: zeeky
|
81
|
+
version: 4.5.6
|
82
|
+
project_path: spec/testdata/Project/Project.fsproj
|
83
|
+
}, XSemVer::SemVer.new(1,2,3)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should take version from the semver first' do
|
87
|
+
subject.version.should eq '1.2.3'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe ::Albacore::AppSpec, 'when getting version from yaml' do
|
92
|
+
subject do
|
93
|
+
::Albacore::AppSpec.new 'missing-.appspec-path', %{
|
94
|
+
---
|
95
|
+
title: smurfs.abound
|
96
|
+
version: 4.5.6
|
97
|
+
project_path: spec/testdata/Project/Project.fsproj
|
98
|
+
}, nil
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should take version from the semver first' do
|
102
|
+
subject.version.should eq '4.5.6'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe ::Albacore::AppSpec, 'when giving invalid project path' do
|
107
|
+
it 'should raise ArgumentError when path doesn\'t exist' do
|
108
|
+
expect {
|
109
|
+
::Albacore::AppSpec.new 'missing-.appspec-path', %{---
|
110
|
+
project_path: path/not/existent/proj.fsproj}, nil
|
111
|
+
}.to raise_error(ArgumentError)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should raise ArgumentError when no value given' do
|
115
|
+
expect {
|
116
|
+
::Albacore::AppSpec.new 'missing-.appspec-path', %{---
|
117
|
+
title: my.project}, nil
|
118
|
+
}.to raise_error(ArgumentError)
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
describe ::Albacore::AppSpec, 'when fetching ALL data from Project.fsproj' do
|
124
|
+
let :project_path do
|
125
|
+
'spec/testdata/Project/Project.appspec'
|
126
|
+
end
|
127
|
+
|
128
|
+
subject do
|
129
|
+
::Albacore::AppSpec.load project_path
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should find the directory of the project' do
|
133
|
+
# this also means it found a project and successfully parsed its project
|
134
|
+
# definition
|
135
|
+
subject.proj.proj_path_base.should include File.dirname(project_path)
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should have the title' do
|
139
|
+
subject.title.should eq 'project'
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should have no license' do
|
143
|
+
subject.license.should be_nil
|
144
|
+
end
|
145
|
+
end
|
data/spec/dsl_spec.rb
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
|
15
15
|
#puts "X has methods: #{X.new.private_methods.inspect}"
|
16
16
|
|
17
|
-
%w[nugets_restore nugets_pack asmver build test_runner restore_hint_paths].each do |sym|
|
17
|
+
%w[nugets_restore nugets_pack asmver build test_runner restore_hint_paths fpm_gen].each do |sym|
|
18
18
|
method = :"#{sym}"
|
19
19
|
describe "that #{method}(*args, &block) is included when doing `require 'albacore'`" do
|
20
20
|
subject do
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'xsemver'
|
2
|
+
require 'albacore/app_spec'
|
3
|
+
require 'albacore/fpm_app_spec'
|
4
|
+
|
5
|
+
shared_context 'valid AppSpec' do
|
6
|
+
let :spec do
|
7
|
+
::Albacore::AppSpec.new '/a/b/c.appspec', %{
|
8
|
+
---
|
9
|
+
title: my.app
|
10
|
+
project_path: spec/testdata/Project/Project.fsproj
|
11
|
+
version: 1.2.3
|
12
|
+
license: MIT
|
13
|
+
description: my.app implements much wow
|
14
|
+
uri: https://github.com/Albacore/albacore
|
15
|
+
category: webserver
|
16
|
+
}, XSemVer::SemVer.new(5, 6, 7)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ::Albacore::FpmAppSpec, 'public API' do
|
21
|
+
include_context 'valid AppSpec'
|
22
|
+
|
23
|
+
subject do
|
24
|
+
::Albacore::FpmAppSpec.new spec
|
25
|
+
end
|
26
|
+
|
27
|
+
it do
|
28
|
+
should respond_to :filename
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should know resulting filename' do
|
32
|
+
subject.filename.should eq('my.app-5.6.7-1.x86_64.rpm')
|
33
|
+
end
|
34
|
+
|
35
|
+
it do
|
36
|
+
should respond_to :generate
|
37
|
+
end
|
38
|
+
|
39
|
+
it do
|
40
|
+
should respond_to :generate_flags
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
describe ::Albacore::FpmAppSpec, 'when generating command from valid AppSpec' do
|
46
|
+
include_context 'valid AppSpec'
|
47
|
+
|
48
|
+
subject do
|
49
|
+
::Albacore::FpmAppSpec.new spec
|
50
|
+
end
|
51
|
+
|
52
|
+
let :flags do
|
53
|
+
subject.generate_flags
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should generate command source' do
|
57
|
+
flags['-s'].should eq 'dir'
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should generate command target' do
|
61
|
+
flags['-t'].should eq 'rpm'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should generate command name/title' do
|
65
|
+
flags['--name'].should eq 'my.app'
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should generate command description' do
|
69
|
+
flags['--description'].should eq 'my.app implements much wow'
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should generate command url' do
|
73
|
+
flags['--url'].should eq 'https://github.com/Albacore/albacore'
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should generate command category' do
|
77
|
+
flags['--category'].should eq 'webserver'
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should generate command version' do
|
81
|
+
flags['--version'].should eq '5.6.7'
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should generate command epoch' do
|
85
|
+
flags['--epoch'].should eq 1
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should generate command license' do
|
89
|
+
flags['--license'].should eq 'MIT'
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should generate command "look in this directory" flag' do
|
93
|
+
flags['-C'].should eq '/a/b'
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should generate command depends' do
|
97
|
+
flags['--depends'].should eq 'mono'
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should generate command rpm-digest' do
|
101
|
+
flags['--rpm-digest'].should eq 'sha256'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe ::Albacore::FpmAppSpec, 'validation method' do
|
106
|
+
include_context 'valid AppSpec'
|
107
|
+
|
108
|
+
subject do
|
109
|
+
# TODO: construct
|
110
|
+
end
|
111
|
+
# TODO: to validate
|
112
|
+
end
|
113
|
+
|
114
|
+
describe ::Albacore::FpmAppSpec, 'when generating command from in-valid AppSpec' do
|
115
|
+
let :spec do
|
116
|
+
::Albacore::AppSpec.new 'missing descriptor path', %{
|
117
|
+
---
|
118
|
+
title: my.app
|
119
|
+
project_path: spec/testdata/Project/Project.fsproj
|
120
|
+
}, XSemVer::SemVer.new(5, 6, 7)
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should raise InvalidAppSpecError' do
|
124
|
+
expect { ::Albacore::FpmAppSpec.new spec }.to raise_error ::Albacore::InvalidAppSpecError
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe ::Albacore::FpmAppSpec, 'should never generate nils' do
|
129
|
+
let :spec do
|
130
|
+
::Albacore::AppSpec.new 'missing descriptor path', %{
|
131
|
+
---
|
132
|
+
title: my.app
|
133
|
+
project_path: spec/testdata/Project/Project.fsproj
|
134
|
+
}, XSemVer::SemVer.new(5, 6, 7)
|
135
|
+
end
|
136
|
+
|
137
|
+
subject do
|
138
|
+
::Albacore::FpmAppSpec.new spec
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'should not have a license' do
|
142
|
+
spec.license.should be_nil
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'that license should never be a FPM parameter' do
|
146
|
+
subject.generate_flags.has_key?('--license').should be_false
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe ::Albacore::FpmAppSpec::Config do
|
151
|
+
%w|files= out= opts no_bundler|.each do |sym|
|
152
|
+
it "should respond_to :#{sym}" do
|
153
|
+
should respond_to :"#{sym}"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
---
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: albacore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.rc.
|
4
|
+
version: 2.0.0.rc.14
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-04-
|
13
|
+
date: 2014-04-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- albacore.gemspec
|
177
177
|
- lib/albacore.rb
|
178
178
|
- lib/albacore/albacore_module.rb
|
179
|
+
- lib/albacore/app_spec.rb
|
179
180
|
- lib/albacore/application.rb
|
180
181
|
- lib/albacore/cmd_config.rb
|
181
182
|
- lib/albacore/config_dsl.rb
|
@@ -187,6 +188,7 @@ files:
|
|
187
188
|
- lib/albacore/ext/README.md
|
188
189
|
- lib/albacore/ext/teamcity.rb
|
189
190
|
- lib/albacore/facts.rb
|
191
|
+
- lib/albacore/fpm_app_spec.rb
|
190
192
|
- lib/albacore/logging.rb
|
191
193
|
- lib/albacore/nuget_model.rb
|
192
194
|
- lib/albacore/package.rb
|
@@ -218,6 +220,7 @@ files:
|
|
218
220
|
- lib/albacore/version.rb
|
219
221
|
- spec/Rakefile
|
220
222
|
- spec/albacore_spec.rb
|
223
|
+
- spec/app_spec_spec.rb
|
221
224
|
- spec/asmver_spec.rb
|
222
225
|
- spec/asmver_task_spec.rb
|
223
226
|
- spec/build_spec.rb
|
@@ -226,6 +229,7 @@ files:
|
|
226
229
|
- spec/dsl_spec.rb
|
227
230
|
- spec/ext_teamcity_spec.rb
|
228
231
|
- spec/facts_spec.rb
|
232
|
+
- spec/fpm_app_spec_spec.rb
|
229
233
|
- spec/nuget_model_spec.rb
|
230
234
|
- spec/nugets_pack_spec.rb
|
231
235
|
- spec/nugets_restore_spec.rb
|
@@ -277,6 +281,7 @@ files:
|
|
277
281
|
- spec/testdata/Gemfile
|
278
282
|
- spec/testdata/NuGet.exe
|
279
283
|
- spec/testdata/Project/Library1.fs
|
284
|
+
- spec/testdata/Project/Project.appspec
|
280
285
|
- spec/testdata/Project/Project.fsproj
|
281
286
|
- spec/testdata/Project/Project.sln
|
282
287
|
- spec/testdata/Project/Project.v11.suo
|
@@ -317,7 +322,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
317
322
|
version: '0'
|
318
323
|
segments:
|
319
324
|
- 0
|
320
|
-
hash:
|
325
|
+
hash: -504786499595810367
|
321
326
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
322
327
|
none: false
|
323
328
|
requirements:
|
@@ -333,6 +338,7 @@ summary: Dolphin-safe and awesome Mono and .Net Rake-tasks
|
|
333
338
|
test_files:
|
334
339
|
- spec/Rakefile
|
335
340
|
- spec/albacore_spec.rb
|
341
|
+
- spec/app_spec_spec.rb
|
336
342
|
- spec/asmver_spec.rb
|
337
343
|
- spec/asmver_task_spec.rb
|
338
344
|
- spec/build_spec.rb
|
@@ -341,6 +347,7 @@ test_files:
|
|
341
347
|
- spec/dsl_spec.rb
|
342
348
|
- spec/ext_teamcity_spec.rb
|
343
349
|
- spec/facts_spec.rb
|
350
|
+
- spec/fpm_app_spec_spec.rb
|
344
351
|
- spec/nuget_model_spec.rb
|
345
352
|
- spec/nugets_pack_spec.rb
|
346
353
|
- spec/nugets_restore_spec.rb
|
@@ -392,6 +399,7 @@ test_files:
|
|
392
399
|
- spec/testdata/Gemfile
|
393
400
|
- spec/testdata/NuGet.exe
|
394
401
|
- spec/testdata/Project/Library1.fs
|
402
|
+
- spec/testdata/Project/Project.appspec
|
395
403
|
- spec/testdata/Project/Project.fsproj
|
396
404
|
- spec/testdata/Project/Project.sln
|
397
405
|
- spec/testdata/Project/Project.v11.suo
|