xezat 0.1.2 → 0.2.2

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +43 -8
  3. data/.rubocop.yml +6 -3
  4. data/.ruby-version +1 -0
  5. data/lib/xezat/command/announce.rb +22 -0
  6. data/lib/xezat/command/bump/changelog.rb +8 -2
  7. data/lib/xezat/command/bump/compiler.rb +1 -1
  8. data/lib/xezat/command/bump/cygport_dep.rb +9 -2
  9. data/lib/xezat/command/bump/development_package.rb +4 -2
  10. data/lib/xezat/command/bump/file.rb +2 -2
  11. data/lib/xezat/command/bump/language.rb +1 -1
  12. data/lib/xezat/command/bump/runtime_package.rb +10 -4
  13. data/lib/xezat/command/bump/src_uri.rb +5 -5
  14. data/lib/xezat/command/bump.rb +3 -3
  15. data/lib/xezat/command/doctor.rb +0 -2
  16. data/lib/xezat/command/init.rb +1 -1
  17. data/lib/xezat/command/port.rb +1 -0
  18. data/lib/xezat/command/validate.rb +90 -6
  19. data/lib/xezat/config.rb +3 -3
  20. data/lib/xezat/cygchangelog.rb +8 -5
  21. data/lib/xezat/cygversion.rb +6 -1
  22. data/lib/xezat/detector/asciidoc.rb +20 -0
  23. data/lib/xezat/detector/autoconf.rb +1 -1
  24. data/lib/xezat/detector/boost.m4.rb +1 -1
  25. data/lib/xezat/detector/cmake.rb +1 -1
  26. data/lib/xezat/detector/libtool.rb +2 -2
  27. data/lib/xezat/detector/make.rb +1 -1
  28. data/lib/xezat/detector/nasm.rb +16 -0
  29. data/lib/xezat/detector/ninja.rb +1 -1
  30. data/lib/xezat/detector/python27.rb +5 -5
  31. data/lib/xezat/detector/python36.rb +10 -1
  32. data/lib/xezat/detector/python37.rb +10 -1
  33. data/lib/xezat/detector/{python36-docutils.rb → python38-docutils.rb} +7 -2
  34. data/lib/xezat/detector/python38.rb +22 -0
  35. data/lib/xezat/detector/python39.rb +26 -0
  36. data/lib/xezat/detector/waf.rb +1 -1
  37. data/lib/xezat/detectors.rb +12 -6
  38. data/lib/xezat/generator/pkgconfig.rb +6 -6
  39. data/lib/xezat/main.rb +10 -2
  40. data/lib/xezat/packages.rb +1 -1
  41. data/lib/xezat/variables.rb +7 -6
  42. data/lib/xezat/version.rb +1 -1
  43. data/lib/xezat.rb +4 -4
  44. data/share/xezat/categories.yaml +51 -0
  45. data/share/xezat/compilers.json +7 -0
  46. data/share/xezat/repository/github.json +3 -3
  47. data/share/xezat/repository/gnu.json +4 -0
  48. data/share/xezat/repository/savannah.json +1 -1
  49. data/share/xezat/repository/sourceforge.json +1 -1
  50. data/share/xezat/template/announce.erb +7 -0
  51. data/share/xezat/template/cmake.erb +8 -7
  52. data/xezat.gemspec +10 -9
  53. metadata +42 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e515798ac8ff0a0f6f60ba790faa9ee4e7b3c2fdbe70f55484d7c180929961a7
4
- data.tar.gz: d5159b3b559a9bd19f9f67bf14e1d0e496c052d83579286289446ece688c2be9
3
+ metadata.gz: 6183648a65f69a1fc1c1a85779066ba529614681aeb56fa78979ba9d9536c625
4
+ data.tar.gz: 20589012624b3e1690014d2b03ad2dda3fe01c464f5c3fb03223572a856a8dc4
5
5
  SHA512:
