bake-modernize 0.1.2 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fbae11851db3723d7447541f71edf6be25cf9628238a4f0448cc92452a297cd
4
- data.tar.gz: b44def12e5c6c99e1eeb48cf032ca7cf5218a4807a29653c162357a6c3c6d2bf
3
+ metadata.gz: 618ddd5d5d14fae0b60bdcb99792041860923d6c8d427a4c4434ee6647510cdd
4
+ data.tar.gz: d7fe3f033d7740faba648e91f2350977cc486f48ec2c2e2bdb557311c31a594d
5
5
  SHA512:
6
- metadata.gz: 585051b328bbe211011db904b5b6093fe73e1a5416078f4c0881b6a586c9f56d3cb680df4a91a338b1bdef029e388d5102fbd74270d766ae6d1f620f83c70a49
7
- data.tar.gz: e262f334b3ffda2e56f73cb5f508e9e3fe2b39df8714b8788b22bf1933303cf388662fa06a9c5c0a1dad186feecce7afa9470872a7e8c1fc011ec80ac3372035
6
+ metadata.gz: '01387668d332dce58fd867a0727a125e4fe5f8d84a28f53c61a946c48ebe06b06ff7cc7db6cbc986b2b7a7f16503289bdfa58e26cf1139eb3f9489ad9fb759a5'
7
+ data.tar.gz: a1f680d832d37a4591f2c71793384f66b71d54efceecd8a7c9e963b7348a199523bd26d16057880626bd33b14ade10b25b10e0901b86751e640a9b1eb9810951
@@ -1,4 +1,4 @@
1
1
 
2
2
  def modernize
3
- call('modernize:actions', 'modernize:gemfile', 'modernize:gemspec')
3
+ call('modernize:actions', 'modernize:editorconfig', 'modernize:gemfile', 'modernize:gemspec')
4
4
  end
@@ -1,5 +1,7 @@
1
1
 
2
2
  require 'bake/modernize'
3
+ require 'rugged'
4
+ require 'markly'
3
5
 
4
6
  def actions
5
7
  update(root: Dir.pwd)
@@ -14,4 +16,58 @@ def update(root:)
14
16
 
15
17
  template_root = Bake::Modernize.template_path_for('actions')
16
18
  Bake::Modernize.copy_template(template_root, root)
19
+
20
+ readme_path = File.expand_path("README.md", root)
21
+ repository_url = self.repository_url(root)
22
+ self.update_badges(readme_path, repository_url)
23
+ end
24
+
25
+ private
26
+
27
+ def repository_url(root)
28
+ repository = Rugged::Repository.discover(root)
29
+ git_url = repository.remotes['origin'].url
30
+
31
+ if match = git_url.match(/@(?<url>.*?):(?<path>.*?)(\.git)?\z/)
32
+ return "https://#{match[:url]}/#{match[:path]}"
33
+ end
34
+ end
35
+
36
+ def badge_for(repository_url = self.repository_url)
37
+ "[![Development Status](#{repository_url}/workflows/Development/badge.svg)](#{repository_url}/actions?workflow=Development)"
38
+ end
39
+
40
+ def badge?(node)
41
+ return false unless node.type == :link
42
+ return node.all?{|child| child.type == :image}
43
+ end
44
+
45
+ def badges?(node)
46
+ node.any?{|child| badge?(child)}
47
+ end
48
+
49
+ def update_badges(readme_path, repository_url)
50
+ root = Markly.parse(File.read(readme_path))
51
+
52
+ node = root.first_child
53
+
54
+ # Skip heading:
55
+ node = node.next if node.type == :header
56
+
57
+ replacement = Markly.parse(badge_for(repository_url))
58
+
59
+ # We are looking for the first paragraph which contains only links, which contain one image.
60
+ while node
61
+ if badges?(node)
62
+ node = node.replace(replacement.first_child)
63
+ break
64
+ elsif node.type == :header
65
+ node.insert_before(replacement.first_child)
66
+ break
67
+ end
68
+
69
+ node = node.next
70
+ end
71
+
72
+ File.write(readme_path, root.to_markdown(width: 0))
17
73
  end
@@ -0,0 +1,17 @@
1
+
2
+ require 'bake/modernize'
3
+
4
+ def editorconfig
5
+ update(root: Dir.pwd)
6
+ end
7
+
8
+ def update(root:)
9
+ editorconfig_path = File.expand_path(".editorconfig", root)
10
+
11
+ if File.exist?(editorconfig_path)
12
+ FileUtils.rm_rf(editorconfig_path)
13
+ end
14
+
15
+ template_root = Bake::Modernize.template_path_for('editorconfig')
16
+ Bake::Modernize.copy_template(template_root, root)
17
+ end
@@ -70,7 +70,7 @@ def update(path: self.default_gemspec_path, output: $stdout)
70
70
  end
71
71
 
72
72
  if required_ruby_version = spec.required_ruby_version
73
- output.puts
73
+ output.puts "\t"
74
74
  output.puts "\tspec.required_ruby_version = #{required_ruby_version.to_s.inspect}"
75
75
  end
76
76
 
@@ -107,7 +107,7 @@ def directory_glob_for(spec, paths = spec.files)
107
107
  end
