set_version 0.1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +166 -0
- data/README.md +42 -0
- data/lib/set_version.rb +77 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 840ccce889ddf3a883ba834c392d4ec77b61de57
|
4
|
+
data.tar.gz: c5df3e87784c0249fcedc45770584551d39bd4cb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5abc0ae7e74650572c7348439aeb157512cf6c3a98deedb6bb6ed8b314deda8cb45f552a1a7001bf8cf3ebe667f788905760854b4b60a78d59ef9da4b0b02cb0
|
7
|
+
data.tar.gz: fc31fc57fc35ef42449afbd37e93f7afcc596d1f588b0779cf1f76c2c3332fea8487889728d16a917df357eba9d219f7a25c5bcf80af4e66477d8253522a7373
|
data/LICENSE
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
166
|
+
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# set_version
|
2
|
+
|
3
|
+
Make gem version with autoicrement build number.
|
4
|
+
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/set_version.svg)](http://badge.fury.io/rb/set_version)
|
6
|
+
[![GitHub license](https://img.shields.io/badge/license-LGPLv3-orange.svg?style=flat)](https://raw.githubusercontent.com/shikhalev/set_version/master/LICENSE)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/shikhalev/set_version/badges/gpa.svg)](https://codeclimate.com/github/shikhalev/set_version)
|
8
|
+
|
9
|
+
```Ruby
|
10
|
+
set_version *vers, git: false, message: 'Build #%<version>s', tag: false
|
11
|
+
```
|
12
|
+
|
13
|
+
* `vers` — version numbers: major, minor, patch; and beta-flag — String
|
14
|
+
or Symbol like 'alpha', 'beta', 'pre', 'rc' etc.
|
15
|
+
* `git:` — named parameter — boolean. If set to `true`, method will check
|
16
|
+
where gemspec is under git control, add `gemvers`-file to git, and commit
|
17
|
+
with `message`.
|
18
|
+
* `message:` — template for git commit message, can use named placeholders:
|
19
|
+
* `:version` — result full version;
|
20
|
+
* `:major`, `:minor`, `:patch` and `:beta` — parameters of calling;
|
21
|
+
* `:build` — build number.
|
22
|
+
* `tag:` — if `true` and git enabled it is adding tag named by version.
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
```Ruby
|
27
|
+
Gem::Specification.new do |g|
|
28
|
+
|
29
|
+
# some settings
|
30
|
+
# g.files = [. . .]
|
31
|
+
# important! files _must_ be set _before_ set_version call
|
32
|
+
|
33
|
+
g.set_version 1, 0, 0, 'beta'
|
34
|
+
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
See example in [gemspec](set_version.gemspec).
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
* [GNU Lesser General Public License v3](LICENSE)
|
data/lib/set_version.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'digest/sha1'
|
5
|
+
|
6
|
+
class Gem::Specification
|
7
|
+
|
8
|
+
SET_VERSION_VERSION = [0, 1, 2]
|
9
|
+
|
10
|
+
def set_version *vers, git: false, message: 'Build #%<version>s', tag: false
|
11
|
+
|
12
|
+
if Integer === vers[-1]
|
13
|
+
beta = ''
|
14
|
+
else
|
15
|
+
beta = vers.pop.to_s
|
16
|
+
end
|
17
|
+
major = vers[0] || 0
|
18
|
+
minor = vers[1] || 0
|
19
|
+
patch = vers[2] || 0
|
20
|
+
key = "#{major}.#{minor}.#{patch}.#{beta}"
|
21
|
+
|
22
|
+
s_fn = caller_locations[0].absolute_path
|
23
|
+
s_nm = File.basename caller_locations[0].path, '.gemspec'
|
24
|
+
v_fn = File.expand_path "../#{s_nm}.gemvers", s_fn
|
25
|
+
if File.exist? v_fn
|
26
|
+
data = eval(File.read v_fn)
|
27
|
+
else
|
28
|
+
data = {}
|
29
|
+
end
|
30
|
+
stored = data[key]
|
31
|
+
if !stored
|
32
|
+
stored = {}
|
33
|
+
end
|
34
|
+
build = stored[:build] || -1
|
35
|
+
|
36
|
+
digest = Digest::SHA1.new
|
37
|
+
digest << (File.read s_fn)
|
38
|
+
files.each do |f|
|
39
|
+
digest << (File.read f) if File.file? f
|
40
|
+
end
|
41
|
+
|
42
|
+
if digest.hexdigest != stored[:hash]
|
43
|
+
build += 1
|
44
|
+
stored[:hash] = digest.hexdigest
|
45
|
+
stored[:build] = build
|
46
|
+
data[key] = stored
|
47
|
+
File.open(v_fn, 'w') { |f| f.puts data.inspect }
|
48
|
+
end
|
49
|
+
|
50
|
+
if beta == '' && build == 0
|
51
|
+
if patch == 0
|
52
|
+
result = "#{major}.#{minor}"
|
53
|
+
else
|
54
|
+
result = "#{major}.#{minor}.#{patch}"
|
55
|
+
end
|
56
|
+
else
|
57
|
+
result = "#{major}.#{minor}.#{patch}.#{beta}#{build}"
|
58
|
+
end
|
59
|
+
self.version = result
|
60
|
+
|
61
|
+
if git
|
62
|
+
msg = message % { version: result, major: major, minor: minor,
|
63
|
+
patch: patch, beta: beta, build: build }
|
64
|
+
if system "git ls-files #{s_fn} --error-unmatch > /dev/null 2>&1"
|
65
|
+
system "git add #{v_fn} > /dev/null 2>&1"
|
66
|
+
system "git commit -a -m '#{msg}' > /dev/null 2>&1"
|
67
|
+
if tag
|
68
|
+
system "git tag #{result}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
return result
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: set_version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ivan Shikhalev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Make gem version with autoicrement build number.
|
14
|
+
email: shikhalev@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- LICENSE
|
20
|
+
- README.md
|
21
|
+
- lib/set_version.rb
|
22
|
+
homepage: https://github.com/shikhalev/set_version
|
23
|
+
licenses:
|
24
|
+
- GNU LGPLv3
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '2.0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.4.5
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Make gem version with autoicrement build number
|
46
|
+
test_files: []
|
47
|
+
has_rdoc:
|