raketeer 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,23 +1,9 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  #--
6
5
  # This file is part of Raketeer.
7
- # Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
8
- #
9
- # Raketeer is free software: you can redistribute it and/or modify
10
- # it under the terms of the GNU Lesser General Public License as published by
11
- # the Free Software Foundation, either version 3 of the License, or
12
- # (at your option) any later version.
13
- #
14
- # Raketeer is distributed in the hope that it will be useful,
15
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- # GNU Lesser General Public License for more details.
18
- #
19
- # You should have received a copy of the GNU Lesser General Public License
20
- # along with Raketeer. If not, see <https://www.gnu.org/licenses/>.
6
+ # Copyright (c) 2019-2021 Jonathan Bradley Whited
21
7
  #++
22
8
 
23
9
 
@@ -26,12 +12,14 @@ require 'raketeer/sem_ver'
26
12
  module Raketeer
27
13
  ###
28
14
  # Bump Version
29
- #
30
- # @author Jonathan Bradley Whited (@esotericpig)
15
+ #
16
+ # @author Jonathan Bradley Whited
31
17
  # @since 0.2.4
32
18
  ###
33
19
  class BumpVer < SemVer
34
20
  def initialize(version: nil,major: nil,minor: nil,patch: nil,prerelease: nil,build_meta: nil)
21
+ super()
22
+
35
23
  self.build_meta = build_meta
36
24
  self.major = major
37
25
  self.minor = minor
@@ -39,104 +27,104 @@ module Raketeer
39
27
  self.prerelease = prerelease
40
28
  self.version = version
41
29
  end
42
-
30
+
43
31
  def init_int_or_str(obj)
44
- return nil if obj.nil?()
32
+ return nil if obj.nil?
45
33
  return obj if obj.is_a?(Integer)
46
-
47
- obj = obj.to_s().strip()
48
-
49
- return obj if obj.empty?() || obj[0] == '+'
50
- return obj.to_i()
34
+
35
+ obj = obj.to_s.strip
36
+
37
+ return obj if obj.empty? || obj[0] == '+'
38
+ return obj.to_i
51
39
  end
52
-
40
+
53
41
  def init_str(obj)
54
- return obj.nil?() ? nil : obj.to_s().strip()
42
+ return obj.nil? ? nil : obj.to_s.strip
55
43
  end
56
-
44
+
57
45
  def bump!(sem_ver)
58
- if !@version.nil?()
46
+ if !@version.nil?
59
47
  sem_ver.version = @version
60
48
  else
61
- if !@major.nil?()
49
+ if !@major.nil?
62
50
  if @major.is_a?(Integer)
63
51
  sem_ver.major = @major
64
- elsif @major.empty?()
52
+ elsif @major.empty?
65
53
  sem_ver.major = 0 # There must always be a major version
66
54
  else
67
- sem_ver.major = 0 if sem_ver.major.nil?()
68
- sem_ver.major += @major.to_i()
55
+ sem_ver.major = 0 if sem_ver.major.nil?
56
+ sem_ver.major += @major.to_i
69
57
  end
70
58
  end
71
-
72
- if !@minor.nil?()
59
+
60
+ if !@minor.nil?
73
61
  if @minor.is_a?(Integer)
74
62
  sem_ver.minor = @minor
75
- elsif @minor.empty?()
63
+ elsif @minor.empty?
76
64
  sem_ver.minor = nil
77
65
  else
78
- sem_ver.minor = 0 if sem_ver.minor.nil?()
79
- sem_ver.minor += @minor.to_i()
66
+ sem_ver.minor = 0 if sem_ver.minor.nil?
67
+ sem_ver.minor += @minor.to_i
80
68
  end
81
69
  end
82
-
83
- if !@patch.nil?()
70
+
71
+ if !@patch.nil?
84
72
  if @patch.is_a?(Integer)
85
73
  sem_ver.patch = @patch
