raketary 0.1.3 → 0.2.4

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,86 +1,80 @@
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 Raketary.
7
- # Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
8
- #
9
- # Raketary 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
- # Raketary 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 Raketary. 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
  require 'raketary/cmd'
25
13
  require 'raketeer/bump_task'
26
14
 
15
+
27
16
  module Raketary
28
17
  ###
29
- # @author Jonathan Bradley Whited (@esotericpig)
18
+ # @author Jonathan Bradley Whited
30
19
  # @since 0.1.0
31
20
  ###
32
- class AppBump < Cmd
21
+ class BumpCmd < Cmd
33
22
  def initialize(*)
34
23
  super
35
-
24
+
36
25
  @run_cmd = false
37
-
38
- parse!() do |op|
26
+
27
+ parse! do |op|
39
28
  op.on('-n','--dry-run','do a dry run (do NOT write to files)')
40
29
  op.on('-s','--strict','enforce semantic versioning (i.e., \\d+\\.\\d+\\.\\d+.*)')
30
+
41
31
  op.separator op.summary_indent
42
-
43
- op.on('-v','--ver [STR]',%q{show/set the version (e.g.: '1.2.3-alpha.4+beta.5') (default: show)}) do |ver|
32
+
33
+ op.on('-v','--ver [STR]',"show/set the version (e.g.: '1.2.3-alpha.4+beta.5')" \
34
+ ' (default: show)') do |ver|
44
35
  @run_cmd = true
45
36
  ver
46
37
  end
47
- op.on('-m','--major [INT,STR]',%q{bump/set the major number (e.g.: +2, 4) (default: +1)}) do |major|
38
+ op.on('-m','--major [INT,STR]','bump/set the major number (e.g.: +2, 4) (default: +1)') do |major|
48
39
  @run_cmd = true
49
- major.nil?() ? '+1' : major
40
+ major.nil? ? '+1' : major
50
41
  end
51
- op.on('-i','--minor [INT,STR]',%q{bump/set the minor number (e.g.: +2, 4) (default: +1)}) do |minor|
42
+ op.on('-i','--minor [INT,STR]','bump/set the minor number (e.g.: +2, 4) (default: +1)') do |minor|
52
43
  @run_cmd = true
53
- minor.nil?() ? '+1' : minor
44
+ minor.nil? ? '+1' : minor
54
45
  end
55
- op.on('-p','--patch [INT,STR]',%q{bump/set the patch number (e.g.: +2, 4) (default: +1)}) do |patch|
46
+ op.on('-p','--patch [INT,STR]','bump/set the patch number (e.g.: +2, 4) (default: +1)') do |patch|
56
47
  @run_cmd = true
57
- patch.nil?() ? '+1' : patch
48
+ patch.nil? ? '+1' : patch
58
49
  end
59
- op.on('-r','--pre [STR]',%q{set/erase the pre-release extension (e.g.: 'alpha.4') (default: erase)}) do |pre|
50
+ op.on('-r','--pre [STR]',"set/erase the pre-release extension (e.g.: 'alpha.4')" \
51
+ ' (default: erase)') do |pre|
60
52
  @run_cmd = true
61
- pre.nil?() ? '' : pre
53
+ pre.nil? ? '' : pre
62
54
  end
63
- op.on('-b','--build [STR]',%q{set/erase the the build metadata (e.g.: 'beta.5') (default: erase)}) do |build|
55
+ op.on('-b','--build [STR]',"set/erase the the build metadata (e.g.: 'beta.5')" \
56
+ ' (default: erase)') do |build|
64
57
  @run_cmd = true
65
- build.nil?() ? '' : build
58
+ build.nil? ? '' : build
66
59
  end
67
60
  op.on('-u','--bundle','bump the Gemfile.lock version') do
68
61
  @run_cmd = true
69
62
  true
70
63
  end
64
+
71
65
  op.separator op.summary_indent
72
-
66
+
73
67
  op.on_tail('-x','--example','show some examples') do
74
- puts <<~EOX
68
+ puts <<~EXAMPLES
75
69
  #{app.name} #{@name} -v # Show the current version
76
70
  #{app.name} #{@name} -n # Do a dry run for any task (will NOT write to files)
77
-
71
+
78
72
  #{app.name} #{@name} -v '1.2.3-alpha.4-beta.5' # Set the version manually
79
73
  #{app.name} #{@name} -m 1 -i 2 -p 3 # Set the version numbers
80
74
  #{app.name} #{@name} -r 'alpha.4' -b 'beta.5' # Set the version extensions
81
75
  #{app.name} #{@name} -m -i -p # Bump the version numbers by 1
82
76
  #{app.name} #{@name} -m +2 -i +3 -p +4 # Bump the version numbers by X
83
-
77
+
84
78
  #{app.name} #{@name} -m # Bump the major number by 1
85
79
  #{app.name} #{@name} -m 1 # Set the major number to 1
86
80
  #{app.name} #{@name} -m +2 # Bump the major number by 2
@@ -95,23 +89,24 @@ module Raketary
95
89
  #{app.name} #{@name} -b # Erase the build metadata
