raketeer 0.2.8 → 0.2.13

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.
@@ -1,47 +1,35 @@
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
7
+ #
8
+ # SPDX-License-Identifier: LGPL-3.0-or-later
21
9
  #++
22
10
 
23
11
 
24
12
  module Raketeer
25
13
  ###
26
14
  # Semantic Version
27
- #
15
+ #
28
16
  # This is a non-strict version of Semantic Versioning v2.0.0.
29
- #
30
- # @author Jonathan Bradley Whited (@esotericpig)
17
+ #
18
+ # @author Jonathan Bradley Whited
31
19
  # @since 0.2.4
32
20
  # @see https://semver.org
33
21
  ###
34
22
  class SemVer
35
- REGEX = /\d+(\.\d+)?(\.\d+)?(\-[0-9A-Za-z\-\.]+)?(\+[0-9A-Za-z\-\.]+)?/
36
- STRICT_REGEX = /\d+\.\d+\.\d+(\-[0-9A-Za-z\-\.]+)?(\+[0-9A-Za-z\-\.]+)?/
37
-
23
+ REGEX = /\d+(\.\d+)?(\.\d+)?(\-[0-9A-Za-z\-\.]+)?(\+[0-9A-Za-z\-\.]+)?/.freeze
24
+ STRICT_REGEX = /\d+\.\d+\.\d+(\-[0-9A-Za-z\-\.]+)?(\+[0-9A-Za-z\-\.]+)?/.freeze
25
+
38
26
  attr_accessor :build_meta
39
27
  attr_accessor :major
40
28
  attr_accessor :minor
41
29
  attr_accessor :patch
42
30
  attr_accessor :prerelease
43
31
  attr_accessor :version # If not +nil+, {to_s} will only return this.
44
-
32
+
45
33
  def initialize(major: nil,minor: nil,patch: nil,prerelease: nil,build_meta: nil)
46
34
  @build_meta = build_meta
47
35
  @major = major
@@ -50,12 +38,12 @@ module Raketeer
50
38
  @prerelease = prerelease
51
39
  @version = nil
52
40
  end
53
-
41
+
54
42
  def initialize_copy(orig)
55
43
  super(orig)
56
-
57
- copy = caller[0].to_s().include?('clone') ? :clone : :dup
58
-
44
+
45
+ copy = caller[0].to_s.include?('clone') ? :clone : :dup
46
+
59
47
  @build_meta = @build_meta.__send__(copy)
60
48
  @major = @major.__send__(copy)
61
49
  @minor = @minor.__send__(copy)
@@ -63,72 +51,72 @@ module Raketeer
63
51
  @prerelease = @prerelease.__send__(copy)
64
52
  @version = @version.__send__(copy)
65
53
  end
66
-
54
+
67
55
  def self.parse(str)
68
56
  # Parsing backwards makes the logic easier
69
57
  build_meta = str.split('+',2)
70
58
  prerelease = build_meta[0].split('-',2)
71
59
  numbers = prerelease[0].split('.',3)
72
-
73
- sem_ver = SemVer.new()
74
- sem_ver.major = numbers[0].to_i() # There must always be a major version
75
-
60
+
61
+ sem_ver = SemVer.new
62
+ sem_ver.major = numbers[0].to_i # There must always be a major version
63
+
76
64
  if numbers.length >= 2
77
- minor = numbers[1].strip()
78
- sem_ver.minor = minor.to_i() unless minor.empty?()
79
-
65
+ minor = numbers[1].strip
66
+ sem_ver.minor = minor.to_i unless minor.empty?
67
+
80
68
  if numbers.length == 3
81
- patch = numbers[2].strip()
82
- sem_ver.patch = patch.to_i() unless patch.empty?()
69
+ patch = numbers[2].strip
70
+ sem_ver.patch = patch.to_i unless patch.empty?
83
71
  end
84
72
  end
85
-
73
+
86
74
  if prerelease.length == 2
87
- prerelease = prerelease[1].strip()
88
- sem_ver.prerelease = prerelease unless prerelease.empty?()
75
+ prerelease = prerelease[1].strip
76
+ sem_ver.prerelease = prerelease unless prerelease.empty?
89
77
  end
90
-
78
+
91
79
  if build_meta.length == 2
92
- build_meta = build_meta[1].strip()
93
- sem_ver.build_meta = build_meta unless build_meta.empty?()
80
+ build_meta = build_meta[1].strip
81
+ sem_ver.build_meta = build_meta unless build_meta.empty?
94
82
  end
95
-
83
+
96
84
  return sem_ver
97
85
  end
98
-
86
+
99
87
  def self.parse_line(line,strict: false)
100
88
  str = line[regex(strict)]
101
-
102
- return nil if str.nil?() || (str = str.strip()).empty?()
89
+
90
+ return nil if str.nil? || (str = str.strip).empty?
103
91
  return parse(str)
104
92
  end
