sycersion 0.1.0 → 0.2.1
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 +4 -4
- data/.sycersion/environment.yml +3 -1
- data/.sycersion/version +1 -0
- data/Gemfile.lock +1 -1
- data/lib/sycersion/version.rb +1 -1
- data/lib/sycersion/version_environment.rb +57 -25
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74fca173531567bcc02f1e07e07fbed00441208001ccf5efc9e2329a3a530036
|
4
|
+
data.tar.gz: 7ecae7f75bcbbfc67b8837956900a7c2dbb37c5a4daf7cbaec9ebf58006b57e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a30908c13e1ee3701e4b234506b2b2a89289e5aeef11b108beabc2690f5b3dac691b09006a86aa169ef8a0d01b8a837b0981f6324ec240a7ca72836aa9dc9a41
|
7
|
+
data.tar.gz: 6a06dba6e6ca65fcd8558a1b9a89f91e0d214c82e7ff8351803d3bdc6b6d1beba34d3ce0f8685f2026c436250323da8eb8915ee0a615328653b21ab549062789
|
data/.sycersion/environment.yml
CHANGED
data/.sycersion/version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.1
|
data/Gemfile.lock
CHANGED
data/lib/sycersion/version.rb
CHANGED
@@ -42,25 +42,39 @@ module Sycersion
|
|
42
42
|
def summary_of_environment
|
43
43
|
puts "\nWhere to find the configuration files"
|
44
44
|
puts "-------------------------------------\n"
|
45
|
-
puts "\nDirectory:
|
46
|
-
puts "Configuration file:
|
47
|
-
puts "
|
48
|
-
puts
|
45
|
+
puts "\nDirectory: #{SYCERSION_DIR}"
|
46
|
+
puts "Configuration file: #{SYCERSION_ENV}\n"
|
47
|
+
puts "Application version-file: #{@app_ver_file}" if @app_ver_file
|
48
|
+
puts "Application version assignment: #{@version_string}" if @version_string
|
49
|
+
puts "\nIf you change the configuration file and encounter odd behaviour,"
|
50
|
+
puts 're-run `sycersion --init`.'
|
49
51
|
end
|
50
52
|
|
51
53
|
def determine_version_and_version_file
|
52
54
|
files = Dir.glob('**/*version*')
|
53
55
|
files.each do |file|
|
54
|
-
File.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
next if File.directory?(file)
|
57
|
+
|
58
|
+
retrieve_version_files(file)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def retrieve_version_files(file)
|
63
|
+
File.readlines(file, chomp: true).each do |line|
|
64
|
+
scan_result = scan_for_version(line)
|
65
|
+
if scan_result
|
66
|
+
@version_files[file] = [scan_result, line]
|
67
|
+
break
|
60
68
|
end
|
61
69
|
end
|
62
70
|
end
|
63
71
|
|
72
|
+
def scan_for_version(line)
|
73
|
+
line.scan(Sycersion::SEMVER_LAX_REGEX)[0]
|
74
|
+
rescue ArgumentError
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
|
64
78
|
def prompt_version_and_version_file
|
65
79
|
if File.exist?(SYCERSION_VER)
|
66
80
|
resume_version_and_version_file
|
@@ -92,14 +106,14 @@ module Sycersion
|
|
92
106
|
end
|
93
107
|
|
94
108
|
def select_version_and_version_file
|
95
|
-
puts "\nFound
|
96
|
-
puts "
|
109
|
+
puts "\nFound files with versions\n"
|
110
|
+
puts "-------------------------\n"
|
97
111
|
list_versions_and_version_files
|
98
|
-
print "\nChoose
|
112
|
+
print "\nChoose file and version with number or hit return for [0]: "
|
99
113
|
selection = gets.chomp.to_i
|
100
|
-
|
101
|
-
@version = Sycersion::Semver.version(@version_files[
|
102
|
-
@version_string = @version_files[@
|
114
|
+
@app_ver_file = @version_files.keys[selection]
|
115
|
+
@version = Sycersion::Semver.version(@version_files[@app_ver_file][0])
|
116
|
+
@version_string = @version_files[@app_ver_file][1].strip
|
103
117
|
end
|
104
118
|
|
105
119
|
def list_versions_and_version_files
|
@@ -130,15 +144,28 @@ module Sycersion
|
|
130
144
|
|
131
145
|
In your application you can now access the version with
|
132
146
|
|
133
|
-
> File.read(#{version_file})
|
147
|
+
> File.read('#{version_file}')
|
134
148
|
|
135
|
-
If you application framework has a defined place to assign
|
136
|
-
|
149
|
+
If you application framework has a defined place to assign the version you
|
150
|
+
could do like so
|
137
151
|
|
138
|
-
> version = File.read(#{version_file})
|
152
|
+
> version = if File.exist? ? File.read('#{version_file}') : 'No VERSION!'
|
153
|
+
#{describe_adoption_of_version_file}
|
139
154
|
CODE_SNIP
|
140
155
|
end
|
141
156
|
|
157
|
+
def describe_adoption_of_version_file
|
158
|
+
return unless @app_ver_file && @version_string
|
159
|
+
|
160
|
+
<<-PROPOSAL
|
161
|
+
|
162
|
+
In #{@app_ver_file} you can change the version assignment to read from
|
163
|
+
#{@version_file} and change it accordingly.
|
164
|
+
|
165
|
+
#{@version_string}
|
166
|
+
PROPOSAL
|
167
|
+
end
|
168
|
+
|
142
169
|
def save
|
143
170
|
create_environment
|
144
171
|
end
|
@@ -147,7 +174,7 @@ module Sycersion
|
|
147
174
|
FileUtils.mkdir(SYCERSION_DIR) unless Dir.exist?(SYCERSION_DIR)
|
148
175
|
File.open(@version_file, 'w') { |f| f.write(@version) }
|
149
176
|
File.open(SYCERSION_ENV, 'w') do |f|
|
150
|
-
YAML.dump([@version_file, @version], f)
|
177
|
+
YAML.dump([@version_file, @version, @app_ver_file, @version_string], f)
|
151
178
|
end
|
152
179
|
rescue IOError => e
|
153
180
|
puts e.message
|
@@ -158,12 +185,17 @@ module Sycersion
|
|
158
185
|
@version_file, @version = YAML.load_file(SYCERSION_ENV)
|
159
186
|
true
|
160
187
|
else
|
161
|
-
|
162
|
-
@version = '0.1.0'
|
163
|
-
@version_files = {}
|
164
|
-
@version_string = ''
|
188
|
+
load_environment_default
|
165
189
|
false
|
166
190
|
end
|
167
191
|
end
|
192
|
+
|
193
|
+
def load_environment_default
|
194
|
+
@version_file = SYCERSION_VER
|
195
|
+
@version = '0.1.0'
|
196
|
+
@version_files = {}
|
197
|
+
@app_ver_file = ''
|
198
|
+
@version_string = ''
|
199
|
+
end
|
168
200
|
end
|
169
201
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sycersion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Sugar
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- ".rspec"
|
80
80
|
- ".ruby-version"
|
81
81
|
- ".sycersion/environment.yml"
|
82
|
+
- ".sycersion/version"
|
82
83
|
- ".travis.yml"
|
83
84
|
- CODE_OF_CONDUCT.md
|
84
85
|
- Gemfile
|