86
- elsif @patch.empty?()
74
+ elsif @patch.empty?
87
75
  sem_ver.patch = nil
88
76
  else
89
- sem_ver.patch = 0 if sem_ver.patch.nil?()
90
- sem_ver.patch += @patch.to_i()
77
+ sem_ver.patch = 0 if sem_ver.patch.nil?
78
+ sem_ver.patch += @patch.to_i
91
79
  end
92
80
  end
93
-
94
- if !@prerelease.nil?()
95
- if @prerelease.empty?()
81
+
82
+ if !@prerelease.nil?
83
+ if @prerelease.empty?
96
84
  sem_ver.prerelease = nil
97
85
  else
98
86
  sem_ver.prerelease = @prerelease
99
87
  end
100
88
  end
101
-
102
- if !@build_meta.nil?()
103
- if @build_meta.empty?()
89
+
90
+ if !@build_meta.nil?
91
+ if @build_meta.empty?
104
92
  sem_ver.build_meta = nil
105
93
  else
106
94
  sem_ver.build_meta = @build_meta
107
95
  end
108
96
  end
109
97
  end
110
-
98
+
111
99
  return sem_ver
112
100
  end
113
-
101
+
114
102
  def bump_line!(line,sem_ver,strict: false)
115
- line.sub!(self.class.regex(strict),bump!(sem_ver).to_s())
116
-
103
+ line.sub!(self.class.regex(strict),bump!(sem_ver).to_s)
104
+
117
105
  return line
118
106
  end
119
-
107
+
120
108
  def build_meta=(build_meta)
121
109
  super(init_str(build_meta))
122
110
  end
123
-
111
+
124
112
  def major=(major)
125
113
  super(init_int_or_str(major))
126
114
  end
127
-
115
+
128
116
  def minor=(minor)
129
117
  super(init_int_or_str(minor))
130
118
  end
131
-
119
+
132
120
  def patch=(patch)
133
121
  super(init_int_or_str(patch))
134
122
  end
135
-
123
+
136
124
  def prerelease=(prerelease)
137
125
  super(init_str(prerelease))
138
126
  end
139
-
127
+
140
128
  def version=(version)
141
129
  super(init_str(version))
142
130
  end
@@ -1,23 +1,9 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  #--
6
5
  # This file is part of Raketeer.
7
- # Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
8
- #
9
- # Raketeer is free software: you can redistribute it and/or modify
10
- # it under the terms of the GNU Lesser General Public License as published by
11
- # the Free Software Foundation, either version 3 of the License, or
12
- # (at your option) any later version.
13
- #
14
- # Raketeer is distributed in the hope that it will be useful,
15
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- # GNU Lesser General Public License for more details.
18
- #
19
- # You should have received a copy of the GNU Lesser General Public License
20
- # along with Raketeer. If not, see <https://www.gnu.org/licenses/>.
6
+ # Copyright (c) 2019-2021 Jonathan Bradley Whited
21
7
  #++
22
8
 
23
9
 
@@ -26,7 +12,7 @@ require 'raketeer/sem_ver'
26
12
 
27
13
  module Raketeer
28
14
  ###
29
- # @author Jonathan Bradley Whited (@esotericpig)
15
+ # @author Jonathan Bradley Whited
30
16
  # @since 0.2.4
31
17
  ###
32
18
  class FilesBumper
@@ -42,67 +28,67 @@ module Raketeer
42
28
  attr_accessor :strict
43
29
  attr_accessor :version
44
30
  attr_accessor :version_bumped # Was the version actually bumped?
45
-
31
+
46
32
  alias_method :bump_ver_empty?,:bump_ver_empty
47
33
  alias_method :dry_run?,:dry_run
48
34
  alias_method :strict?,:strict
49
35
  alias_method :version_bumped?,:version_bumped
50
-
36
+
51
37
  def initialize(files,bump_ver,dry_run,strict,&init_per_file)
52
38
  @bump_ver = bump_ver
