filex 0.1.7 → 0.1.8

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: 68c1ba3c025c00952e357eb1485d2b0afa6b590fc4c1b95cad619ee593977522
4
- data.tar.gz: 8fca50b602f80d344cbba84cfa3ee9b973ccf483ae35fafb4d0907e5ba4ab3d4
3
+ metadata.gz: a05cb9f111f8adbf6c2c6937fb4383d9e3d3454af5340d266f5ab841ac2b7bef
4
+ data.tar.gz: 566736200110b37183e32afe47924ddf9b2226221b260d225eaaca975bd2c33d
5
5
  SHA512:
6
- metadata.gz: c2717226490e6f4d2832cdc9630f9a1f99a6023f3d61ff87635a29e12bfaffa7e2f654ec88aa072d08b50c0c6c47bd08779035d01b275abe834d0fa26669abc4
7
- data.tar.gz: 6078cc5f928ba8665b2c471e473aefe69bb9d0222197e9a072c3cb27397c6db5d0c65ffd0e6effcf00d9f86b87f58a87b503576a2d344dca32876f027d971cf6
6
+ metadata.gz: 54c7f6b9e8fe26228a0535b22c68fc3cfb1a7f755dc7a719a3bfcd8dbc792e07f8c24192abde1e7582b0a7740e1f442016d702baf58747774c3584b4a3f462e6
7
+ data.tar.gz: 066af2e43e25b792419b2bcc009bedb8df0a6bdb9dc7532a0ed6e39bd9fc0328068fa0079747a10afc95444b2354c49e9f5d2596f34ca58aed9db3a1d7761e20
@@ -0,0 +1,29 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ pull_request:
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ name: Ruby ${{ matrix.ruby }}
14
+ strategy:
15
+ matrix:
16
+ ruby:
17
+ - '2.7'
18
+
19
+ env:
20
+ BUNDLE_WITH: test
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: ${{ matrix.ruby }}
27
+ bundler-cache: true
28
+ - name: Run the default task
29
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -9,3 +9,6 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ /vendor/
13
+ .ruby-version
14
+
data/.rubocop.yml CHANGED
@@ -1,115 +1,15 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
+ require:
4
+ - rubocop-rake
5
+ - rubocop-rspec
6
+
3
7
  AllCops:
4
- TargetRubyVersion: 2.5
8
+ TargetRubyVersion: 2.7
9
+ NewCops: enable
10
+
5
11
  DisplayCopNames: true
6
12
  #
7
13
  StyleGuideBaseURL: https://github.com/fortissimo1997/ruby-style-guide/blob/japanese/README.ja.md
8
14
  #
9
- Exclude:
10
- - "Rakefile"
11
- - "*.gemspec"
12
- - "vendor/**/*"
13
- - "spec/*.rb"
14
- - 'bin/console'
15
- - 'bin/setup'
16
-
17
- Layout/ExtraSpacing:
18
- AllowForAlignment: true
19
- Layout/SpaceInsideBlockBraces:
20
- EnforcedStyle: space
21
- SpaceBeforeBlockParameters: false
22
- Layout/MultilineMethodCallIndentation:
23
- EnforcedStyle: indented
24
- Layout/EmptyLineAfterGuardClause:
25
- Enabled: false
26
- Layout/MultilineOperationIndentation:
27
- EnforcedStyle: indented
28
-
29
- Lint/UnderscorePrefixedVariableName:
30
- Enabled: false
31
- Lint/UnusedMethodArgument:
32
- Enabled: false
33
-
34
- Metrics/LineLength:
35
- Enabled: false
36
- Metrics/ClassLength:
37
- Exclude:
38
- # - "test/**/*.rb"
39
- Metrics/ParameterLists:
40
- Max: 7
41
- Metrics/MethodLength:
42
- Max: 30
43
-
44
- Naming/FileName:
45
- Enabled: false
46
- Naming/UncommunicativeMethodParamName:
47
- AllowedNames:
48
- - z
49
15
 