6
- metadata.gz: b1dae9f8ee739e65769e5466d973c02876c5dc7e170aa7f52d3c3c6f014cf74fe200fd9300dd2db27df0ad6c49ddbf4dfade8f7f0986382a76e127e4932cca75
7
- data.tar.gz: 81d6a0943f8f8160bfd0ac4b16b6517700392a91119b5472f2c78721f2f99ba71a35ae7d2925059da12b8c376bb2296f051b9e14910ac79cd4e2aca104a11597
6
+ metadata.gz: e94a00970240eb104ba88a2126a4fbd04d97820977a383a0498e584b3373b69e8dd98260c30cb59853e36f792949c5fa527a910345b19582ea1332541f2b2a48
7
+ data.tar.gz: b01a34f4cc54b8967e765045048d8759612de6653602c0833ff6b252b8302563ea286fcfde36eefb4d1ab58f623a3c32f299aedb5b741aef681363840f719e63
data/.circleci/config.yml CHANGED
@@ -1,13 +1,10 @@
1
- # Ruby CircleCI 2.0 configuration file
2
- #
3
- # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
- #
5
- version: 2
1
+ version: 2.1
2
+ orbs:
3
+ ruby: circleci/ruby@1.4.0
6
4
  jobs:
7
- build:
5
+ test:
8
6
  docker:
9
- # specify the version you desire here
10
- - image: circleci/ruby
7
+ - image: cimg/ruby:2.6
11
8
 
12
9
  working_directory: ~/repo
13
10
 
@@ -73,3 +70,41 @@ jobs:
73
70
  # Collect reports
74
71
  - store_test_results:
75
72
  path: /tmp/test-results
73
+ - store_artifacts:
74
+ path: ~/repo/coverage
75
+ destination: coverage
76
+
77
+ deploy:
78
+ docker:
79
+ - image: cimg/ruby:2.6
80
+ steps:
81
+ - checkout
82
+ - run:
83
+ name: Install native libraries
84
+ command: |
85
+ sudo apt-get install cmake libicu-dev
86
+
87
+ - run:
88
+ name: Install dependencies
89
+ command: |
90
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
91
+
92
+ - run:
93
+ name: Publish gem to Rubygems
94
+ command: bundle exec rake release
95
+
96
+ workflows:
97
+ test:
98
+ jobs:
99
+ - test:
100
+ filters:
101
+ tags:
102
+ only: /.*/
103
+ - deploy:
104
+ requires:
105
+ - test
106
+ filters:
107
+ tags:
108
+ only: /^v.*/
109
+ branches:
110
+ ignore: /.*/
data/.rubocop.yml CHANGED
@@ -1,11 +1,16 @@
1
1
  require: rubocop-performance
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.3
4
+ NewCops: enable
5
+ SuggestExtensions: false
6
+ TargetRubyVersion: 2.6
5
7
  Exclude:
6
8
  - 'spec/cygport/**/*'
7
9
  - 'vendor/**/*'
8
10
 
11
+ Layout/LineLength:
12
+ Max: 160
13
+
9
14
  Metrics/AbcSize:
10
15
  Max: 40
11
16
  Metrics/BlockLength:
@@ -14,8 +19,6 @@ Metrics/BlockLength:
14
19
  - 'spec/**/*'
15
20
  Metrics/CyclomaticComplexity:
16
21
  Max: 10
17
- Metrics/LineLength:
18
- Max: 160
19
22
  Metrics/MethodLength:
20
23
  Max: 35
21
24
  Metrics/ParameterLists:
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.4
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xezat/variables'
4
+
5
+ module Xezat
6
+ module Command
7
+ class Announce
8
+ include Xezat
9
+
10
+ def initialize(options, cygport)
11
+ @options = options
12
+ @cygport = cygport
13
+ end
14
+
15
+ def execute
16
+ variables = variables(@cygport)
17
+ erb = File.expand_path(File.join(TEMPLATE_DIR, 'announce.erb'))
18
+ print ERB.new(File.readlines(erb).join(nil), trim_mode: '%-').result(binding).chop # remove redundant new line
19
+ end
20
+ end
21
+ end
22
+ end
@@ -9,7 +9,7 @@ module Xezat
9
9
  module Command
10
10
  class Bump
11
11
  def get_changelog(variables, options, readme_file)
12
- Xezat.logger.debug('Append latest log to changelog')
12
+ Xezat.logger.debug(' Try to append latest log to changelog...')
13
13
  current_version = variables[:PVR].intern
14
14
  if FileTest.exist?(readme_file)
15
15
  raise FilePermissionError, "Cannot read #{readme_file}" unless FileTest.readable?(readme_file)
@@ -17,10 +17,16 @@ module Xezat
17
17
 
18
18
  changelog = Cygchangelog.new(File.read(readme_file))