96
90
  #{app.name} #{@name} -b 'beta.5' # Set the build metadata
97
91
  #{app.name} #{@name} -u # Bump the Gemfile.lock version
98
- EOX
92
+ EXAMPLES
99
93
  exit
100
94
  end
101
95
  end
102
96
  end
103
-
104
- def run()
97
+
98
+ def run
105
99
  super()
106
100
  return unless @run_cmd
107
-
108
- bump_task = Raketeer::BumpTask.new()
109
- bump_task.bump_bundle = false
110
- bump_task.dry_run = app.options[:dry_run] ? true : false
111
- bump_task.strict = app.options[:strict] ? true : false
112
-
113
- bump_task.check_env()
114
-
101
+
102
+ bump_task = Raketeer::BumpTask.new do |task|
103
+ task.bump_bundle = false
104
+ task.dry_run = app.options[:dry_run] ? true : false
105
+ task.strict = app.options[:strict] ? true : false
106
+ end
107
+
108
+ bump_task.check_env
109
+
115
110
  bump_task.bump_all(Raketeer::BumpVer.new(
116
111
  version: app.options[:ver],
117
112
  major: app.options[:major],
@@ -120,9 +115,9 @@ module Raketary
120
115
  prerelease: app.options[:pre],
121
116
  build_meta: app.options[:build]
122
117
  ))
123
-
124
- bump_task.bump_bundle_file() if app.options[:bundle]
125
-
118
+
119
+ bump_task.bump_bundle_file if app.options[:bundle]
120
+
126
121
  app.ran_cmd = true
127
122
  end
128
123
  end
data/lib/raketary/cmd.rb CHANGED
@@ -1,32 +1,21 @@
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 Raketary.
7
- # Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
8
- #
9
- # Raketary 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
- # Raketary 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 Raketary. 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
  require 'optparse'
25
13
  require 'raketary/errors'
26
14
 
15
+
27
16
  module Raketary
28
17
  ###
29
- # @author Jonathan Bradley Whited (@esotericpig)
18
+ # @author Jonathan Bradley Whited
30
19
  # @since 0.1.0
31
20
  ###
32
21
  class Cmd
@@ -34,70 +23,70 @@ module Raketary
34
23
  attr_reader :leftover_args
35
24
  attr_reader :name
36
25
  attr_reader :sub_cmds
37
-
26
+
38
27
  def initialize(app,name)
39
28
  @app = app
40
29
  @leftover_args = []
41
30
  @name = name
42
31
  @sub_cmds = {}
43
32
  end
44
-
33
+
45
34
  def parse!(is_app=false)
46
- parser = OptionParser.new() do |op|
35
+ parser = OptionParser.new do |op|
47
36
  op.program_name = app.name
48
37
  op.version = app.version
49
-
38
+
50
39
  op.banner = ''
51
40
  op.separator '' if is_app
52
-
53
- if !@sub_cmds.empty?()
41
+
42
+ if !@sub_cmds.empty?
54
43
  op.separator is_app ? 'Commands:' : "[#{@name}] Commands:"
55
-
44
+
56
45
  @sub_cmds.each do |name,sub_cmd|
57
- name_desc = ''.dup()
46
+ name_desc = ''.dup
58
47
  name_desc << op.summary_indent
59
48
  name_desc << ("%-#{op.summary_width}s #{sub_cmd.desc}" % [name])
60
-
49
+
61
50
  op.separator name_desc
62
51
  end
63
52
  op.separator ''
64
53
  end
65
-
54
+
66
55
  op.separator is_app ? 'Options:' : "[#{@name}] Options:"
67
-
56
+
68
57
  op.on_tail('-h','--help','show this help')
69
-
58
+
70
59
  yield op
71
60
  end
72
-
61
+
73
62
  options = {}
74
- @leftover_args = parser.order!(app.args,into: options).dup()
75
-
76
- options.keys.each do |key|
77
- if (key_s = key.to_s()).include?('-')
78
- options[key_s.gsub('-','_').to_sym()] = options[key]
63
+ @leftover_args = parser.order!(app.args,into: options).dup
64
+
65
+ options.each_key do |key|
66
+ if (key_s = key.to_s).include?('-')
67
+ options[key_s.gsub('-','_').to_sym] = options[key]
79
68
  options.delete(key)
80
69
  end
81
70
  end
82
71
  app.options.merge!(options)
83
-
72
+
84
73
  app.parsers << parser
85
-
86
- if !app.args.nil?() && !(sub_cmd_name = app.args.shift()).nil?()
87
- if !(sub_cmd = @sub_cmds[sub_cmd_name]).nil?()
74
+
75
+ if !app.args.nil? && !(sub_cmd_name = app.args.shift).nil?
76
+ if !(sub_cmd = @sub_cmds[sub_cmd_name]).nil?
88
77
  begin
89
- sub_cmd.cmd_class.new(app,sub_cmd_name).run()
78
+ sub_cmd.cmd_class.new(app,sub_cmd_name).run
90
79
  rescue DoNotRunCmdError => e
91
80
  app.soft_error = e.soft_msg
92
81
  end