105
-
106
- def empty?()
107
- return @build_meta.nil?() &&
108
- @major.nil?() &&
109
- @minor.nil?() &&
110
- @patch.nil?() &&
111
- @prerelease.nil?() &&
112
- @version.nil?()
93
+
94
+ def empty?
95
+ return @build_meta.nil? &&
96
+ @major.nil? &&
97
+ @minor.nil? &&
98
+ @patch.nil? &&
99
+ @prerelease.nil? &&
100
+ @version.nil?
113
101
  end
114
-
102
+
115
103
  def self.regex(strict=false)
116
104
  return strict ? STRICT_REGEX : REGEX
117
105
  end
118
-
119
- def to_s()
120
- s = ''.dup()
121
-
122
- if !@version.nil?()
123
- s << @version.to_s()
124
- elsif !@major.nil?()
125
- s << @major.to_s()
126
- s << ".#{@minor.to_s()}" unless @minor.nil?()
127
- s << ".#{@patch.to_s()}" unless @patch.nil?()
128
- s << "-#{@prerelease.to_s()}" unless @prerelease.nil?()
129
- s << "+#{@build_meta.to_s()}" unless @build_meta.nil?()
106
+
107
+ def to_s
108
+ s = ''.dup
109
+
110
+ if !@version.nil?
111
+ s << @version.to_s
112
+ elsif !@major.nil?
113
+ s << @major.to_s
114
+ s << ".#{@minor}" unless @minor.nil?
115
+ s << ".#{@patch}" unless @patch.nil?
116
+ s << "-#{@prerelease}" unless @prerelease.nil?
117
+ s << "+#{@build_meta}" unless @build_meta.nil?
130
118
  end
131
-
119
+
132
120
  return s
133
121
  end
134
122
  end
data/lib/raketeer/util.rb CHANGED
@@ -1,98 +1,86 @@
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-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
7
+ #
8
+ # SPDX-License-Identifier: LGPL-3.0-or-later
21
9
  #++
22
10
 
23
11
 
24
12
  module Raketeer
25
13
  ###
26
- # @author Jonathan Bradley Whited (@esotericpig)
14
+ # @author Jonathan Bradley Whited
27
15
  # @since 0.2.2
28
16
  ###
29
17
  module Util
30
18
  # @since 0.2.4
31
- TRUE_BOOLS = ['1','on','t','true','y','yes'].freeze()
32
-
19
+ TRUE_BOOLS = %w[ 1 on t true y yes ].freeze
20
+
33
21
  # This is pretty hacky...
34
- #
22
+ #
35
23
  # @since 0.2.8
36
- def self.find_github_username()
24
+ def self.find_github_username
37
25
  Dir.glob('*.gemspec') do |file|
38
26
  File.foreach(file) do |line|
39
27
  md = line.match(%r{(github\.com/)([^/]+)}i)
40
-
41
- next if md.nil?() || md.length < 3
42
-
28
+
29
+ next if md.nil? || md.length < 3
30
+
43
31
  return md[2].gsub(/\s+/,'')
44
32
  end
45
33
  end
46
-
34
+
47
35
  return nil
48
36
  end
49
-
37
+
50
38
  def self.find_main_executable(bin_dir='bin')
51
39
  # Try the bin/ dir
52
40
  main_exe = Dir.glob(File.join(bin_dir,'*'))
53
-
41
+
54
42
  return File.basename(main_exe[0]) if main_exe.length == 1
55
-
43
+
56
44
  # Try using the main module
57
- main_mod = find_main_module()
58
-
59
- if !main_mod.nil?()
45
+ main_mod = find_main_module
46
+
47
+ if !main_mod.nil?
60
48
  main_exe = File.join(bin_dir,main_mod)
61
-
49
+
62
50
  return main_mod if File.exist?(main_exe)
63
51
  end
64
-
52
+
65
53
  return nil
66
54
  end
67
-
55
+
68
56
  def self.find_main_module(lib_dir='lib')
69
57
  # Try the lib/ dir
70
58
  main_file = Dir.glob(File.join(lib_dir,'*.rb'))
71
-
59
+
72
60
  return File.basename(main_file[0],'.*') if main_file.length == 1
73
-
61
+
74
62
  # Try the Gemspec
75
63
  main_file = Dir.glob('*.gemspec')
76
-
64
+
77
65
  return File.basename(main_file[0],'.*') if main_file.length == 1
78
-
66
+
79
67
  return nil
80
68
  end
81
-
69
+
82
70
  # @since 0.2.7
83
71
  def self.get_env_bool(env_name,def_value=nil)
84
72
  value = ENV[env_name]
85
-
86
- if value.nil?() || (value = value.to_s().strip()).empty?()
73
+
74
+ if value.nil? || (value = value.to_s.strip).empty?
87
75
  return def_value
88
76
  end
89
-
77
+
90
78
  return to_bool(value)
91
79
  end
92
-
80
+
93
81
  # @since 0.2.4
94
82
  def self.to_bool(obj)
95
- return TRUE_BOOLS.include?(obj.to_s().downcase())
83
+ return TRUE_BOOLS.include?(obj.to_s.downcase)
96
84
  end
97
85
  end
98
86
  end
@@ -1,40 +1,26 @@
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
7
+ #
8
+ # SPDX-License-Identifier: LGPL-3.0-or-later
21
9
  #++
22
10
 