19
19
  message = options['message'] || 'Version bump.'
20
- changelog[current_version] = message unless changelog.key?(current_version)
20
+ if changelog.length > 1 || !changelog.key?(current_version)
21
+ changelog[current_version] = message # overwrite unless initial package
22
+ Xezat.logger.debug(" '#{message}' appended")
23
+ else
24
+ Xezat.logger.warn(' Initial release protected')
25
+ end
21
26
  else
22
27
  changelog = Cygchangelog.new
23
28
  changelog[current_version] = 'Initial release by fd0 <https://github.com/fd00/>'
29
+ Xezat.logger.debug(' Initial release by you')
24
30
  end
25
31
  changelog
26
32
  end
@@ -6,7 +6,7 @@ module Xezat
6
6
  module Command
7
7
  class Bump
8
8
  def get_compilers(languages, _variables)
9
- Xezat.logger.debug('Collect compilers')
9
+ Xezat.logger.debug(' Collect compilers')
10
10
  compiler_file = File.expand_path(File.join(DATA_DIR, 'compilers.json'))
11
11
  compiler_candidates = JSON.parse(File.read(compiler_file))
12
12
  compilers = []
@@ -1,14 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'find'
3
4
  require 'open3'
4
5
  require 'xezat'
5
6
 
6
7
  module Xezat
7
8
  module Command
8
9
  class Bump
9
- def invoke_cygport_dep(cygport)
10
+ def invoke_cygport_dep(variables, cygport)
11
+ candidate_files = Find.find(variables[:D]).select do |file|
12
+ file.end_with?('.exe', '.dll', '.so')
13
+ end
14
+ additional_path = candidate_files.map do |file|
15
+ File.dirname(file)
16
+ end.sort.uniq.join(':')
10
17
  command = ['bash', File.expand_path(File.join(DATA_DIR, 'invoke_cygport_dep.sh')), cygport]
11
- result, error, status = Open3.capture3(command.join(' '))
18
+ result, error, status = Open3.capture3({ 'PATH' => "#{ENV['PATH']}:#{additional_path}" }, command.join(' '))
12
19
  raise CygportProcessError, error unless status.success?
13
20
 
14
21
  result
@@ -9,10 +9,12 @@ module Xezat
9
9
  module Command
10
10
  class Bump
11
11
  def get_development_packages(variables, packages)
12
- Xezat.logger.debug('Collect development packages')
12
+ Xezat.logger.debug(' Collect development packages')
13
13
  compilers = get_compilers(get_languages(variables[:S]), variables)
14
14
  tools = get_tools(variables)
15
- development_packages = (compilers + tools + [:cygport]).uniq.sort
15
+ build_requires = variables[:BUILD_REQUIRES].nil? ? [] : variables[:BUILD_REQUIRES].split.map(&:to_sym)
16
+ development_packages = (compilers + tools + build_requires + [:cygport]).uniq.sort
17
+ development_packages.delete(:'libssl-devel') if development_packages.include?(:'libssl1.0-devel')
16
18
  development_packages.map! do |package|
17
19
  packages[package] || ''
18
20
  end
@@ -9,10 +9,10 @@ module Xezat
9
9
  module Command
10
10
  class Bump
11
11
  def get_files(variables)
12
- Xezat.logger.debug('Collect files')
12
+ Xezat.logger.debug(' Collect files')
13
13
  pkg2files = {}
14
14
  variables[:pkg_name].each do |pkg_name|
15
- Xezat.logger.debug(" Collect #{pkg_name}")
15
+ Xezat.logger.debug(" Collect #{pkg_name}")
16
16
  lst_file = File.expand_path(File.join(variables[:T], ".#{pkg_name}.lst"))
17
17
  raise IllegalStateError, "No such file: #{lst_file}" unless FileTest.readable?(lst_file)
18
18
 
@@ -7,7 +7,7 @@ module Xezat
7
7
  module Command
8
8
  class Bump
9
9
  def get_languages(top_src_dir)
10
- Xezat.logger.debug('Collect languages')
10
+ Xezat.logger.debug(' Collect languages')
11
11
  languages_file = File.expand_path(File.join(DATA_DIR, 'languages.json'))
12
12
  languages_candidates = JSON.parse(File.read(languages_file))
13
13
  languages = []
@@ -7,10 +7,16 @@ require 'xezat/variables'
7
7
  module Xezat