50
- Style/AsciiComments:
51
- Enabled: false
52
- Style/HashSyntax:
53
- Exclude:
54
- - "**/*.rake"
55
- - "Rakefile"
56
- Style/EmptyMethod:
57
- Enabled: false
58
- Style/FrozenStringLiteralComment:
59
- Enabled: false
60
- Style/NumericLiterals:
61
- Enabled: false
62
- Style/StringLiterals:
63
- EnforcedStyle: double_quotes
64
- Style/TrailingCommaInArrayLiteral:
65
- Enabled: false
66
- Style/TrailingCommaInHashLiteral:
67
- Enabled: false
68
- Style/TrailingCommaInArguments:
69
- Enabled: false
70
- Style/Documentation:
71
- Enabled: false
72
- Style/WordArray:
73
- Enabled: false
74
- Style/BarePercentLiterals:
75
- EnforcedStyle: percent_q
76
- Style/BracesAroundHashParameters:
77
- Enabled: false
78
- Style/PercentQLiterals:
79
- Enabled: false
80
- Style/UnneededPercentQ:
81
- Enabled: false
82
- Style/IfUnlessModifier:
83
- Enabled: false
84
- Style/NumericPredicate:
85
- Enabled: false
86
- Style/MutableConstant:
87
- Enabled: false
88
- Style/SymbolArray:
89
- Enabled: false
90
- Style/FormatString:
91
- Enabled: false
92
- Style/ConditionalAssignment:
93
- Enabled: false
94
- Style/WhileUntilModifier:
95
- Enabled: false
96
- Style/RedundantBegin:
97
- Enabled: false
98
- Style/YodaCondition:
99
- EnforcedStyle: forbid_for_equality_operators_only
100
- Style/TernaryParentheses:
101
- EnforcedStyle: require_parentheses_when_complex
102
- Style/MethodCallWithArgsParentheses:
103
- Exclude:
104
- - "**/*.rake"
105
- - "Rakefile"
106
- - "Gemfile"
107
- Enabled: true
108
- IgnoredMethods:
109
- - p
110
- - pp
111
- - puts
112
- - print
113
- - printf
114
- - raise
115
- - require
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,29 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-10-04 10:37:13 UTC using RuboCop version 1.36.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ # Configuration parameters: .
12
+ # SupportedStyles: space, no_space
13
+ Layout/SpaceAroundEqualsInParameterDefault:
14
+ EnforcedStyle: no_space
15
+
16
+ # Offense count: 4
17
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
18
+ Metrics/AbcSize:
19
+ Max: 24
20
+
21
+ # Offense count: 1
22
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
23
+ Metrics/CyclomaticComplexity:
24
+ Max: 8
25
+
26
+ # Offense count: 6
27
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
28
+ Metrics/MethodLength:
29
+ Max: 29
data/Gemfile CHANGED
@@ -1,4 +1,23 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in filex.gemspec
4
6
  gemspec
