xezat 0.1.0 → 0.1.1

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 (60) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +75 -0
  3. data/.fasterer.yml +6 -0
  4. data/.rubocop.yml +33 -0
  5. data/Gemfile +4 -2
  6. data/README.md +2 -0
  7. data/Rakefile +5 -3
  8. data/bin/console +4 -3
  9. data/exe/xezat +1 -0
  10. data/lib/xezat.rb +8 -0
  11. data/lib/xezat/command/bump.rb +16 -127
  12. data/lib/xezat/command/bump/changelog.rb +29 -0
  13. data/lib/xezat/command/bump/compiler.rb +28 -0
  14. data/lib/xezat/command/bump/cygport_dep.rb +18 -0
  15. data/lib/xezat/command/bump/development_package.rb +22 -0
  16. data/lib/xezat/command/bump/file.rb +37 -0
  17. data/lib/xezat/command/bump/language.rb +30 -0
  18. data/lib/xezat/command/bump/runtime_package.rb +17 -0
  19. data/lib/xezat/command/bump/src_uri.rb +21 -0
  20. data/lib/xezat/command/bump/tool.rb +13 -0
  21. data/lib/xezat/command/debug.rb +2 -2
  22. data/lib/xezat/command/doctor.rb +4 -2
  23. data/lib/xezat/command/generate.rb +2 -2
  24. data/lib/xezat/command/init.rb +15 -11
  25. data/lib/xezat/command/port.rb +16 -7
  26. data/lib/xezat/config.rb +3 -1
  27. data/lib/xezat/cygchangelog.rb +24 -18
  28. data/lib/xezat/cygclasses.rb +4 -1
  29. data/lib/xezat/cygversion.rb +5 -3
  30. data/lib/xezat/debugger/linguist.rb +4 -0
  31. data/lib/xezat/debugger/variable.rb +2 -0
  32. data/lib/xezat/detector/autoconf.rb +2 -0
  33. data/lib/xezat/detector/automake.rb +2 -0
  34. data/lib/xezat/detector/boost.m4.rb +3 -0
  35. data/lib/xezat/detector/cmake.rb +2 -0
  36. data/lib/xezat/detector/gengetopt.rb +2 -0
  37. data/lib/xezat/detector/gnulib.rb +2 -0
  38. data/lib/xezat/detector/gobject-introspection.rb +2 -0
  39. data/lib/xezat/detector/halibut.rb +2 -0
  40. data/lib/xezat/detector/libQt5Core-devel.rb +2 -0
  41. data/lib/xezat/detector/libtool.rb +9 -0
  42. data/lib/xezat/detector/make.rb +3 -2
  43. data/lib/xezat/detector/meson.rb +2 -0
  44. data/lib/xezat/detector/ninja.rb +4 -0
  45. data/lib/xezat/detector/python27.rb +24 -0
  46. data/lib/xezat/detector/{python-docutils.rb → python3-docutils.rb} +5 -2
  47. data/lib/xezat/detector/python36.rb +24 -0
  48. data/lib/xezat/detector/roundup.rb +2 -0
  49. data/lib/xezat/detector/waf.rb +9 -1
  50. data/lib/xezat/detectors.rb +12 -1
  51. data/lib/xezat/ext/linguist/file_blob.rb +3 -1
  52. data/lib/xezat/generator/pkgconfig.rb +23 -20
  53. data/lib/xezat/main.rb +4 -3
  54. data/lib/xezat/packages.rb +7 -0
  55. data/lib/xezat/variables.rb +23 -4
  56. data/lib/xezat/version.rb +3 -1
  57. data/share/xezat/compilers.json +0 -3
  58. data/xezat.gemspec +13 -9
  59. metadata +70 -15
  60. data/.travis.yml +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 232d133a72ddf6d202df40c66764960972d57c45
4
- data.tar.gz: 58bc0d8f834b0ea48eb71f49ae1085a0cb6643e9
2
+ SHA256:
3
+ metadata.gz: c0af671c67dab5b04826969bc2ec3d76d2bebad555c9b56cdc2afaf9bafc8600
4
+ data.tar.gz: cd5799a4eaeb7f9bcdc7ae0ca59271b7d40241d07bb0f37d90a5554b0889e98f
5
5
  SHA512:
6
- metadata.gz: 47fd5be715978a678b9030ac424f7dedba6a4c13745535e06e4feba5300de6e14dc7b91e42b69c3234be1ed68dcb0e5785ac4ef01acbf06eca05f0db95d25082
7
- data.tar.gz: 2bca806c8f4b0aea539d130ba5cfe585fc86addf7b06920adbcb9640ad0a5149115268eb445bf6b0bdb5a64b0f10f59964b5c6ff98f217a4996a1729d8581c24
6
+ metadata.gz: 3c51af33761f4ff6e3edc6edb02e1352a864bd4a7dae447c98bf3328fd0d05b7c54684d3ec73394cf9d0ce81a0a21bb680ba9a89b42e14270d8f91da0c379c28
7
+ data.tar.gz: abdc28922f8369cef8a4aaabac83124f5208643ded6ad7af2c4517ef49cc4be05c8962849a33a5970de498a404dc8d417941fb28c32139947445fd146757859d
@@ -0,0 +1,75 @@
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
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby
11
+
12
+ working_directory: ~/repo
13
+
14
+ steps:
15
+ - checkout
16
+
17
+ - run:
18
+ name: Init & update submodule
19
+ command: |
20
+ git submodule init
21
+ git submodule update
22
+ git submodule foreach git pull origin master
23
+
24
+ # Download and cache dependencies
25
+ - restore_cache:
26
+ keys:
27
+ - v1-dependencies-{{ .Branch }}
28
+ # fallback to using the latest cache if no exact match is found
29
+ #- v1-dependencies-
30
+
31
+ - run:
32
+ name: Show ruby version
33
+ command: |
34
+ ruby -v
35
+
36
+ - run:
37
+ name: Install native libraries
38
+ command: |
39
+ sudo apt-get install cmake libicu-dev
40
+
41
+ - run:
42
+ name: Install dependencies
43
+ command: |
44
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
45
+
46
+ - save_cache:
47
+ paths:
48
+ - ./vendor/bundle
49
+ key: v1-dependencies-{{ .Branch }}
50
+
51
+ # Rubocop
52
+ - run:
53
+ name: Rubocop
54
+ command: |
55
+ bundle exec rubocop -D -c .rubocop.yml --format simple
56
+
57
+ # Fasterer
58
+ - run:
59
+ name: Fasterer
60
+ command: |
61
+ bundle exec fasterer
62
+
63
+ # Run tests
64
+ - run:
65
+ name: Run tests
66
+ command: |
67
+ mkdir /tmp/test-results
68
+ bundle exec rspec --no-color \
69
+ --format progress \
70
+ --format RspecJunitFormatter \
71
+ --out /tmp/test-results/rspec.xml
72
+
73
+ # Collect reports
74
+ - store_test_results:
75
+ path: /tmp/test-results
@@ -0,0 +1,6 @@
1
+ speedups:
2
+ sort_vs_sort_by: false
3
+
4
+ exclude_paths:
5
+ - 'spec/**/*.rb'
6
+ - 'vendor/**/*.rb'
@@ -0,0 +1,33 @@
1
+ require: rubocop-performance
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.3
5
+ Exclude:
6
+ - 'spec/cygport/**/*'
7
+ - 'vendor/**/*'
8
+
9
+ Layout/IndentHeredoc:
10
+ EnforcedStyle: active_support
11
+
12
+ Metrics/AbcSize:
13
+ Max: 40
14
+ Metrics/BlockLength:
15
+ Exclude:
16
+ - '*.gemspec'
17
+ - 'spec/**/*'
18
+ Metrics/CyclomaticComplexity:
19
+ Max: 10
20
+ Metrics/LineLength:
21
+ Max: 160
22
+ Metrics/MethodLength:
23
+ Max: 35
24
+ Metrics/ParameterLists:
25
+ Max: 8
26
+ Metrics/PerceivedComplexity:
27
+ Max: 12
28
+
29
+ Naming/FileName:
30
+ Enabled: false
31
+
32
+ Style/Documentation:
33
+ Enabled: false
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  # Specify your gem's dependencies in xezat.gemspec
6
8
  gemspec
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Xezat
2
2
 