8
8
  module Command
9
9
  class Bump
10
- def get_runtime_packages(cygport)
11
- Xezat.logger.debug('Collect runtime packages from cygport dep')
12
- result = invoke_cygport_dep(cygport)
13
- result.gsub(/^.*\*\*\*.*$/, '').split($INPUT_RECORD_SEPARATOR).map(&:lstrip)
10
+ def get_runtime_packages(variables, pkgs, cygport)
11
+ Xezat.logger.debug(' Collect runtime packages from cygport dep')
12
+ result = invoke_cygport_dep(variables, cygport)
13
+ runtime_packages = result.gsub(/^.*\*\*\*.*$/, '').split($INPUT_RECORD_SEPARATOR).map(&:lstrip)
14
+ build_requires = variables[:BUILD_REQUIRES].nil? ? [] : variables[:BUILD_REQUIRES].split.map(&:to_sym)
15
+ runtime_packages.delete(pkgs[:'libssl-devel']) if build_requires.include?(:'libssl1.0-devel')
16
+ variables[:REQUIRES]&.split&.each do |req|
17
+ runtime_packages << pkgs[req.to_sym]
18
+ end
19
+ runtime_packages.sort
14
20
  end
15
21
  end
16
22
  end
@@ -6,15 +6,15 @@ require 'xezat/cygclasses'
6
6
  module Xezat
7
7
  module Command
8
8
  class Bump
9
- def get_src_uri(vars, cygclasses = CygclassManager.new)
10
- Xezat.logger.debug('Collect SRC_URI')
9
+ def get_src_uri(variables, cygclasses = CygclassManager.new)
10
+ Xezat.logger.debug(' Collect SRC_URI')
11
11
  cygclasses.vcs.each do |vcs|
12
- next unless vars.key?("_#{vcs}_CYGCLASS_".intern)
12
+ next unless variables.key?("_#{vcs}_CYGCLASS_".intern)
13
13
 
14
14
  src_uri_key = "#{vcs.to_s.upcase}_URI".intern
15
- return vars[src_uri_key].split if vars.key?(src_uri_key)
15
+ return variables[src_uri_key].split if variables.key?(src_uri_key)
16
16
  end
17
- vars[:SRC_URI].split
17
+ variables[:SRC_URI].split
18
18
  end
19
19
  end
20
20
  end
@@ -32,13 +32,13 @@ module Xezat
32
32
 
33
33
  info = {
34
34
  src_uri: get_src_uri(vars),
35
- runtimes: get_runtime_packages(@cygport),
35
+ runtimes: get_runtime_packages(vars, pkgs, @cygport),
36
36
  developments: get_development_packages(vars, pkgs),
37
37
  files: get_files(vars),
38
38
  changelog: get_changelog(vars, @options, readme_file)
39
39
  }
40
40
 
41
- Xezat.logger.debug('Write ChangeLog atomically')
41
+ Xezat.logger.debug(' Write ChangeLog atomically')
42
42
  File.atomic_write(readme_file) do |f|
43
43
  f.write(get_embedded_contents(vars, info))
44
44
  end
@@ -48,7 +48,7 @@ module Xezat
48
48
 
49
49
  def get_embedded_contents(variables, info)
50
50
  erb = File.expand_path(File.join(TEMPLATE_DIR, 'README.erb'))
51
- ERB.new(File.readlines(erb).join(nil), nil, '%-').result(binding).chop # remove redundant new line
51
+ ERB.new(File.readlines(erb).join(nil), trim_mode: '%-').result(binding).chop # remove redundant new line
52
52
  end
53
53
  end
54
54
  end
@@ -7,8 +7,6 @@ module Xezat
7
7
  class Doctor
8
8
  include Xezat
9
9
 
10
- def initialize; end
11
-
12
10
  def execute
13
11
  get_contents_uniqueness.each do |path, pkg|
14
12
  puts "#{path} is not unique: #{pkg}" if pkg.length > 1
@@ -74,7 +74,7 @@ module Xezat
74
74
 
75
75
  def get_cygport(template_variables, category, summary, description, cygclasses, cygport)
76
76
  erb = File.expand_path(File.join(TEMPLATE_DIR, 'cygport.erb'))
77
- ERB.new(File.readlines(erb).join(nil), nil, '%-').result(binding)
77
+ ERB.new(File.readlines(erb).join(nil), trim_mode: '%-').result(binding)
78
78
  end
