raketary 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/raketary/cmd.rb CHANGED
@@ -1,23 +1,11 @@
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-2020 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
 
@@ -27,7 +15,7 @@ require 'raketary/errors'
27
15
 
28
16
  module Raketary
29
17
  ###
30
- # @author Jonathan Bradley Whited (@esotericpig)
18
+ # @author Jonathan Bradley Whited
31
19
  # @since 0.1.0
32
20
  ###
33
21
  class Cmd
@@ -35,70 +23,70 @@ module Raketary
35
23
  attr_reader :leftover_args
36
24
  attr_reader :name
37
25
  attr_reader :sub_cmds
38
-
26
+
39
27
  def initialize(app,name)
40
28
  @app = app
41
29
  @leftover_args = []
42
30
  @name = name
43
31
  @sub_cmds = {}
44
32
  end
45
-
33
+
46
34
  def parse!(is_app=false)
47
- parser = OptionParser.new() do |op|
35
+ parser = OptionParser.new do |op|
48
36
  op.program_name = app.name
49
37
  op.version = app.version
50
-
38
+
51
39
  op.banner = ''
52
40
  op.separator '' if is_app
53
-
54
- if !@sub_cmds.empty?()
41
+
42
+ if !@sub_cmds.empty?
55
43
  op.separator is_app ? 'Commands:' : "[#{@name}] Commands:"
56
-
44
+
57
45
  @sub_cmds.each do |name,sub_cmd|
58
- name_desc = ''.dup()
46
+ name_desc = ''.dup
59
47
  name_desc << op.summary_indent
60
48
  name_desc << ("%-#{op.summary_width}s #{sub_cmd.desc}" % [name])
61
-
49
+
62
50
  op.separator name_desc
63
51
  end
64
52
  op.separator ''
65
53
  end
66
-
54
+
67
55
  op.separator is_app ? 'Options:' : "[#{@name}] Options:"
68
-
56
+
69
57
  op.on_tail('-h','--help','show this help')
70
-
58
+
71
59
  yield op
72
60
  end
73
-
61
+
74
62
  options = {}
75
- @leftover_args = parser.order!(app.args,into: options).dup()
76
-
77
- options.keys.each do |key|
78
- if (key_s = key.to_s()).include?('-')
79
- 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]
80
68
  options.delete(key)
81
69
  end
82
70
  end
83
71
  app.options.merge!(options)
84
-
72
+
85
73
  app.parsers << parser
86
-
87
- if !app.args.nil?() && !(sub_cmd_name = app.args.shift()).nil?()
88
- 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?
89
77
  begin
90
- sub_cmd.cmd_class.new(app,sub_cmd_name).run()
78
+ sub_cmd.cmd_class.new(app,sub_cmd_name).run
91
79
  rescue DoNotRunCmdError => e
92
80
  app.soft_error = e.soft_msg
93
81
  end
94
82
  end
95
83
  end
96
-
84
+
97
85
  return parser
98
86
  end
99
-
100
- def run()
101
- raise DoNotRunCmdError if app.options[:help] || app.ran_cmd?()
87
+
88
+ def run
89
+ raise DoNotRunCmdError if app.options[:help] || app.ran_cmd?
102
90
  end
103
91
  end
104
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
@@ -1,23 +1,11 @@
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) 2020 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) 2020-2021 Jonathan Bradley Whited
7
+ #
8
+ # SPDX-License-Identifier: LGPL-3.0-or-later
21
9
  #++
22
10
 
23
11
 
@@ -29,68 +17,68 @@ require 'yard_ghurt/ghp_sync_task'
29
17
 
30
18
  module Raketary
31
19
  ###
32
- # @author Jonathan Bradley Whited (@esotericpig)
20
+ # @author Jonathan Bradley Whited
33
21
  # @since 0.2.0
34
22
  ###
35
23
  class GHPSyncCmd < Cmd
36
24
  def initialize(*)
37
25
  super
38
-
26
+
39
27
  # Kind of hacky, but necessary because sync_args can have a hyphen/dash.
40
- app.args.each_with_index() do |arg,i|
41
- arg = arg.strip()
42
-
43
- if arg == '-s' || arg.downcase() == '--sync-args'
28
+ app.args.each_with_index do |arg,i|
29
+ arg = arg.strip
30
+
31
+ if arg == '-s' || arg.downcase == '--sync-args'
44
32
  sync_args = app.args[i + 1] # If out of bounds, nil
45
-
46
- if !sync_args.nil?()
33
+
34
+ if !sync_args.nil?
47
35
  sync_args = Shellwords.split(sync_args)
48
- sync_args = nil if sync_args.nil?() || sync_args.empty?()
49
-
36
+ sync_args = nil if sync_args.nil? || sync_args.empty?
37
+
50
38
  app.options[:sync_args] = sync_args
51
39
  end
52
-
40
+
53
41
  app.args.delete_at(i)
54
42
  app.args.delete_at(i) # If out of bounds, no error
55
-
43
+
56
44
  break
57
45
  end
58
46
  end
59
-
60
- parse!() do |op|
47
+
48
+ parse! do |op|
61
49
  op.on('-g','--ghp-dir STR','the destination (GitHub Pages) directory to sync "doc/" to')
62
-
50
+
63
51
  op.separator op.summary_indent
64
-
52
+
65
53
  op.on('-d','--deploy',"actually deploy (don't just do a dry-run)")
66
54
  op.on('-s','--sync-args STR','additional args to pass to the sync command') do |sync_args|
67
55
  app.options[:sync_args] # Already processed above
68
56
  end
69
-
57
+
70
58
  op.separator op.summary_indent
71
59
  end
72
60
  end
73
-
74
- def run()
61
+
62
+ def run
75
63
  super()
