avm-tools 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47963424dd2adf9abec36f3469cb2ec324d6610b13b8f1080e1ed24827ed29c3
4
- data.tar.gz: 327281544236ae524f23e79b07047eb532c7ed0d4e46024a88e7fe0937860a23
3
+ metadata.gz: ada053a628dbec161f4e877cc0bd72884102354b6c8621a108c3ef0461f06acf
4
+ data.tar.gz: 5b5d4b4c53ce36d2856dbb7364048ef6fac3fa92109b80dc51a6d48b705e0a2d
5
5
  SHA512:
6
- metadata.gz: 4317de96095e224feb963c6ea2763c78541d70d47f222f67828741eff4ee7ab83b817c236c8a051a115a01e95a0b51d1f32b6ee16097d7c4d081b9755ee588fe
7
- data.tar.gz: 4dc0c24e635ac76d856da4bace11d42bf8bc021e7fbe6197450e0877c08f8a0f11db1234f667bcc4022ed7810eaa7235cd54a6e8c75f895d31d6ab3aac711976
6
+ metadata.gz: a20e940d7df2f44ed70eef41d49cca74ec0ea42b1ac787906c6c0d779ae3485f7b89f1d49e2dcfbbfae980a085ccd21027f8b828b6aa6f642876fc1046a90c56
7
+ data.tar.gz: 71236b4e428442adee98c040b3c91fb17d349c5cdc3f26a8167da91c2624f77c4cb63f8582d23ed9a7c0abb6214b77f253a68f31ef3153df29cce970308d36d5
data/exe/avm CHANGED
@@ -2,39 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  $LOAD_PATH.unshift("#{__dir__}/../lib")
5
-
6
- require 'avm/tools'
7
- require 'eac_ruby_utils'
8
-
9
- class AvmRunner < ::EacRubyUtils::Console::DocoptRunner
10
- include ::EacRubyUtils::Console::Speaker
11
-
12
- DOC = <<~DOCOPT
13
- Tools for AVM.
14
-
15
- Usage:
16
- __PROGRAM__ [options] git complete-issue
17
- __PROGRAM__ -h | --help
18
-
19
- Options:
20
- -h --help Show this screen.
21
- DOCOPT
22
-
23
- private
24
-
25
- def run
26
- raise "Unknown command: #{options}" unless git_complete_issue?
27
-
28
- ::Avm::Tools::Git::CompleteIssue.new(git_complete_issue_options)
29
- end
30
-
31
- def git_complete_issue_options
32
- { dir: '.' }
33
- end
34
-
35
- def git_complete_issue?
36
- options.fetch('git') && options.fetch('complete-issue')
37
- end
38
- end
39
-
40
- AvmRunner.new
5
+ require 'avm/tools/runner'
6
+ Avm::Tools::Runner.run
data/lib/avm.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ require 'avm/tools'
5
+ end
data/lib/avm/files.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Files
5
+ Dir["#{File.dirname(__FILE__)}/#{::File.basename(__FILE__, '.*')}/*.rb"].each do |path|
6
+ require path
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/object/blank'
4
+ require 'eac_ruby_utils/simple_cache'
5
+
6
+ module Avm
7
+ module Files
8
+ class Rotate
9
+ include ::EacRubyUtils::SimpleCache
10
+
11
+ attr_reader :source_path
12
+
13
+ def initialize(source_path)
14
+ @source_path = source_path
15
+ end
16
+
17
+ def run
18
+ validate_msg = validate
19
+ return validate_msg if validate_msg.present?
20
+
21
+ ::FileUtils.mv(source_path, target_path)
22
+ nil
23
+ end
24
+
25
+ private
26
+
27
+ def validate
28
+ return 'Source not exist' unless ::File.exist?(source_path)
29
+ return 'Already rotated' if source_rotated?
30
+
31
+ nil
32
+ end
33
+
34
+ def source_rotated?
35
+ source_basename_without_extension.match(/[PN]\d{4}\z/)
36
+ end
37
+
38
+ def source_extension_uncached
39
+ file_extension(::File.basename(source_path))
40
+ end
41
+
42
+ def source_basename_without_extension
43
+ ::File.basename(source_path, source_extension)
44
+ end
45
+
46
+ def target_path_uncached
47
+ ::File.join(::File.dirname(source_path), target_basename)
48
+ end
49
+
50
+ def target_basename
51
+ source_basename_without_extension + target_suffix + source_extension
52
+ end
53
+
54
+ def target_suffix
55
+ return '_UNKNOWN_MTIME' unless ::File.exist?(source_path)
56
+
57
+ t = ::File.mtime(source_path)
58
+ t.strftime('_%Y-%m-%d_%H-%M-%S_') + t.strftime('%z').gsub(/\A\+/, 'P').gsub(/\A\-/, 'N')
59
+ end
60
+
61
+ def file_extension(basename)
62
+ extension = ::File.extname(basename)
63
+ return '' if extension.blank?
64
+
65
+ file_extension(::File.basename(basename, extension)) + extension
66
+ end
67
+ end
68
+ end
69
+ end
data/lib/avm/tools.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_launcher'
4
-
5
3
  module Avm