108
108
  end
109
109
 
110
- return "Dir['{#{directories.keys.join(',')}}/**/*', base: __dir__]"
110
+ return "Dir.glob('{#{directories.keys.join(',')}}/**/*', File::FNM_DOTMATCH, base: __dir__)"
111
111
  end
112
112
 
113
113
  def format_dependency(dependency)
@@ -155,7 +155,7 @@ end
155
155
  GITHUB_PROJECT = /github.com\/(?<account>.*?)\/(?<project>.*?)\/?/
156
156
 
157
157
  def detect_funding_uri(spec)
158
- if match = spec.homepage.match(GITHUB_PROJECT)
158
+ if match = spec.homepage&.match(GITHUB_PROJECT)
159
159
  account = match[:account]
160
160
 
161
161
  funding_uri = "https://github.com/sponsors/#{account}/"
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Bake
22
22
  module Modernize
23
- VERSION = "0.1.2"
23
+ VERSION = "0.3.0"
24
24
  end
25
25
  end
@@ -0,0 +1,46 @@
1
+ name: Development
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ${{matrix.os}}-latest
8
+ continue-on-error: ${{matrix.experimental}}
9
+
10
+ strategy:
11
+ matrix:
12
+ os:
13
+ - ubuntu
14
+ - macos
15
+
16
+ ruby:
17
+ - 2.5
18
+ - 2.6
19
+ - 2.7
20
+
21
+ experimental: [false]
22
+ env: [""]
23
+
24
+ include:
25
+ - os: ubuntu
26
+ ruby: truffleruby
27
+ experimental: true
28
+ - os: ubuntu
29
+ ruby: jruby
30
+ experimental: true
31
+ - os: ubuntu
32
+ ruby: head
33
+ experimental: true
34
+
35
+ steps:
36
+ - uses: actions/checkout@v2
37
+ - uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: ${{matrix.ruby}}
40
+
41
+ - name: Install dependencies
42
+ run: ${{matrix.env}} bundle install --without development
43
+
44
+ - name: Run tests
45
+ timeout-minutes: 5
46
+ run: ${{matrix.env}} bundle exec rspec
@@ -0,0 +1,5 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = tab
5
+ indent_size = 2
@@ -0,0 +1,47 @@
1
+ # #{title}
2
+
3
+ #{description}
4
+
5
+ [![Development](https://github.com/#{account}/#{project}/workflows/Development/badge.svg)](https://github.com/#{account}/#{project}/actions?workflow=Development)
6
+
7
+ ## Motivation
8
+
9
+ #{motivation}
10
+
11
+ ## Usage
12
+
13
+ Please see the [project documentation](https://#{account}.github.io/#{project}/) or run it locally using `bake utopia:project:serve`.
14
+
15
+ ## Contributing
16
+
17
+ We welcome contributions to this project.
18
+
19
+ 1. Fork it
20
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
21
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
22
+ 4. Push to the branch (`git push origin my-new-feature`)
23
+ 5. Create new Pull Request
24
+
25
+ ## License
26
+
27
+ Released under the MIT license.
28
+
29
+ Copyright, 2020, by [Samuel G. D. Williams](http://www.codeotaku.com).
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining a copy
32
+ of this software and associated documentation files (the "Software"), to deal
33
+ in the Software without restriction, including without limitation the rights
34
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35
+ copies of the Software, and to permit persons to whom the Software is
36
+ furnished to do so, subject to the following conditions:
37
+
38
+ The above copyright notice and this permission notice shall be included in
39
+ all copies or substantial portions of the Software.
40
+
41
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
47
+ THE SOFTWARE.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bake-modernize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-24 00:00:00.000000000 Z
11
+ date: 2020-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: markly
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rugged
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: bake-bundler
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -66,24 +94,28 @@ dependencies:
66
94
  - - ">="
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0'
69
- description:
70
- email:
97
+ description:
98
+ email:
71
99
  executables: []
72
100
  extensions: []
73
101
  extra_rdoc_files: []
74
102
  files:
75
103
  - bake/modernize.rb
76
104
  - bake/modernize/actions.rb
105
+ - bake/modernize/editorconfig.rb
77
106
  - bake/modernize/gemfile.rb
78
107
  - bake/modernize/gemspec.rb
79
108
  - lib/bake/modernize.rb
80
109
  - lib/bake/modernize/version.rb
110
+ - template/actions/.github/workflows/development.yml
111
+ - template/editorconfig/.editorconfig
112
+ - template/readme/README.md
81
113
  homepage: https://github.com/ioquatix/bake-modernize
82
114
  licenses:
83
115
  - MIT
84
116
  metadata:
85
117
  funding_uri: https://github.com/sponsors/ioquatix/
86
- post_install_message:
118
+ post_install_message:
87
119
  rdoc_options: []
88
120
  require_paths:
89
121
  - lib
@@ -99,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
131
  version: '0'
100
132
  requirements: []
101
133
  rubygems_version: 3.1.2
102
- signing_key:
134
+ signing_key:
103
135
  specification_version: 4
104
136
  summary: Automatically modernize parts of your project/gem.
105
137
  test_files: []