7
+
8
+ gem 'bundler'
9
+ gem 'erubis'
10
+ gem 'messagex'
11
+ gem 'rake', '~> 13.0'
12
+
13
+ group :test, optional: true do
14
+ gem 'rspec', '~> 3.0'
15
+ gem 'rubocop'
16
+ gem 'rubocop-performance'
17
+ gem 'rubocop-rake'
18
+ gem 'rubocop-rspec'
19
+ end
20
+
21
+ group :development do
22
+ gem 'yard'
23
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ filex (0.1.8)
5
+ bundler
6
+ erubis
7
+ messagex
8
+ rake (~> 13.0)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (7.0.4)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (>= 1.6, < 2)
16
+ minitest (>= 5.1)
17
+ tzinfo (~> 2.0)
18
+ ast (2.4.2)
19
+ concurrent-ruby (1.1.10)
20
+ diff-lcs (1.5.0)
21
+ erubis (2.7.0)
22
+ i18n (1.12.0)
23
+ concurrent-ruby (~> 1.0)
24
+ json (2.6.2)
25
+ messagex (0.1.5)
26
+ minitest (5.16.3)
27
+ parallel (1.22.1)
28
+ parser (3.1.2.1)
29
+ ast (~> 2.4.1)
30
+ rack (3.0.0)
31
+ rainbow (3.1.1)
32
+ rake (13.0.6)
33
+ regexp_parser (2.6.0)
34
+ rexml (3.2.5)
35
+ rspec (3.11.0)
36
+ rspec-core (~> 3.11.0)
37
+ rspec-expectations (~> 3.11.0)
38
+ rspec-mocks (~> 3.11.0)
39
+ rspec-core (3.11.0)
40
+ rspec-support (~> 3.11.0)
41
+ rspec-expectations (3.11.1)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.11.0)
44
+ rspec-mocks (3.11.1)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.11.0)
47
+ rspec-support (3.11.1)
48
+ rubocop (1.36.0)
49
+ json (~> 2.3)
50
+ parallel (~> 1.10)
51
+ parser (>= 3.1.2.1)
52
+ rainbow (>= 2.2.2, < 4.0)
53
+ regexp_parser (>= 1.8, < 3.0)
54
+ rexml (>= 3.2.5, < 4.0)
55
+ rubocop-ast (>= 1.20.1, < 2.0)
56
+ ruby-progressbar (~> 1.7)
57
+ unicode-display_width (>= 1.4.0, < 3.0)
58
+ rubocop-ast (1.21.0)
59
+ parser (>= 3.1.1.0)
60
+ rubocop-performance (1.15.0)
61
+ rubocop (>= 1.7.0, < 2.0)
62
+ rubocop-ast (>= 0.4.0)
63
+ rubocop-rails (2.16.1)
64
+ activesupport (>= 4.2.0)
65
+ rack (>= 1.1)
66
+ rubocop (>= 1.33.0, < 2.0)
67
+ rubocop-rake (0.6.0)
68
+ rubocop (~> 1.0)
69
+ rubocop-rspec (2.13.2)
70
+ rubocop (~> 1.33)
71
+ ruby-progressbar (1.11.0)
72
+ tzinfo (2.0.5)
73
+ concurrent-ruby (~> 1.0)
74
+ unicode-display_width (2.3.0)
75
+ webrick (1.7.0)
76
+ yard (0.9.28)
77
+ webrick (~> 1.7.0)
78
+
79
+ PLATFORMS
80
+ x86_64-linux
81
+
82
+ DEPENDENCIES
83
+ bundler
84
+ erubis
85
+ filex!
86
+ messagex
87
+ rake (~> 13.0)
88
+ rspec (~> 3.0)
89
+ rubocop
90
+ rubocop-performance
91
+ rubocop-rails
92
+ rubocop-rake
93
+ rubocop-rspec
94
+ yard
95
+
96
+ BUNDLED WITH
97
+ 2.3.22
data/Rakefile CHANGED
@@ -1,6 +1,29 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
3
2
 
4
- RSpec::Core::RakeTask.new(:spec)
3
+ require 'bundler/gem_tasks'
5
4
 
6
- task :default => :spec
5
+ begin
6
+ require 'rspec/core/rake_task'
7
+ rescue LoadError => e
8
+ puts e.message
9
+ end
10
+ begin
11
+ RSpec::Core::RakeTask.new(:spec)
12
+ rescue NameError, LoadError => e
13
+ puts e.message
14
+ end
15
+ begin
16
+ require 'rubocop/rake_task'
17
+ rescue LoadError => e
18
+ puts e.message
19
+ end
20
+ begin
21
+ RuboCop::RakeTask.new
22
+ rescue NameError, LoadError => e
23
+ puts e.message
24
+ end
25
+ begin
26
+ task default: %i[spec rubocop]
27
+ rescue LoadError => e
28
+ puts e.message
29
+ end
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "filex"
4
+ require 'bundler/setup'
5
+ require 'filex'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "filex"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/filex.gemspec CHANGED
@@ -1,47 +1,52 @@
1
+ # frozen_string_literal: true
1
2
 
2
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "filex/version"
5
+ require 'filex/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "filex"
8
+ spec.name = 'filex'
8
9
  spec.version = Filex::VERSION
9
- spec.authors = ["yasuo kominami"]
10
- spec.email = ["ykominami@gmail.com"]
10
+ spec.authors = ['yasuo kominami']
11
+ spec.email = ['ykominami@gmail.com']
11
12
 
12
- spec.summary = %q{Load a text file, yaml fortmat file and eruby format file and expand it.}
13
- spec.description = %q{Load a text file, yaml fortmat file and eruby format file and expand it.}
14
- spec.homepage = ""
15
- spec.license = "MIT"
13
+ spec.summary = 'Load a text file, yaml fortmat file and eruby format file and expand it.'
14
+ spec.description = 'Load a text file, yaml fortmat file and eruby format file and expand it.'
15
+ spec.homepage = ''
16
+ spec.license = 'MIT'
17
+ spec.required_ruby_version = '>= 2.7.0'
16
18
 
