build_number 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +41 -41
- data/.semver +2 -2
- data/Gemfile.lock +29 -29
- data/README.md +40 -40
- data/Rakefile +5 -5
- data/build_number.gemspec +25 -25
- data/lib/build_number.rb +68 -68
- data/lib/build_number/version.rb +3 -3
- data/spec/build_number_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTVkNWYxZDk0MTIyZWYzNzM4MGU4MDU3NDRkNDViYjczNjQ5NTY5Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZThiN2JmZTBhOTJmNWU2MGQ5MzYzZDlkNTE3MjNmMDE2OTBiNjMxOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWZiNjIyM2QzMDY1YmNkMjExODhmMDIyYmU4NTQxMzVjZTFjN2Y4MjY2N2Qw
|
10
|
+
MDdkODcyY2ZjN2YxY2ZlZDExMmQ3NGRiNGM1NzBjODYxZjVlMzcyZDQ3M2Zj
|
11
|
+
ZmNkODE5YWM0Y2I4OTQ0M2I5OTM0NGJhMWFhNmRjNjBhNTBiNDQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDFlOGFhNTY4YTFiYmJjNWZhY2EwZjkwMzk1NjhlMzcxOWJlMmNhMzM5MjMw
|
14
|
+
ZDA2ZGRhNmNjMzY1OWUxM2Q1MjE1OTE2YjA3NGNiZTk0ZWUzMjVlOGQ3Zjcz
|
15
|
+
OWRlODY2Zjc4NmEyZGU0MDNlYWNiY2RiYjBhZmVjYmJlNzhlMjA=
|
data/.gitignore
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
/.config
|
4
|
-
/coverage/
|
5
|
-
/InstalledFiles
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/test/tmp/
|
9
|
-
/test/version_tmp/
|
10
|
-
/tmp/
|
11
|
-
|
12
|
-
## Specific to RubyMotion:
|
13
|
-
.dat*
|
14
|
-
.repl_history
|
15
|
-
build/
|
16
|
-
|
17
|
-
## Documentation cache and generated files:
|
18
|
-
/.yardoc/
|
19
|
-
/_yardoc/
|
20
|
-
/doc/
|
21
|
-
/rdoc/
|
22
|
-
|
23
|
-
## Environment normalisation:
|
24
|
-
/.bundle/
|
25
|
-
/lib/bundler/man/
|
26
|
-
|
27
|
-
# for a library or gem, you might want to ignore these files since the code is
|
28
|
-
# intended to run in multiple environments; otherwise, check them in:
|
29
|
-
# Gemfile.lock
|
30
|
-
# .ruby-version
|
31
|
-
# .ruby-gemset
|
32
|
-
|
33
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
-
.rvmrc
|
35
|
-
|
36
|
-
# RubyMine files
|
37
|
-
.idea/
|
38
|
-
|
39
|
-
# build number
|
40
|
-
.build_number
|
41
|
-
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
35
|
+
|
36
|
+
# RubyMine files
|
37
|
+
.idea/
|
38
|
+
|
39
|
+
# build number
|
40
|
+
.build_number
|
41
|
+
|
data/.semver
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
build_number (0.1.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.2.5)
|
10
|
-
rake (10.3.2)
|
11
|
-
rspec (2.14.1)
|
12
|
-
rspec-core (~> 2.14.0)
|
13
|
-
rspec-expectations (~> 2.14.0)
|
14
|
-
rspec-mocks (~> 2.14.0)
|
15
|
-
rspec-core (2.14.8)
|
16
|
-
rspec-expectations (2.14.5)
|
17
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
18
|
-
rspec-mocks (2.14.6)
|
19
|
-
semver2 (3.3.3)
|
20
|
-
|
21
|
-
PLATFORMS
|
22
|
-
x86-mingw32
|
23
|
-
|
24
|
-
DEPENDENCIES
|
25
|
-
build_number!
|
26
|
-
bundler (~> 1.6)
|
27
|
-
rake
|
28
|
-
rspec
|
29
|
-
semver2
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
build_number (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.5)
|
10
|
+
rake (10.3.2)
|
11
|
+
rspec (2.14.1)
|
12
|
+
rspec-core (~> 2.14.0)
|
13
|
+
rspec-expectations (~> 2.14.0)
|
14
|
+
rspec-mocks (~> 2.14.0)
|
15
|
+
rspec-core (2.14.8)
|
16
|
+
rspec-expectations (2.14.5)
|
17
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
18
|
+
rspec-mocks (2.14.6)
|
19
|
+
semver2 (3.3.3)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
x86-mingw32
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
build_number!
|
26
|
+
bundler (~> 1.6)
|
27
|
+
rake
|
28
|
+
rspec
|
29
|
+
semver2
|
data/README.md
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
# build_number
|
2
|
-
|
3
|
-
Creates a `.build_number` file in your current directory which will store and increment the `BUILD_NUMBER`
|
4
|
-
environment variable. This is useful when you want to keep track of build numbers outside of a continuous integration
|
5
|
-
environment.
|
6
|
-
|
7
|
-
If the `BUILD_NUMBER` variable is already set, it will not be incremented.
|
8
|
-
|
9
|
-
## Installation
|
10
|
-
|
11
|
-
Add this line to your application's Gemfile:
|
12
|
-
|
13
|
-
gem 'build_number'
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install build_number
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
In your project's Rakefile:
|
26
|
-
|
27
|
-
```ruby
|
28
|
-
require 'build_number'
|
29
|
-
BuildNumber.set_env
|
30
|
-
|
31
|
-
# ENV['BUILD_NUMBER'] is now set and incremented for the next build!
|
32
|
-
```
|
33
|
-
|
34
|
-
## Contributing
|
35
|
-
|
36
|
-
1. Fork it ( https://github.com/scardetto/build_number/fork )
|
37
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
-
5. Create a new Pull Request
|
1
|
+
# build_number
|
2
|
+
|
3
|
+
Creates a `.build_number` file in your current directory which will store and increment the `BUILD_NUMBER`
|
4
|
+
environment variable. This is useful when you want to keep track of build numbers outside of a continuous integration
|
5
|
+
environment.
|
6
|
+
|
7
|
+
If the `BUILD_NUMBER` variable is already set, it will not be incremented.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'build_number'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install build_number
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
In your project's Rakefile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'build_number'
|
29
|
+
BuildNumber.set_env
|
30
|
+
|
31
|
+
# ENV['BUILD_NUMBER'] is now set and incremented for the next build!
|
32
|
+
```
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it ( https://github.com/scardetto/build_number/fork )
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create a new Pull Request
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec) do |c|
|
5
|
-
c.rspec_opts = %w(--color --format=doc)
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |c|
|
5
|
+
c.rspec_opts = %w(--color --format=doc)
|
6
6
|
end
|
data/build_number.gemspec
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'semver'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'build_number'
|
8
|
-
spec.version = SemVer.find.format '%M.%m.%p'
|
9
|
-
spec.authors = ['Rob Scaduto']
|
10
|
-
spec.email = ['rscaduto@thirdwave.it']
|
11
|
-
spec.summary = %q{Store and increment build numbers}
|
12
|
-
spec.description = %q{Library for storing and incrementing a build number in your local project directory.}
|
13
|
-
spec.homepage = 'http://github.com/scardetto/build_number'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ['lib']
|
20
|
-
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
|
-
spec.add_development_dependency 'rspec'
|
23
|
-
spec.add_development_dependency 'rake'
|
24
|
-
spec.add_development_dependency 'semver2'
|
25
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'semver'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'build_number'
|
8
|
+
spec.version = SemVer.find.format '%M.%m.%p'
|
9
|
+
spec.authors = ['Rob Scaduto']
|
10
|
+
spec.email = ['rscaduto@thirdwave.it']
|
11
|
+
spec.summary = %q{Store and increment build numbers}
|
12
|
+
spec.description = %q{Library for storing and incrementing a build number in your local project directory.}
|
13
|
+
spec.homepage = 'http://github.com/scardetto/build_number'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
|
+
spec.add_development_dependency 'rspec'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'semver2'
|
25
|
+
end
|
data/lib/build_number.rb
CHANGED
@@ -1,69 +1,69 @@
|
|
1
|
-
require 'build_number/version'
|
2
|
-
|
3
|
-
module BuildNumber
|
4
|
-
FILE_NAME = '.build_number'
|
5
|
-
|
6
|
-
def self.set_env(dir=nil)
|
7
|
-
ENV['BUILD_NUMBER'] = ENV['BUILD_NUMBER'] || increment(dir)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.increment(dir=nil)
|
11
|
-
file = find_or_create_file dir
|
12
|
-
|
13
|
-
read(file).tap do |current|
|
14
|
-
save file, current + 1
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.find_or_create_file(dir=nil)
|
19
|
-
dir ||= Dir.pwd
|
20
|
-
file = find_file dir
|
21
|
-
file = create_file dir if file.nil?
|
22
|
-
file
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.read(path)
|
26
|
-
file = File.open(path, 'rb')
|
27
|
-
current = file.read.chomp.to_i
|
28
|
-
file.close
|
29
|
-
current
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.save(path, next_build_number=0)
|
33
|
-
open(path, 'w') { |io| io.write next_build_number.to_s }
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def self.find_file(dir=nil)
|
39
|
-
raise "#{dir} is not a directory" unless File.directory? dir
|
40
|
-
file_path = file_name dir
|
41
|
-
|
42
|
-
Dir.chdir dir do
|
43
|
-
until File.exists? file_path do
|
44
|
-
return nil if is_root_path? file_path
|
45
|
-
file_path = parent_path file_path
|
46
|
-
end
|
47
|
-
return file_path
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.is_root_path?(path)
|
52
|
-
File.dirname(path).match(/(\w:\/|\/)$/i)
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.parent_path(path)
|
56
|
-
dir = File.join File.dirname(path), '..'
|
57
|
-
File.expand_path file_name(dir)
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.create_file(dir=nil)
|
61
|
-
file = file_name(dir)
|
62
|
-
save file
|
63
|
-
file
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.file_name(dir)
|
67
|
-
File.join dir, FILE_NAME
|
68
|
-
end
|
1
|
+
require 'build_number/version'
|
2
|
+
|
3
|
+
module BuildNumber
|
4
|
+
FILE_NAME = '.build_number'
|
5
|
+
|
6
|
+
def self.set_env(dir=nil)
|
7
|
+
ENV['BUILD_NUMBER'] = ENV['BUILD_NUMBER'] || increment(dir).to_s
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.increment(dir=nil)
|
11
|
+
file = find_or_create_file dir
|
12
|
+
|
13
|
+
read(file).tap do |current|
|
14
|
+
save file, current + 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find_or_create_file(dir=nil)
|
19
|
+
dir ||= Dir.pwd
|
20
|
+
file = find_file dir
|
21
|
+
file = create_file dir if file.nil?
|
22
|
+
file
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.read(path)
|
26
|
+
file = File.open(path, 'rb')
|
27
|
+
current = file.read.chomp.to_i
|
28
|
+
file.close
|
29
|
+
current
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.save(path, next_build_number=0)
|
33
|
+
open(path, 'w') { |io| io.write next_build_number.to_s }
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def self.find_file(dir=nil)
|
39
|
+
raise "#{dir} is not a directory" unless File.directory? dir
|
40
|
+
file_path = file_name dir
|
41
|
+
|
42
|
+
Dir.chdir dir do
|
43
|
+
until File.exists? file_path do
|
44
|
+
return nil if is_root_path? file_path
|
45
|
+
file_path = parent_path file_path
|
46
|
+
end
|
47
|
+
return file_path
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.is_root_path?(path)
|
52
|
+
File.dirname(path).match(/(\w:\/|\/)$/i)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.parent_path(path)
|
56
|
+
dir = File.join File.dirname(path), '..'
|
57
|
+
File.expand_path file_name(dir)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.create_file(dir=nil)
|
61
|
+
file = file_name(dir)
|
62
|
+
save file
|
63
|
+
file
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.file_name(dir)
|
67
|
+
File.join dir, FILE_NAME
|
68
|
+
end
|
69
69
|
end
|
data/lib/build_number/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module BuildNumber
|
2
|
-
VERSION = '0.1.
|
3
|
-
end
|
1
|
+
module BuildNumber
|
2
|
+
VERSION = '0.1.1'
|
3
|
+
end
|
data/spec/build_number_spec.rb
CHANGED
@@ -36,6 +36,11 @@ describe BuildNumber do
|
|
36
36
|
}.to raise_error
|
37
37
|
end
|
38
38
|
|
39
|
+
it "should set the 'BUILD_NUMBER' env var" do
|
40
|
+
BuildNumber.set_env @tmp_dir
|
41
|
+
ENV.include?('BUILD_NUMBER').should be_true
|
42
|
+
end
|
43
|
+
|
39
44
|
it "should not create a .build_number file if the 'BUILD_NUMBER' env var is already set" do
|
40
45
|
ENV['BUILD_NUMBER'] = random_build_number.to_s
|
41
46
|
BuildNumber.set_env @tmp_dir
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build_number
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Scaduto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|