3
+ [![CircleCI](https://circleci.com/gh/fd00/xezat/tree/master.svg?style=svg)](https://circleci.com/gh/fd00/xezat/tree/master)
4
+
3
5
  xezat helps you win at cygport.
4
6
 
5
7
  ## Installation
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "xezat"
4
+ require 'bundler/setup'
5
+ require 'xezat'
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 "xezat"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/exe/xezat CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  Encoding.default_external = 'UTF-8'
4
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
 
3
5
  module Xezat
@@ -8,4 +10,10 @@ module Xezat
8
10
  INI_FILE = File.expand_path(File.join(Dir.home, '.xezat'))
9
11
 
10
12
  LOG = Logger.new(STDOUT)
13
+ LOG.formatter = proc { |_severity, datetime, _progname, message|
14
+ "#{datetime}: #{message}\n"
15
+ }
16
+
17
+ class CygportProcessError < StandardError
18
+ end
11
19
  end
@@ -1,22 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'facets/file/atomic_write'
2
4
  require 'find'
3
5
  require 'json'
4
6
  require 'xezat'
7
+ require 'xezat/command/bump/changelog'
8
+ require 'xezat/command/bump/development_package'
9
+ require 'xezat/command/bump/file'
10
+ require 'xezat/command/bump/runtime_package'
11
+ require 'xezat/command/bump/src_uri'
5
12
  require 'xezat/cygchangelog'
6
13
  require 'xezat/cygclasses'
7
- require 'xezat/detectors'
8
- require 'xezat/ext/linguist/file_blob'
9
14
  require 'xezat/packages'
10
15
  require 'xezat/variables'
11
16
 
12
17
  module Xezat
13
-
14
- class FilePermissionError < StandardError
15
- end
16
-
17
- class IllegalStateError < StandardError
18
- end
19
-
20
18
  module Command
21
19
  class Bump
22
20
  include Xezat
@@ -27,134 +25,25 @@ module Xezat
27
25
  end
28
26
 
29
27
  def execute
30
- pkgs = packages()
28
+ LOG.debug('Start bumping')
29
+ pkgs = packages
31
30
  vars = variables(@cygport)
32
31
  readme_file = File.expand_path(File.join(vars[:C], 'README'))
33
32
 
34
33
  info = {
35
- src_uri: get_src_uri(vars),
36
- runtimes: get_runtime_packages(@cygport),
37
- developments: get_development_packages(vars, pkgs),
38
- files: get_files(vars),
39
- changelog: get_changelog(vars, @options, readme_file)
34
+ src_uri: get_src_uri(vars),
35
+ runtimes: get_runtime_packages(@cygport),
36
+ developments: get_development_packages(vars, pkgs),
37
+ files: get_files(vars),
38
+ changelog: get_changelog(vars, @options, readme_file)
40
39
  }
41
40
 
41
+ LOG.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
45
- end
46
-
47
-
48
- def get_src_uri(vars, cygclasses = CygclassManager.new)
49
- cygclasses.vcs.each do |vcs|
50
- next unless vars.key?("_#{vcs}_CYGCLASS_".intern)
51
- src_uri_key = "#{vcs.to_s.upcase}_URI".intern
52
- return vars[src_uri_key].split if vars.key?(src_uri_key)
53
- end
54
- vars[:SRC_URI].split
55
- end
56
-
57
-
58
- def get_runtime_packages(cygport)
59
- command = ['bash', File.expand_path(File.join(DATA_DIR, 'invoke_cygport_dep.sh')), cygport]
60
- result, error, status = Open3.capture3(command.join(' '))
61
- raise CygportProcessError, error unless status.success?
62
- result.gsub!(/^.*\*\*\*.*$/, '')
63
- result.split($INPUT_RECORD_SEPARATOR).map!(&:lstrip)
64
- end
65
-
66
-
67
- def get_development_packages(variables, packages)
68
- compilers = get_compilers(get_languages(variables[:S]), variables)
69
- tools = get_tools(variables)
70
- development_packages = (compilers + tools + [:cygport]).uniq.sort
71
- development_packages.map! do |package|
72
- packages[package] || ''
73
- end
74
- end
75
-
76
- def get_compilers(languages, variables)
77
- compiler_file = File.expand_path(File.join(DATA_DIR, 'compilers.json'))
78
- compiler_candidates = JSON.parse(File.read(compiler_file))
79
- compilers = []
80
- languages.uniq.each do |language|
81
- next unless compiler_candidates.key?(language)
82
- compiler_candidate = compiler_candidates[language]
83
- if compiler_candidate['package'] == 'python'
84
- pkg_names = variables[:PKG_NAMES] || variables[:PN]
85
- if pkg_names.include?('python3-')
86
- compilers << :'python3'
87
- elsif pkg_names.include?('pypi-')
88
- compilers << :'pypi'
89
- else
90
- compilers << compiler_candidate['package'].intern
91
- end
92
- else
93
- compilers << compiler_candidate['package'].intern
94
- end
95
- next unless compiler_candidate.key?('dependencies')
96
- compiler_candidate['dependencies'].each do |dependency|
97
- compilers << dependency.intern
98
- end
99
- end
100
- compilers.uniq
101
- end
102
45
 
103
- def get_languages(top_src_dir)
104
- languages_file = File.expand_path(File.join(DATA_DIR, 'languages.json'))
105
- languages_candidates = JSON.parse(File.read(languages_file))
106
- languages = []
107
- Find.find(top_src_dir) do |path|
108
- next if FileTest.directory?(path)
109
- name = languages_candidates[File.extname(path)]
110
- if name.nil?
111
- language = Xezat::Linguist::FileBlob.new(path).language
112
- next if language.nil?
113
- name = language.name
114
- end
115
- languages << name
116
- end
117
- languages
118
- end
119
-
120
- def get_tools(variables)
121
- DetectorManager.new().detect(variables)
122
- end
123
-
124
- def get_files(variables)
125
- pkg2files = {}
126
- variables[:pkg_name].each do |pkg_name|
127
- lst_file = File.expand_path(File.join(variables[:T], ".#{pkg_name}.lst"))
128
- raise IllegalStateError, "No such file: #{lst_file}" unless FileTest.readable?(lst_file)
129
- lines = File.readlines(lst_file)
130
- lines.delete_if do |path|
131
- path.strip!
132
- path[-1] == File::SEPARATOR # ignore directory
133
- end.map! do |path|
134
- File::SEPARATOR + path
135
- end
136
- if variables[:PN] == pkg_name
137
- readme = File::SEPARATOR + File.join('usr', 'share', 'doc', 'Cygwin', "#{pkg_name}.README")
138
- lines << readme.strip unless lines.include?(readme)
139
- end
140
- pkg2files[pkg_name.intern] = lines.sort
141
- end
142
- pkg2files
143
- end
144
-
145
- def get_changelog(variables, options, readme_file)
146
- current_version = variables[:PVR].intern
147
- if FileTest.exist?(readme_file)
148
- raise FilePermissionError, "Cannot read #{readme_file}" unless FileTest.readable?(readme_file)
149
- raise FilePermissionError, "Cannot write #{readme_file}" unless FileTest.writable?(readme_file)
150
- changelog = Cygchangelog.new(File.read(readme_file))
151
- message = options['message'] || 'Version bump.'
152
- changelog[current_version] = message unless changelog.key?(current_version)
153
- else
154
- changelog = Cygchangelog.new
155
- changelog[current_version] = 'Initial release by fd0 <https://github.com/fd00/>'
156
- end
157
- changelog
46
+ LOG.debug('End bumping')
158
47
  end
159
48
 
160
49
  def get_embedded_contents(variables, info)
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xezat'
4
+
5
+ module Xezat
6
+ class FilePermissionError < StandardError
7
+ end
8
+
9
+ module Command
10
+ class Bump
11
+ def get_changelog(variables, options, readme_file)
12
+ LOG.debug('Append latest log to changelog')
13
+ current_version = variables[:PVR].intern
14
+ if FileTest.exist?(readme_file)
15
+ raise FilePermissionError, "Cannot read #{readme_file}" unless FileTest.readable?(readme_file)
16
+ raise FilePermissionError, "Cannot write #{readme_file}" unless FileTest.writable?(readme_file)
17
+
18
+ changelog = Cygchangelog.new(File.read(readme_file))
19
+ message = options['message'] || 'Version bump.'
20
+ changelog[current_version] = message unless changelog.key?(current_version)
21
+ else
22
+ changelog = Cygchangelog.new
23
+ changelog[current_version] = 'Initial release by fd0 <https://github.com/fd00/>'
24
+ end
25
+ changelog
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xezat'
4
+
5
+ module Xezat
6
+ module Command
7
+ class Bump
8
+ def get_compilers(languages, _variables)
9
+ LOG.debug('Collect compilers')
10
+ compiler_file = File.expand_path(File.join(DATA_DIR, 'compilers.json'))
11
+ compiler_candidates = JSON.parse(File.read(compiler_file))
12
+ compilers = []
13
+ languages.uniq.each do |language|
14
+ next unless compiler_candidates.key?(language)
15
+
16
+ compiler_candidate = compiler_candidates[language]
17
+ compilers << compiler_candidate['package'].intern
18
+ next unless compiler_candidate.key?('dependencies')
19
+
20
+ compiler_candidate['dependencies'].each do |dependency|
21
+ compilers << dependency.intern
22
+ end
23
+ end
24
+ compilers.uniq
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+ require 'xezat'
5
+
6
+ module Xezat
7
+ module Command
8
+ class Bump
9
+ def invoke_cygport_dep(cygport)
10
+ command = ['bash', File.expand_path(File.join(DATA_DIR, 'invoke_cygport_dep.sh')), cygport]
11
+ result, error, status = Open3.capture3(command.join(' '))
12
+ raise CygportProcessError, error unless status.success?
13
+
14
+ result
15
+ end
16
+ end
17
+ end
18
+ end