6
4
  module Tools
7
5
  require 'avm/tools/version'
@@ -1,10 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_launcher/git/base'
4
+ require 'eac_ruby_utils/console/speaker'
5
+ require 'eac_ruby_utils/simple_cache'
6
+
3
7
  module Avm
4
8
  module Tools
5
9
  module Git
6
10
  class CompleteIssue
7
- include ::Eac::SimpleCache
11
+ include ::EacRubyUtils::SimpleCache
8
12
  include ::EacRubyUtils::Console::Speaker
9
13
 
10
14
  def initialize(options)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ Dir["#{File.dirname(__FILE__)}/#{::File.basename(__FILE__, '.*')}/*.rb"].each do |path|
5
+ require path
6
+ end
7
+
8
+ module Avm
9
+ module Tools
10
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
11
+ DOC = <<~DOCOPT
12
+ Tools for AVM.
13
+
14
+ Usage:
15
+ __PROGRAM__ [options] __SUBCOMMANDS__
16
+ __PROGRAM__ -h | --help
17
+
18
+ Options:
19
+ -h --help Show this screen.
20
+ DOCOPT
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'avm/tools/runner/files/rotate'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class Files < ::EacRubyUtils::Console::DocoptRunner
10
+ DOC = <<~DOCOPT
11
+ Files utilities for AVM.
12
+
13
+ Usage:
14
+ __PROGRAM__ [options] __SUBCOMMANDS__
15
+ __PROGRAM__ -h | --help
16
+
17
+ Options:
18
+ -h --help Show this screen.
19
+ DOCOPT
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'avm/files/rotate'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class Files < ::EacRubyUtils::Console::DocoptRunner
10
+ class Rotate < ::EacRubyUtils::Console::DocoptRunner
11
+ DOC = <<~DOCOPT
12
+ Rotates a file (Like a backup).
13
+
14
+ Usage:
15
+ __PROGRAM__ <path>
16
+ __PROGRAM__ -h | --help
17
+
18
+ Options:
19
+ -h --help Show this screen.
20
+ DOCOPT
21
+
22
+ def run
23
+ ::Avm::Files::Rotate.new(options.fetch('<path>')).run
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ Dir["#{File.dirname(__FILE__)}/#{::File.basename(__FILE__, '.*')}/*.rb"].each do |path|
5
+ require path
6
+ end
7
+
8
+ module Avm
9
+ module Tools
10
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
11
+ class Git < ::EacRubyUtils::Console::DocoptRunner
12
+ DOC = <<~DOCOPT
13
+ Git utilities for AVM.
14
+
15
+ Usage:
16
+ __PROGRAM__ [options] __SUBCOMMANDS__
17
+ __PROGRAM__ -h | --help
18
+
19
+ Options:
20
+ -h --help Show this screen.
21
+ DOCOPT
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'avm/tools/git/complete_issue'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class Git < ::EacRubyUtils::Console::DocoptRunner
10
+ class CompleteIssue < ::EacRubyUtils::Console::DocoptRunner
11
+ DOC = <<~DOCOPT
12
+ Closes a issue in a Git repository.
13
+
14
+ Usage:
15
+ __PROGRAM__
16
+ __PROGRAM__ -h | --help
17
+
18
+ Options:
19
+ -h --help Show this screen.
20
+ DOCOPT
21
+ end
22
+
23
+ def run
24
+ ::Avm::Tools::Git::CompleteIssue.new(git_complete_issue_options)
25
+ end
26
+
27
+ private
28
+
29
+ def git_complete_issue_options
30
+ { dir: '.' }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-29 00:00:00.000000000 Z
11
+ date: 2019-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_launcher
@@ -16,14 +16,76 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.5'
19
+ version: '0.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.5'
26
+ version: '0.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: eac_ruby_utils
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: '3.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: '3.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.74.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.74.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.34'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 1.34.1
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '1.34'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 1.34.1
27
89
  description:
28
90
  email:
29
91
  executables:
@@ -33,9 +95,17 @@ extra_rdoc_files: []
33
95
  files:
34
96
  - Gemfile
35
97
  - exe/avm
98
+ - lib/avm.rb
99
+ - lib/avm/files.rb
100
+ - lib/avm/files/rotate.rb
36
101
  - lib/avm/tools.rb
37
102
  - lib/avm/tools/git.rb
38
103
  - lib/avm/tools/git/complete_issue.rb
104
+ - lib/avm/tools/runner.rb
105
+ - lib/avm/tools/runner/files.rb
106
+ - lib/avm/tools/runner/files/rotate.rb
107
+ - lib/avm/tools/runner/git.rb
108
+ - lib/avm/tools/runner/git/complete_issue.rb
39
109
  - lib/avm/tools/version.rb
40
110
  homepage:
41
111
  licenses: []