79
79
  end
80
80
  end
@@ -43,6 +43,7 @@ module Xezat
43
43
  port_dir = conf['xezat']['portdir'] || options[:portdir]
44
44
  raise NoPortDirectoryError if port_dir.nil?
45
45
 
46
+ Xezat.logger.debug(" Port directory: #{port_dir}")
46
47
  port_dir
47
48
  end
48
49
  end
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'net/http'
3
4
  require 'pkg-config'
5
+ require 'uri'
6
+ require 'xezat/packages'
4
7
  require 'xezat/variables'
5
8
 
6
9
  module Xezat
@@ -16,22 +19,103 @@ module Xezat
16
19
  def execute
17
20
  Xezat.logger.debug('Start validating')
18
21
  vars = variables(@cygport)
22
+ pkgs = packages
23
+
24
+ Xezat.logger.debug(' Validate .cygport')
25
+ validate_cygport(@cygport)
26
+
27
+ Xezat.logger.debug(' Validate category')
28
+ validate_category(vars[:CATEGORY])
29
+
30
+ Xezat.logger.debug(' Validate homepage')
31
+ validate_homepage(vars[:HOMEPAGE])
32
+
33
+ Xezat.logger.debug(' Validate BUILD_REQUIRES')
34
+ validate_build_requires(vars[:BUILD_REQUIRES], pkgs)
35
+
36
+ Xezat.logger.debug(' Validate *.pc')
19
37
  validate_pkgconfig(vars)
38
+
20
39
  Xezat.logger.debug('End validating')
21
40
  end
22
41
 
42
+ def validate_cygport(cygport)
43
+ original_string = File.read(cygport)
44
+ stripped_string = original_string.gsub(/^\xEF\xBB\xBF/, '')
45
+ Xezat.logger.error(' .cygport contains BOM') unless original_string == stripped_string
46
+ end
47
+
48
+ def validate_category(category)
49
+ categories_file = File.expand_path(File.join(DATA_DIR, 'categories.yaml'))
50
+ Xezat.logger.error(" Category is invalid : #{category}") unless YAML.safe_load(File.open(categories_file), [Symbol]).include?(category.downcase)
51
+ end
52
+
53
+ def validate_homepage(homepage)
54
+ response = Net::HTTP.get_response(URI.parse(homepage))
55
+ code = response.code
56
+ if code == '200'
57
+ Xezat.logger.debug(" code = #{response.code}")
58
+ else
59
+ Xezat.logger.error(" code = #{response.code}")
60
+ end
61
+ rescue OpenSSL::SSL::SSLError => e
62
+ raise e unless @options[:ignore]
63
+
64
+ Xezat.logger.error(' Ignore SSLError')
65
+ end
66
+
67
+ def validate_build_requires(build_requires, pkgs)
68
+ return if build_requires.nil?
69
+
70
+ build_requires.split.each do |build_require|
71
+ build_require_pkg = pkgs[build_require.to_sym]
72
+ if build_require_pkg.nil?
73
+ Xezat.logger.error(" #{build_require} not found")
74
+ else
75
+ Xezat.logger.debug(" #{build_require_pkg}")
76
+ end
77
+ end
78
+ end
79
+
23
80
  def validate_pkgconfig(variables)
24
81
  pkgconfig_path = File.join(variables[:D], 'usr', 'lib', 'pkgconfig')
25
82
  PKGConfig.add_path(pkgconfig_path)
26
83
  Dir.glob('*.pc', 0, base: pkgconfig_path).each do |pc|
27
84
  basename = File.basename(pc, '.pc')
28
- Xezat.logger.debug(" #{basename}.pc found")
85
+ Xezat.logger.debug(" #{basename}.pc found")
29
86
  modversion = PKGConfig.modversion(basename)