53
- @bump_ver_empty = bump_ver.empty?()
39
+ @bump_ver_empty = bump_ver.empty?
54
40
  @dry_run = dry_run
55
- @files = files.to_a()
41
+ @files = files.to_a
56
42
  @init_per_file = init_per_file
57
43
  @sem_ver = nil
58
44
  @strict = strict
59
45
  @version = nil
60
46
  @version_bumped = false
61
47
  end
62
-
48
+
63
49
  def add_change(line,push: true)
64
50
  puts "+ #{line}"
65
-
51
+
66
52
  @changes += 1
67
53
  @lines << line if push
68
54
  end
69
-
55
+
70
56
  def bump_files(&block)
71
57
  @files.each do |filename|
72
58
  puts "[#{filename}]:"
73
-
59
+
74
60
  if !File.exist?(filename)
75
61
  puts '! File does not exist'
76
-
62
+
77
63
  next
78
64
  end
79
-
65
+
80
66
  @changes = 0 # For possible future use
81
67
  @lines = []
82
68
  @sem_ver = nil
83
-
84
- @init_per_file.call(self) unless @init_per_file.nil?()
85
-
69
+
70
+ @init_per_file&.call(self)
71
+
86
72
  File.foreach(filename) do |line|
87
73
  @line = line
88
-
89
- block.call(self) if !@line.strip().empty?()
90
-
74
+
75
+ block.call(self) if !@line.strip.empty?
76
+
91
77
  @lines << @line
92
78
  end
93
-
94
- next if bump_ver_empty?()
95
-
79
+
80
+ next if bump_ver_empty?
81
+
96
82
  print '= '
97
-
83
+
98
84
  if @changes > 0
99
- if dry_run?()
85
+ if dry_run?
100
86
  puts "Nothing written (dry run): #{@sem_ver}"
101
87
  else
102
88
  File.open(filename,'w') do |file|
103
89
  file.puts @lines
104
90
  end
105
-
91
+
106
92
  puts "#{@changes} change#{@changes == 1 ? '' : 's'} written"
107
93
  end
108
94
  else
@@ -110,42 +96,40 @@ module Raketeer
110
96
  end
111
97
  end
112
98
  end
113
-
99
+
114
100
  # @return [:no_ver,:same_ver,:bumped_ver]
115
101
  def bump_line!(add_change: true)
116
102
  @sem_ver = SemVer.parse_line(@line,strict: @strict)
117
-
118
- return :no_ver if @sem_ver.nil?()
119
-
120
- @version = @sem_ver if @version.nil?()
121
-
122
- if bump_ver_empty?()
103
+
104
+ return :no_ver if @sem_ver.nil?
105
+
106
+ @version = @sem_ver if @version.nil?
107
+
108
+ if bump_ver_empty?
123
109
  puts "= #{@sem_ver}"
124
-
110
+
125
111
  return :same_ver
126
112
  else
127
- orig_line = @line.dup()
128
- orig_sem_ver_s = @sem_ver.to_s()
129
-
113
+ orig_line = @line.dup
114
+ orig_sem_ver_s = @sem_ver.to_s
115
+
130
116
  @bump_ver.bump_line!(@line,@sem_ver,strict: @strict)
131
-
132
- if @sem_ver.to_s() != orig_sem_ver_s
117
+
118
+ if @sem_ver.to_s != orig_sem_ver_s
133
119
  if !@version_bumped
134
120
  @version = @sem_ver
135
121
  @version_bumped = true
136
122
  end
137
-
123
+
138
124
  self.add_change(@line,push: false) if add_change
139
-
125
+
140
126
  return :bumped_ver
141
127
  else
142
128
  @line = orig_line
143
-
129
+
144
130
  return :same_ver
145
131
  end
146
132
  end
147
-
148
- return :no_ver
149
133
  end
150
134
  end
151
135
  end
@@ -1,23 +1,9 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  #--
6
5
  # This file is part of Raketeer.