17
19
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
20
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
21
  if spec.respond_to?(:metadata)
20
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
22
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
23
 
22
- # spec.metadata["homepage_uri"] = spec.homepage
23
- # spec.metadata["source_code_uri"] = "text file, yaml format file and eruby format file2 file operation"
24
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
24
+ # spec.metadata["homepage_uri"] = spec.homepage
25
+ # spec.metadata["source_code_uri"] = "text file, yaml format file and eruby format file2 file operation"
26
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
25
27
  else
26
- raise "RubyGems 2.0 or newer is required to protect against " \
27
- "public gem pushes."
28
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
29
+ 'public gem pushes.'
28
30
  end
29
31
 
30
32
  # Specify which files should be added to the gem when it is released.
31
33
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
34
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
33
35
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
36
  end
35
- spec.bindir = "exe"
37
+ spec.bindir = 'exe'
36
38
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
- spec.require_paths = ["lib"]
39
+ spec.require_paths = ['lib']
38
40
 
39
- spec.add_development_dependency "bundler", "~> 2.0"
40
- spec.add_development_dependency "rake", "~> 10.0"
41
- spec.add_development_dependency "rspec", "~> 3.0"
42
- spec.add_development_dependency "rubocop"
43
- spec.add_development_dependency "rubocop-performance"
41
+ spec.add_runtime_dependency 'bundler'
42
+ spec.add_runtime_dependency 'erubis'
43
+ spec.add_runtime_dependency 'messagex'
44
+ spec.add_runtime_dependency 'rake', '~> 13.0'
44
45
 
45
- spec.add_runtime_dependency "messagex"
46
- spec.add_runtime_dependency "erubis"
46
+ spec.add_development_dependency 'rspec', '~> 3.0'
47
+ spec.add_development_dependency 'rubocop'
48
+ spec.add_development_dependency 'rubocop-performance'
49
+ spec.add_development_dependency 'rubocop-rails'
50
+
51
+ spec.metadata['rubygems_mfa_required'] = 'true'
47
52
  end
data/lib/filex/version.rb CHANGED
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Filex
2
4
  # バージョン番号
3
- VERSION = "0.1.7"
5
+ VERSION = '0.1.8'
4
6
  end
data/lib/filex.rb CHANGED
@@ -4,12 +4,12 @@
4
4
  # ファイル操作用モジュール
5
5
  #
6
6
  module Filex
7
- require "digest"
8
- require "pp"
9
- require "erubis"
10
- require "yaml"
11
- require "messagex"
12
- require "filex/version"
7
+ require 'digest'
8
+ require 'pp'
9
+ require 'erubis'
10
+ require 'yaml'
11
+ require 'messagex'
12
+ require 'filex/version'
13
13
 
14
14
  #
15
15
  # ファイル操作用モジュールのエラークラス
@@ -26,10 +26,10 @@ module Filex
26
26
  # @param mes [Messagex] Messagexクラスのインスタンス
27
27
  # @return [void]
28
28
  def self.setup(mes)
29
- mes.add_exitcode("EXIT_CODE_CANNOT_ANALYZE_YAMLFILE")
30
- mes.add_exitcode("EXIT_CODE_NAME_ERROR_EXCEPTION_IN_ERUBY")
31
- mes.add_exitcode("EXIT_CODE_ERROR_EXCEPTION_IN_ERUBY")
32
- mes.add_exitcode("EXIT_CODE_FILE_IS_EMPTY")
29
+ mes.add_exitcode('EXIT_CODE_CANNOT_ANALYZE_YAMLFILE')
30
+ mes.add_exitcode('EXIT_CODE_NAME_ERROR_EXCEPTION_IN_ERUBY')
31
+ mes.add_exitcode('EXIT_CODE_ERROR_EXCEPTION_IN_ERUBY')
32
+ mes.add_exitcode('EXIT_CODE_FILE_IS_EMPTY')
33
33
  end
34
34
 
35
35
  #
@@ -44,7 +44,7 @@ module Filex
44
44
  rescue Error => e
45
45
  mes.output_exception(e)
46
46
  mes.output_fatal("str=#{str}")
47
- exit(mes.ec("EXIT_CODE_CANNOT_ANALYZE_YAMLFILE"))
47
+ exit(mes.ec('EXIT_CODE_CANNOT_ANALYZE_YAMLFILE'))
48
48
  end