30
- Xezat.logger.debug(" modversion = #{modversion}")
31
- pv = variables[:PV][0]
32
- Xezat.logger.error(" modversion differs from $PN = #{pv}") unless modversion == pv
33
- Xezat.logger.debug(" cflags = #{PKGConfig.cflags(basename)}")
34
- Xezat.logger.debug(" libs = #{PKGConfig.libs(basename)}")
87
+ Xezat.logger.debug(" modversion = #{modversion}")
88
+ pv = variables[:PV][0].gsub(/\+.+$/, '')
89
+ Xezat.logger.error(" modversion differs from $PN = #{pv}") unless modversion == pv
90
+ Xezat.logger.debug(" cflags = #{PKGConfig.cflags(basename)}")
91
+ libs = PKGConfig.libs(basename)
92
+ Xezat.logger.debug(" libs = #{libs}")
93
+ validate_libs(variables, libs)
94
+ end
95
+ end
96
+
97
+ def validate_libs(variables, libs)
98
+ lib_dirs = [File.join(variables[:D], '/usr/lib'), '/usr/lib', '/usr/lib/w32api', '/usr/lib/gcc/x86_64-pc-cygwin/11']
99
+ libs.split do |option|
100
+ if option.start_with?('-l')
101
+ lib_name = option[2, 255] # Assume file length limit
102
+ found = false
103
+ lib_dirs.each do |dir|
104
+ archive_path = File.join(dir, "lib#{lib_name}.dll.a")
105
+ if File.exist?(archive_path)
106
+ Xezat.logger.debug(" #{lib_name} -> #{archive_path.gsub(variables[:D], '$D')}")
107
+ found = true
108
+ break
109
+ end
110
+ static_path = File.join(dir, "lib#{lib_name}.a")
111
+ next unless File.exist?(static_path)
112
+
113
+ Xezat.logger.debug(" #{lib_name} -> #{static_path}")
114
+ found = true
115
+ break
116
+ end
117
+ Xezat.logger.error(" #{lib_name} not found") unless found
118
+ end
35
119
  end
36
120
  end
37
121
  end
data/lib/xezat/config.rb CHANGED
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'inifile'
3
+ require 'yaml'
4
4
 
5
5
  module Xezat
6
6
  def config(filepath = nil)
7
- config = IniFile.new
7
+ config = {}
8
8
  config['cygwin'] = {
9
9
  'cygclassdir' => '/usr/share/cygport/cygclass'
10
10
  }
11
11
  config['xezat'] = {
12
12
  }
13
- config.merge!(IniFile.load(filepath)) if filepath
13
+ config.merge!(YAML.load_file(filepath)) if filepath
14
14
  config
15
15
  end
16
16
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'English'
3
4
  require 'xezat/cygversion'
4
5
 
5
6
  module Xezat
@@ -24,7 +25,7 @@ module Xezat
24
25
  next
25
26
  end
26
27
  matched_content = /^(.+)$/.match(line)
27
- next unless matched_content
28
+ next if matched_content.nil?
28
29
  raise ReadmeSyntaxError, 'Version missing' if version.nil?
29
30
 
30
31
  if @changelogs.key?(version)
@@ -48,13 +49,15 @@ module Xezat
48
49
  @changelogs.key?(key)
49
50
  end
50
51
 
51
- def each
52
+ def each(&block)
52
53
  logs = @changelogs.sort do |a, b|
53
54
  -(Cygversion.new(a[0].to_s) <=> Cygversion.new(b[0].to_s))
54
55
  end
55
- logs.each do |k, v|
56
- yield(k, v)
57
- end
56
+ logs.each(&block)
57
+ end
58
+
59
+ def length
60
+ @changelogs.length
58
61
  end
59
62
  end
60
63
  end
@@ -15,6 +15,8 @@ module Xezat
15
15
 
16
16
  def to_v
17
17
  [Gem::Version.new(@version), @revision, @release]
18
+ rescue ArgumentError
19
+ to_a
18
20
  end
19
21
 
20
22
  def to_a
@@ -22,7 +24,10 @@ module Xezat
22
24
  end
23
25
 
24
26
  def <=>(other)
25
- to_v <=> other.to_v
27
+ result = (to_v <=> other.to_v)
28
+ return result unless result.nil?
29
+
30
+ (to_a <=> other.to_a)
26
31
  end
27
32
  end
28
33
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'find'
4
+
5
+ module Xezat
6
+ module Detector
7
+ class Asciidoc
8
+ def detect(variables)
9
+ Find.find(variables[:S]) do |file|
10
+ next unless file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")
11
+
12
+ File.foreach(file) do |line|
13
+ return true if line.include?('asciidoc')
14
+ end
15
+ end
16
+ false
17
+ end
18
+ end
19
+ end
20
+ end
@@ -7,7 +7,7 @@ module Xezat
7
7
  class Autoconf