93
82
  end
94
83
  end
95
-
84
+
96
85
  return parser
97
86
  end
98
-
99
- def run()
100
- raise DoNotRunCmdError if app.options[:help] || app.ran_cmd?()
87
+
88
+ def run
89
+ raise DoNotRunCmdError if app.options[:help] || app.ran_cmd?
101
90
  end
102
91
  end
103
92
  end
@@ -1,37 +1,25 @@
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 Raketary.
7
- # Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
8
- #
9
- # Raketary 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
- # Raketary 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 Raketary. 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 Raketary
25
13
  ###
26
- # @author Jonathan Bradley Whited (@esotericpig)
14
+ # @author Jonathan Bradley Whited
27
15
  # @since 0.1.0
28
16
  ###
29
17
  class DoNotRunCmdError < StandardError
30
18
  attr_accessor :soft_msg
31
-
19
+
32
20
  def initialize(msg=nil)
33
21
  super(msg)
34
-
22
+
35
23
  @soft_msg = msg
36
24
  end
37
25
  end
@@ -0,0 +1,85 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ #--
5
+ # This file is part of Raketary.
6
+ # Copyright (c) 2020-2021 Jonathan Bradley Whited
7
+ #
8
+ # SPDX-License-Identifier: LGPL-3.0-or-later
9
+ #++
10
+
11
+
12
+ require 'rake'
13
+ require 'raketary/cmd'
14
+ require 'shellwords'
15
+ require 'yard_ghurt/ghp_sync_task'
16
+
17
+
18
+ module Raketary
19
+ ###
20
+ # @author Jonathan Bradley Whited
21
+ # @since 0.2.0
22
+ ###
23
+ class GHPSyncCmd < Cmd
24
+ def initialize(*)
25
+ super
26
+
27
+ # Kind of hacky, but necessary because sync_args can have a hyphen/dash.
28
+ app.args.each_with_index do |arg,i|
29
+ arg = arg.strip
30
+
31
+ if arg == '-s' || arg.downcase == '--sync-args'
32
+ sync_args = app.args[i + 1] # If out of bounds, nil
33
+
34
+ if !sync_args.nil?
35
+ sync_args = Shellwords.split(sync_args)
36
+ sync_args = nil if sync_args.nil? || sync_args.empty?
37
+
38
+ app.options[:sync_args] = sync_args
39
+ end
40
+
41
+ app.args.delete_at(i)
42
+ app.args.delete_at(i) # If out of bounds, no error
43
+
44
+ break
45
+ end
46
+ end
47
+
48
+ parse! do |op|
49
+ op.on('-g','--ghp-dir STR','the destination (GitHub Pages) directory to sync "doc/" to')
50
+
51
+ op.separator op.summary_indent
52
+
53
+ op.on('-d','--deploy',"actually deploy (don't just do a dry-run)")
54
+ op.on('-s','--sync-args STR','additional args to pass to the sync command') do |sync_args|
55
+ app.options[:sync_args] # Already processed above
56
+ end
57
+
58
+ op.separator op.summary_indent
59
+ end
60
+ end
61
+
62
+ def run
63
+ super()
64
+
65
+ ghp_dir = app.options[:ghp_dir]
66
+
67
+ return unless ghp_dir
68
+
69
+ deploy = app.options[:deploy]
70
+ sync_args = app.options[:sync_args]
71
+
72
+ sync_task = YardGhurt::GHPSyncTask.new do |task|
73
+ task.ghp_dir = ghp_dir
74
+ task.sync_args.push(*sync_args) unless sync_args.nil?
75
+ end
76
+
77
+ sync_task = Rake::Task[sync_task.name]
78
+
79
+ sync_task.reenable
80
+ sync_task.invoke(deploy)
81
+
82
+ app.ran_cmd = true
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,49 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ #--
5
+ # This file is part of Raketary.
6
+ # Copyright (c) 2020-2021 Jonathan Bradley Whited
7
+ #
8
+ # SPDX-License-Identifier: LGPL-3.0-or-later
9
+ #++
10
+
11
+
12
+ require 'bundler/gem_tasks'
13
+ require 'rake'
14
+ require 'raketary/cmd'
15
+ require 'raketeer/github_pkg_task'
16
+
17
+
18
+ module Raketary
19
+ ###
20
+ # @author Jonathan Bradley Whited
21
+ # @since 0.1.2
22
+ ###
23
+ class GitHubPkgCmd < Cmd
24
+ def initialize(*)
25
+ super
26
+
27
+ parse! do |op|
28
+ op.on('-u','--user STR','set the GitHub username')
29
+
30
+ op.separator op.summary_indent
31
+ end
32
+ end
33
+
34
+ def run
35
+ super()
36
+
37
+ ghpkg_task = Raketeer::GitHubPkgTask.new do |task|
38
+ task.username = app.options[:user]
39
+ end
40
+
41
+ ghpkg_task = Rake::Task[ghpkg_task.name]
42
+
43
+ ghpkg_task.reenable
44
+ ghpkg_task.invoke
45
+
46
+ app.ran_cmd = true
47
+ end
48
+ end
49
+ end