76
-
64
+
77
65
  ghp_dir = app.options[:ghp_dir]
78
-
66
+
79
67
  return unless ghp_dir
80
-
68
+
81
69
  deploy = app.options[:deploy]
82
70
  sync_args = app.options[:sync_args]
83
-
84
- sync_task = YardGhurt::GHPSyncTask.new() do |task|
71
+
72
+ sync_task = YardGhurt::GHPSyncTask.new do |task|
85
73
  task.ghp_dir = ghp_dir
86
- task.sync_args.push(*sync_args) unless sync_args.nil?()
74
+ task.sync_args.push(*sync_args) unless sync_args.nil?
87
75
  end
88
-
76
+
89
77
  sync_task = Rake::Task[sync_task.name]
90
-
91
- sync_task.reenable()
78
+
79
+ sync_task.reenable
92
80
  sync_task.invoke(deploy)
93
-
81
+
94
82
  app.ran_cmd = true
95
83
  end
96
84
  end
@@ -1,23 +1,11 @@
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) 2020 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) 2020-2021 Jonathan Bradley Whited
7
+ #
8
+ # SPDX-License-Identifier: LGPL-3.0-or-later
21
9
  #++
22
10
 
23
11
 
@@ -29,32 +17,32 @@ require 'raketeer/github_pkg_task'
29
17
 
30
18
  module Raketary
31
19
  ###
32
- # @author Jonathan Bradley Whited (@esotericpig)
20
+ # @author Jonathan Bradley Whited
33
21
  # @since 0.1.2
34
22
  ###
35
23
  class GitHubPkgCmd < Cmd
36
24
  def initialize(*)
37
25
  super
38
-
39
- parse!() do |op|
26
+
27
+ parse! do |op|
40
28
  op.on('-u','--user STR','set the GitHub username')
41
-
29
+
42
30
  op.separator op.summary_indent
43
31
  end
44
32
  end
45
-
46
- def run()
33
+
34
+ def run
47
35
  super()
48
-
49
- ghpkg_task = Raketeer::GitHubPkgTask.new() do |task|
36
+
37
+ ghpkg_task = Raketeer::GitHubPkgTask.new do |task|
50
38
  task.username = app.options[:user]
51
39
  end
52
-
40
+
53
41
  ghpkg_task = Rake::Task[ghpkg_task.name]
54
-
55
- ghpkg_task.reenable()
56
- ghpkg_task.invoke()
57
-
42
+
43
+ ghpkg_task.reenable
44
+ ghpkg_task.invoke
45
+
58
46
  app.ran_cmd = true
59
47
  end
60
48
  end
@@ -1,23 +1,11 @@
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-2020 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
 
@@ -28,27 +16,27 @@ require 'raketeer/irb_task'
28
16
 
29
17
  module Raketary
30
18
  ###
31
- # @author Jonathan Bradley Whited (@esotericpig)
19
+ # @author Jonathan Bradley Whited
32
20
  # @since 0.1.0
33
21
  ###
34
22
  class IRBCmd < Cmd
35
23
  def initialize(*)
36
24
  super
37
-
38
- parse!() do |op|
25
+
26
+ parse! do |op|
39
27
  #op.separator op.summary_indent
40
28
  end
41
29
  end
42
-
43
- def run()
30
+
31
+ def run
44
32
  super()
45
-
46
- irb_task = Raketeer::IRBTask.new()
33
+
34
+ irb_task = Raketeer::IRBTask.new
47
35
  irb_task = Rake::Task[irb_task.name]
48
-
49
- irb_task.reenable()
50
- irb_task.invoke()
51
-
36
+
37
+ irb_task.reenable
38
+ irb_task.invoke
39
+
52
40
  app.ran_cmd = true
53
41
  end
54
42
  end
@@ -1,23 +1,11 @@
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-2020 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
 
@@ -28,16 +16,16 @@ require 'raketeer/nokogiri_install_tasks'
28
16
 
29
17
  module Raketary
30
18
  ###
31
- # @author Jonathan Bradley Whited (@esotericpig)
19
+ # @author Jonathan Bradley Whited
32
20
  # @since 0.1.0
33
21
  ###
34
22
  class NokogiriCmd < Cmd
35
23
  def initialize(*)
36
24
  super
37
-
25
+
38
26
  @main_opts = 0
39
-
40
- parse!() do |op|
27
+
28
+ parse! do |op|
41
29
  op.on('-a','--apt','install Nokogiri libs for Ubuntu/Debian') do
42
30
  @main_opts += 1
43
31
  true
@@ -53,28 +41,28 @@ module Raketary
53
41
  op.separator op.summary_indent
54
42
  end
55
43
  end
56
-
57
- def run()
44
+
45
+ def run
58
46
  super()
59
47
  return if @main_opts <= 0
60
-
48
+
61
49
  if @main_opts >= 2
62
50
  raise DoNotRunCmdError,'Please choose only one platform to install the libs for.'
63
51
  end
64
-
52
+
65
53
  install_task = nil
66
-
54
+
67
55
  if app.options[:apt]
68
- install_task = Raketeer::NokogiriAPTTask.new()
56
+ install_task = Raketeer::NokogiriAPTTask.new
69
57
  elsif app.options[:dnf]
70
- install_task = Raketeer::NokogiriDNFTask.new()
58
+ install_task = Raketeer::NokogiriDNFTask.new
71
59
  elsif app.options[:other]
72
- install_task = Raketeer::NokogiriOtherTask.new()
60
+ install_task = Raketeer::NokogiriOtherTask.new
73
61
  end
74
-
75
- if !install_task.nil?()
62
+
63
+ if !install_task.nil?
76
64
  install_task.run(install_task,nil)
77
-
65
+
78
66
  app.ran_cmd = true
79
67
  end
80
68
  end