23
11
 
24
12
  module Raketeer
25
- VERSION = '0.2.8'
26
-
13
+ VERSION = '0.2.13'
14
+
27
15
  # @since 0.2.4
28
16
  DEP_VERSIONS = {
29
- 'irb' => '~> 1.0'
30
- }
31
-
17
+ 'irb' => '>= 1.0'
18
+ }.freeze
19
+
32
20
  # @since 0.2.4
33
21
  def self.try_require_dev(gem_name)
34
- begin
35
- require gem_name
36
- rescue LoadError => e
37
- raise e.exception("Add development dependency: '#{gem_name}','#{DEP_VERSIONS[gem_name]}'")
38
- end
22
+ require gem_name
23
+ rescue LoadError => e
24
+ raise e.exception("Add development dependency: '#{gem_name}','#{DEP_VERSIONS[gem_name]}'")
39
25
  end
40
26
  end
data/raketeer.gemspec CHANGED
@@ -1,74 +1,58 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
- #--
5
- # This file is part of Raketeer.
6
- # Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
7
- #
8
- # Raketeer is free software: you can redistribute it and/or modify
9
- # it under the terms of the GNU Lesser General Public License as published by
10
- # the Free Software Foundation, either version 3 of the License, or
11
- # (at your option) any later version.
12
- #
13
- # Raketeer is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- # GNU Lesser General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU Lesser General Public License
19
- # along with Raketeer. If not, see <https://www.gnu.org/licenses/>.
20
- #++
21
-
22
4
 
23
5
  lib = File.expand_path(File.join('..','lib'),__FILE__)
24
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
25
7
 
26
8
  require 'raketeer/version'
27
9
 
28
- Gem::Specification.new() do |spec|
10
+ Gem::Specification.new do |spec|
29
11
  spec.name = 'raketeer'
30
12
  spec.version = Raketeer::VERSION
31
- spec.authors = ['Jonathan Bradley Whited (@esotericpig)']
32
- spec.email = ['bradley@esotericpig.com']
13
+ spec.authors = ['Jonathan Bradley Whited']
14
+ spec.email = ['code@esotericpig.com']
33
15
  spec.licenses = ['LGPL-3.0-or-later']
34
16
  spec.homepage = 'https://github.com/esotericpig/raketeer'
35
17
  spec.summary = 'Extra Ruby Rake Tasks.'
36
- spec.description = 'Extra Ruby Rake Tasks for IRB, Nokogiri, running, bumping the version, etc.'
37
-
18
+ spec.description = <<-DESC
19
+ Extra Ruby Rake Tasks for bumping the version, GitHub Packages, Nokogiri, IRB, running, etc.
20
+ DESC
21
+
38
22
  spec.metadata = {
39
23
  'bug_tracker_uri' => 'https://github.com/esotericpig/raketeer/issues',
40
24
  'changelog_uri' => 'https://github.com/esotericpig/raketeer/blob/master/CHANGELOG.md',
41
25
  'homepage_uri' => 'https://github.com/esotericpig/raketeer',
42
26
  'source_code_uri' => 'https://github.com/esotericpig/raketeer'
43
27
  }
44
-
28
+
45
29
  spec.require_paths = ['lib']
46
-
30
+
47
31
  spec.files = Dir.glob(File.join("{#{spec.require_paths.join(',')}}",'**','*.{erb,rb}')) +
48
32
  Dir.glob(File.join('{test,yard}','**','*.{erb,rb}')) +
49
- %W( Gemfile #{spec.name}.gemspec Rakefile ) +
50
- %w( CHANGELOG.md LICENSE.txt README.md )
51
-
33
+ %W[ Gemfile #{spec.name}.gemspec Rakefile ] +
34
+ %w[ CHANGELOG.md LICENSE.txt README.md ]
35
+
52
36
  spec.required_ruby_version = '>= 2.1.10'
53
-
37
+
54
38
  # TODO: also add the below comment to the README & reword for user
55
- #
39
+ #
56
40
  # If it is a dependency specific to a task, then it should probably be added
57
41
  # as a development dependency (not a runtime dependency) so that a bunch of
58
42
  # non-essential dependencies (to the user) are not added.
59
- #
43
+ #
60
44
  # For example, if the user only uses the Nokogiri tasks, then they don't need
61
45
  # the IRB dependency.
62
- #
46
+ #
63
47
  # Therefore, it is up to the user to add the dependencies they need.
64
48
  # If the user uses the IRB task, then they will have to add 'irb' as a
65
49
  # development dependency in their own project's Gemspec.
66
-
50
+
67
51
  dv = Raketeer::DEP_VERSIONS
68
-
69
- spec.add_runtime_dependency 'rake' #,'~> 12.3'
70
-
71
- spec.add_development_dependency 'bundler','~> 1.17'
52
+
53
+ spec.add_runtime_dependency 'rake'
54
+
55
+ spec.add_development_dependency 'bundler','~> 2.2'
72
56
  spec.add_development_dependency 'irb' ,dv['irb'] # For IRBTask
73
57
  spec.add_development_dependency 'yard' ,'~> 0.9' # For documentation
74
58
  end