49
49
 
50
50
  yamlhs
@@ -71,7 +71,7 @@ module Filex
71
71
  def self.check_and_expand_yamlfile(yamlfname, objx, mes)
72
72
  lines = Filex.check_and_expand_file_lines(yamlfname, objx, mes)
73
73
  str = escape_by_single_quote_with_lines_in_yamlformat(lines, mes).join("\n")
74
- mes.output_debug("=str")
74
+ mes.output_debug('=str')
75
75
  mes.output_debug(str)
76
76
  load_yaml(str, mes)
77
77
  end
@@ -95,30 +95,30 @@ module Filex
95
95
  # @return [String] ファイルの内容
96
96
  def self.check_and_load_file(fname, mes)
97
97
  size = File.size?(fname)
98
- if size && (size > 0)
98
+ if size&.positive?
99
99
  begin
100
100
  strdata = File.read(fname)
101
101
  rescue IOError => e
102
102
  mesg = "Can't read #{fname}"
103
103
  mes.output_fatal(mesg)
104
104
  mes.output_exception(e)
105
- exit(mes.ec("EXIT_CODE_CANNOT_READ_FILE"))
105
+ exit(mes.ec('EXIT_CODE_CANNOT_READ_FILE'))
106
106
  rescue SystemCallError => e
107
107
  mesg = "Can't write #{fname}"
108
108
  mes.output_fatal(mesg)
109
109
  mes.output_exception(e)
110
- exit(mes.ec("EXIT_CODE_CANNOT_READ_FILE"))
110
+ exit(mes.ec('EXIT_CODE_CANNOT_READ_FILE'))
111
111
  end
112
112
  else
