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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 296451fb7d60ad509421f5bfdfa718e726a06f7377f063a4f27a5176fc3f8a8c
4
- data.tar.gz: 8291b661655aed0ccce7f24e085e26185e8f6a43d7bca101c4dfcc77a34911a7
3
+ metadata.gz: 74fca173531567bcc02f1e07e07fbed00441208001ccf5efc9e2329a3a530036
4
+ data.tar.gz: 7ecae7f75bcbbfc67b8837956900a7c2dbb37c5a4daf7cbaec9ebf58006b57e0
5
5
  SHA512:
6
- metadata.gz: a21a9851fb8b5961565423189306c44ee6189d18c101e5f0c690d97977c11418eb5bd09c04e3ca4b5b80a7a42a05264e1867bba1a4a28eb9c428cb2c5e138f98
7
- data.tar.gz: 94bcfc3960cc42798e5620f7bb391a10f6d945021e734ae1099bb2f88b333d71faf304aef964d16c324acd606ebe2533eff702be7f7164cffc18e46fab996a3b
6
+ metadata.gz: a30908c13e1ee3701e4b234506b2b2a89289e5aeef11b108beabc2690f5b3dac691b09006a86aa169ef8a0d01b8a837b0981f6324ec240a7ca72836aa9dc9a41
7
+ data.tar.gz: 6a06dba6e6ca65fcd8558a1b9a89f91e0d214c82e7ff8351803d3bdc6b6d1beba34d3ce0f8685f2026c436250323da8eb8915ee0a615328653b21ab549062789
@@ -1,3 +1,5 @@
1
1
  ---
2
2
  - ".sycersion/version"
3
- - 0.1.0
3
+ - 0.2.1
4
+ -
5
+ -
@@ -0,0 +1 @@
1
+ 0.2.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sycersion (0.1.0)
4
+ sycersion (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sycersion
4
- VERSION = File.exist?('.sycersion/version') ? File.read('.sycersion/version') : '0.1.0'
4
+ VERSION = File.exist?('.sycersion/version') ? File.read('.sycersion/version') : '0.2.1'
5
5
  end
@@ -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: #{SYCERSION_DIR}"
46
- puts "Configuration file: #{SYCERSION_ENV}\n"
47
- puts "\nChange the configuration file only if you know what you are doing."
48
- puts 'Otherwise run `sycersion --init` again.'
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.readlines(file, chomp: true).each do |line|
55
- scan_result = line.scan(Sycersion::SEMVER_LAX_REGEX)
56
- if scan_result[0]
57
- @version_files[file] = [scan_result[0], line]
58
- break
59
- end
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 version-files\n"
96
- puts "-------------------\n"
109
+ puts "\nFound files with versions\n"
110
+ puts "-------------------------\n"
97
111
  list_versions_and_version_files
98
- print "\nChoose version-file and version with number or hit return for [0]: "
112
+ print "\nChoose file and version with number or hit return for [0]: "
99
113
  selection = gets.chomp.to_i
100
- app_version_file = @version_files.keys[selection]
101
- @version = Sycersion::Semver.version(@version_files[app_version_file][0])
102
- @version_string = @version_files[@version_file[1]]
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
- the version you could do like so
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
- @version_file = SYCERSION_VER
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.0
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