8
8
  def detect(variables)
9
9
  Find.find(variables[:S]) do |file|
10
- return true if file.end_with?(File::SEPARATOR + 'configure.ac') || file.end_with?(File::SEPARATOR + 'configure.in')
10
+ return true if file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")
11
11
  end
12
12
  false
13
13
  end
@@ -7,7 +7,7 @@ module Xezat
7
7
  class BoostM4
8
8
  def detect(variables)
9
9
  Find.find(variables[:S]) do |file|
10
- next unless file.end_with?(File::SEPARATOR + 'configure.ac') || file.end_with?(File::SEPARATOR + 'configure.in')
10
+ next unless file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")
11
11
 
12
12
  File.foreach(file) do |line|
13
13
  return true if line.lstrip.start_with?('BOOST_REQUIRE')
@@ -7,7 +7,7 @@ module Xezat
7
7
  class Cmake
8
8
  def detect(variables)
9
9
  Find.find(variables[:S]) do |file|
10
- return true if file.end_with?(File::SEPARATOR + 'CMakeLists.txt')
10
+ return true if file.end_with?("#{File::SEPARATOR}CMakeLists.txt")
11
11
  end
12
12
  false
13
13
  end
@@ -7,10 +7,10 @@ module Xezat
7
7
  class Libtool
8
8
  def detect(variables)
9
9
  Find.find(variables[:S]) do |file|
10
- return true if file.end_with?(File::SEPARATOR + 'ltmain.sh')
10
+ return true if file.end_with?("#{File::SEPARATOR}ltmain.sh")
11
11
  end
12
12
  Find.find(variables[:S]) do |file|
13
- next unless file.end_with?(File::SEPARATOR + 'Makefile') || file.end_with?(File::SEPARATOR + 'makefile')
13
+ next unless file.end_with?("#{File::SEPARATOR}Makefile", "#{File::SEPARATOR}makefile")
14
14
  next if File.directory?(file)
15
15
 
16
16
  File.foreach(file) do |line|
@@ -7,7 +7,7 @@ module Xezat
7
7
  class Make
8
8
  def detect(variables)
9
9
  Find.find(variables[:B]) do |file|
10
- return true if file.end_with?(File::SEPARATOR + 'Makefile') || file.end_with?(File::SEPARATOR + 'makefile')
10
+ return true if file.end_with?("#{File::SEPARATOR}Makefile", "#{File::SEPARATOR}makefile")
11
11
  end
12
12
  File.foreach(File.join(variables[:top], variables[:cygportfile])) do |line|
13
13
  return true if line.index('cygmake')
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Xezat
4
+ module Detector
5
+ class Nasm
6
+ def detect(variables)
7
+ if variables.key?(:_meson_CYGCLASS_)
8
+ File.foreach(File.join(variables[:S], 'meson.build')) do |line|
9
+ return true if line.include?("find_program('nasm')")
10
+ end
11
+ end
12
+ false
13
+ end
14
+ end
15
+ end
16
+ end
@@ -9,7 +9,7 @@ module Xezat
9
9
  return true if variables.key?(:_meson_CYGCLASS_)
10
10
 
11
11
  Find.find(variables[:B]) do |file|
12
- return true if file.end_with?(File::SEPARATOR + 'build.ninja')
12
+ return true if file.end_with?("#{File::SEPARATOR}build.ninja")
13
13
  end
14
14
  false
15
15
  end
@@ -11,11 +11,11 @@ module Xezat
11
11
  Find.find(variables[:D]) do |file|
12
12
  next unless file.end_with?('.py')
13
13
 
14
- File.foreach(file) do |line|
15
- return true if line.strip == '#!/usr/bin/env python' || line.strip.start_with?('#!/usr/bin/env python2')
16
-
17
- break
18
- end
14
+ first_line = File.readlines(file).first
15
+ return true if %r{^#!\s*/usr/bin/env\s*python2\s*$}.match?(first_line)
16
+ return true if %r{^#!\s*/usr/bin/env\s*python2.7\s*$}.match?(first_line)
17
+ return true if %r{^#!\s*/usr/bin/python2\s*$}.match?(first_line)
18
+ return true if %r{^#!\s*/usr/bin/python2.7\s*$}.match?(first_line)
19
19
  end
20
20
  false
21
21
  end