113
- mesg = %Q(Can not find #{fname} or is empty| size=|#{size}|)
113
+ mesg = %(Can not find #{fname} or is empty| size=|#{size}|)
114
114
  mes.output_error(mesg)
115
- exit(mes.ec("EXIT_CODE_CANNOT_FIND_FILE_OR_EMPTY"))
115
+ exit(mes.ec('EXIT_CODE_CANNOT_FIND_FILE_OR_EMPTY'))
116
116
  end
117
117
 
118
118
  if strdata.strip.empty?
119
- mesg = %Q(#{fname} is empty)
119
+ mesg = %(#{fname} is empty)
120
120
  mes.output_fatal(mesg)
121
- exit(mes.ec("EXIT_CODE_FILE_IS_EMPTY"))
121
+ exit(mes.ec('EXIT_CODE_FILE_IS_EMPTY'))
122
122
  else
123
123
  digest = Digest::MD5.hexdigest(strdata)
124
124
  mes.output_info(digest)
@@ -142,12 +142,12 @@ module Filex
142
142
  strdata = Erubis::Eruby.new(eruby_str).result(data)
143
143
  rescue NameError => e
144
144
  mes.output_exception(e)
145
- fnames.map {|x| mes.output_fatal(%Q(#{x[0]}=#{x[1]})) }
146
- exit(mes.ec("EXIT_CODE_NAME_ERROR_EXCEPTION_IN_ERUBY"))
145
+ fnames.map { |x| mes.output_fatal(%(#{x[0]}=#{x[1]})) }
146
+ exit(mes.ec('EXIT_CODE_NAME_ERROR_EXCEPTION_IN_ERUBY'))
147
147
  rescue Error => e
148
148
  mes.output_exception(e)
149
- fnames.map {|x| mes.output_fatal(%Q(#{x[0]}=#{x[1]})) }
150
- exit(mes.ec("EXIT_CODE_ERROR_EXCEPTION_IN_ERUBY"))
149
+ fnames.map { |x| mes.output_fatal(%(#{x[0]}=#{x[1]})) }
150
+ exit(mes.ec('EXIT_CODE_ERROR_EXCEPTION_IN_ERUBY'))
151
151
  end
152
152
  strdata
153
153
  end
@@ -164,8 +164,7 @@ module Filex
164
164
  mes.output_info("fname=#{fname}")
165
165
  mes.output_info("strdata=#{strdata}")
166
166
  mes.output_info("objx=#{objx}")
167
- strdata2 = expand_str(strdata, objx, mes, fname: fname)
168
- strdata2
167
+ expand_str(strdata, objx, mes, fname: fname)
169
168
  end
170
169
 
171
170
  #
@@ -216,7 +215,7 @@ module Filex
216
215
  # @param str [String] 分割対象文字列
217
216
  # @return [Array<String>] 第0要素 分割文字列の左側部分、第1要素 分割文字列の右側部分
218
217
  def self.hyphen_space(str)
219
- if (m = /^(\s*((\-\s+)+))(.*)$/.match(str))
218
+ if (m = /^(\s*((-\s+)+))(.*)$/.match(str))
220
219
  left = m[1]
221
220
  right = m[4]
222
221
  end
@@ -224,6 +223,34 @@ module Filex
224
223
  [left, right]
225
224
  end
226
225
 
226
+ def self.right_hyphen(line, right, state)
227
+ left = nil
228
+ if right&.index('-')
229
+ left, _right = hyphen_space(line)
230
+ state[:mes].output_info("F3|left=#{left}")
231
+ if left
232
+ state[:need_quoto] = true
233
+ state[:mes].output_info("NQ|1|need_quoto=#{state[:need_quoto]}")
234
+ end
235
+ end
236
+ left
237
+ end
238
+
239
+ def self.left_hyphen_space(line, state)
240
+ left, right = hyphen_space(line)
241
+ state[:mes].output_info("F4|left=#{left}|right=#{right}")
242
+ if right&.index('-')&.zero?
243
+ state[:mes].output_info("F-X|index=0|right.size=#{right.size}")
244
+ if right.size == 1
245
+ left += right
246
+ right = nil
247
+ else
248
+ state[:need_quoto] = true
249
+ end
250
+ end
251
+ [left, right]
252
+ end
253
+
227
254
  #
228
255
  # YAML形式の文字列に、シングルクォーテーションでのエスケープが必要かを調べる(第1段階)
229
256
  #
@@ -239,29 +266,10 @@ module Filex
239
266
  state[:mes].output_info("F2|left=#{left}|right=#{right}")
240
267
 
241
268
  # 右側部分に"-"が含まれていれば、"- "で区切れるか調べる
242
- if right&.index("-")
243
- left, right = hyphen_space(line)
244
- state[:mes].output_info("F3|left=#{left}")
245
- if left
246
- state[:need_quoto] = true
247
- state[:mes].output_info("NQ|1|need_quoto=#{state[:need_quoto]}")
248
- end
249
- end
269
+ left = right_hyphen(line, right, state)
250
270
 
251
271
  # lineが":"が分割できなければ、lineに対して"- "での分割を試みる
252
- unless left
253
- left, right = hyphen_space(line)
254
- state[:mes].output_info("F4|left=#{left}|right=#{right}")
255
- if right&.index("-") == 0
256
- state[:mes].output_info("F-X|index=0|right.size=#{right.size}")
257
- if right.size == 1
258
- left += right
259
- right = nil
260
- else
261
- state[:need_quoto] = true
262
- end
263
- end
264
- end
272
+ left, _right = left_hyphen_space(line, state) unless left
265
273
 
266
274
  state[:mes].output_info("FE|left=#{left}|right=#{right}")
267
275
  [left, right]
@@ -297,24 +305,23 @@ module Filex
297
305
  # @param left [String] 対象文字列の分割左側部分
298
306
  # @param right [String] 対象文字列の分割右側部分
299
307
  # @return [Array<String>] 第0要素 分割された文字列の左側部分、第1要素 分割された文字列の右側部分
300
- def self.escape_single_quote_yaml_second(line, state, left, right)
308
+ def self.escape_single_quote_yaml_second(_line, state, left, right)
301
309
  return [left, right] if right.nil? || right.strip.empty?
302
310
 
303
311
  state[:mes].output_info("S1|left=#{left}|right=#{right}")
304
312
  state[:has_quoto] = true if right.index("'")
305
313
 
306
- if right.index(":")
314
+ if right.index(':')
307
315
  state[:mes].output_info("S2|left=#{left}|right=#{right}")
308
316
 
309
317
  return([left, right]) if /\d:/.match?(right)
318
+
310
319
  state[:mes].output_info("S3|left=#{left}|right=#{right}")
311
320
  end
312
321
  left2, right2 = colon_space(right)
313
322
  state[:mes].output_info("S4|left2=#{left2}|right2=#{right2}")
314
323
 
315
- unless left2
316
- left2, right2 = check_colon_in_right(right, state)
317
- end
324
+ left2, right2 = check_colon_in_right(right, state) unless left2
318
325
 
319
326
  if left2
320
327
  left += left2
@@ -335,18 +342,21 @@ module Filex
335
342
  # @param left [String] 対象文字列の分割左側部分
336
343
  # @param right [String] 対象文字列の分割右側部分
337
344
  # @return [void]
338
- def self.escape_single_quote_yaml_third(line, state, left, right)
345
+ def self.escape_single_quote_yaml_third(_line, state, left, right)
339
346
  return if right.nil? || right.strip.empty?
347
+
340
348
  state[:mes].output_info("T1|left=#{left}|right=#{right}")
341
349
 
342
350
  return if state[:need_quoto]
351
+
343
352
  state[:mes].output_info("T2|left=#{left}|right=#{right}")
344
353
 
345
- return unless (right.index(":") || right.index("*"))
354
+ return unless right.index(':') || right.index('*')
355
+
346
356
  state[:mes].output_info("T3|left=#{left}|right=#{right}")
347
357
 
348
- state[:mes].output_info("T4 not need_quoto")
349
- unless right.index("-")
358
+ state[:mes].output_info('T4 not need_quoto')
359
+ unless right.index('-')
350
360
  state[:need_quoto] = true
351
361
  state[:mes].output_info("NQ|T5|need_quoto=#{state[:need_quoto]}")
352
362
  end
@@ -367,12 +377,10 @@ module Filex
367
377
 
368
378
  left, right = escape_single_quote_yaml_first(line, state)
369
379
  left, right = escape_single_quote_yaml_second(line, state, left, right)
370
- if left
371
- escape_single_quote_yaml_third(line, state, left, right)
372
- end
380
+ escape_single_quote_yaml_third(line, state, left, right) if left
373
381
  if state[:need_quoto] && !state[:has_quoto]
374
- state[:mes].output_info("2 need_quoto")
375
- left + %q(') + right + %q(')
382
+ state[:mes].output_info('2 need_quoto')
383
+ "#{left}'#{right}'"
376
384
  else
377
385
  line
378
386
  end
metadata CHANGED
@@ -1,43 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - yasuo kominami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-30 00:00:00.000000000 Z
11
+ date: 2022-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :development
19
+ version: '0'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: erubis
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: messagex
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
25
46
  - !ruby/object:Gem::Version
26
- version: '2.0'
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rake
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - "~>"
32
60
  - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
61
+ version: '13.0'
62
+ type: :runtime
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - "~>"
39
67
  - !ruby/object:Gem::Version
40
- version: '10.0'
68
+ version: '13.0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: rspec
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,27 +109,13 @@ dependencies:
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
- name: messagex
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: erubis
112
+ name: rubocop-rails
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
- type: :runtime
118
+ type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
@@ -116,11 +130,14 @@ executables: []
116
130
  extensions: []
117
131
  extra_rdoc_files: []
118
132
  files:
133
+ - ".github/workflows/main.yml"
119
134
  - ".gitignore"
120
135
  - ".rspec"
121
136
  - ".rubocop.yml"
137
+ - ".rubocop_todo.yml"
122
138
  - ".travis.yml"
123
139
  - Gemfile
140
+ - Gemfile.lock
124
141
  - LICENSE
125
142
  - LICENSE.txt
126
143
  - README.md
@@ -133,7 +150,8 @@ files:
133
150
  homepage: ''
134
151
  licenses:
135
152
  - MIT
136
- metadata: {}
153
+ metadata:
154
+ rubygems_mfa_required: 'true'
137
155
  post_install_message:
138
156
  rdoc_options: []
139
157
  require_paths:
@@ -142,15 +160,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
160
  requirements:
143
161
  - - ">="
144
162
  - !ruby/object:Gem::Version
145
- version: '0'
163
+ version: 2.7.0
146
164
  required_rubygems_version: !ruby/object:Gem::Requirement
147
165
  requirements:
148
166
  - - ">="
149
167
  - !ruby/object:Gem::Version
150
168
  version: '0'
151
169
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.7.6
170
+ rubygems_version: 3.1.6
154
171
  signing_key:
155
172
  specification_version: 4
156
173
  summary: Load a text file, yaml fortmat file and eruby format file and expand it.