7
- # Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
8
- #
9
- # Raketeer is free software: you can redistribute it and/or modify
10
- # it under the terms of the GNU Lesser General Public License as published by
11
- # the Free Software Foundation, either version 3 of the License, or
12
- # (at your option) any later version.
13
- #
14
- # Raketeer is distributed in the hope that it will be useful,
15
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- # GNU Lesser General Public License for more details.
18
- #
19
- # You should have received a copy of the GNU Lesser General Public License
20
- # along with Raketeer. If not, see <https://www.gnu.org/licenses/>.
6
+ # Copyright (c) 2019-2021 Jonathan Bradley Whited
21
7
  #++
22
8
 
23
9
 
@@ -26,11 +12,11 @@ require 'raketeer/github_pkg_task'
26
12
 
27
13
  module Raketeer
28
14
  ###
29
- # @author Jonathan Bradley Whited (@esotericpig)
15
+ # @author Jonathan Bradley Whited
30
16
  # @since 0.2.8
31
17
  ###
32
18
  module GitHubPkg
33
19
  end
34
20
  end
35
21
 
36
- Raketeer::GitHubPkgTask.new() # @since 0.2.8
22
+ Raketeer::GitHubPkgTask.new # @since 0.2.8
@@ -1,23 +1,9 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  #--
6
5
  # This file is part of Raketeer.
7
- # Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
8
- #
9
- # Raketeer is free software: you can redistribute it and/or modify
10
- # it under the terms of the GNU Lesser General Public License as published by
11
- # the Free Software Foundation, either version 3 of the License, or
12
- # (at your option) any later version.
13
- #
14
- # Raketeer is distributed in the hope that it will be useful,
15
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- # GNU Lesser General Public License for more details.
18
- #
19
- # You should have received a copy of the GNU Lesser General Public License
20
- # along with Raketeer. If not, see <https://www.gnu.org/licenses/>.
6
+ # Copyright (c) 2019-2021 Jonathan Bradley Whited
21
7
  #++
22
8
 
23
9
 
@@ -28,7 +14,7 @@ require 'raketeer/util'
28
14
 
29
15
  module Raketeer
30
16
  ###
31
- # @author Jonathan Bradley Whited (@esotericpig)
17
+ # @author Jonathan Bradley Whited
32
18
  # @since 0.2.8
33
19
  ###
34
20
  class GitHubPkgTask < Rake::TaskLib
@@ -36,34 +22,34 @@ module Raketeer
36
22
  attr_accessor :description
37
23
  attr_accessor :name
38
24
  attr_accessor :username
39
-
25
+
40
26
  def initialize(name=:github_pkg)
41
27
  super()
42
-
28
+
43
29
  @deps = [:build]
44
- @description = %Q(Publish this project's gem(s) to GitHub Packages)
30
+ @description = "Publish this project's gem(s) to GitHub Packages"
45
31
  @name = name
46
32
  @username = nil
47
-
48
- yield self if block_given?()
49
-
50
- @username = Util.find_github_username() if @username.nil?()
51
-
52
- raise "#{self.class.name}.username is nil" if @username.nil?()
53
-
54
- define()
33
+
34
+ yield self if block_given?
35
+
36
+ @username = Util.find_github_username if @username.nil?
37
+
38
+ raise "#{self.class.name}.username is nil" if @username.nil?
39
+
40
+ define
55
41
  end
56
-
57
- def define()
42
+
43
+ def define
58
44
  desc @description
59
45
  task @name => Array(@deps) do |task,args|
60
46
  sh_cmd = ['gem']
61
-
47
+
62
48
  sh_cmd.push('push')
63
49
  sh_cmd.push('--key','github')
64
50
  sh_cmd.push('--host',"https://rubygems.pkg.github.com/#{username}")
65
51
  sh_cmd.push(*Dir.glob(File.join('pkg','*.gem'))) # Is this okay for multiple gems?
66
-
52
+
67
53
  sh(*sh_cmd)
68
54
  end
69
55
  end