ruby_leiningen 0.24.0.pre.6 → 0.24.0.pre.7

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: 3e94778c404922e29dc5189f2229d213c7460cb62aae1a05ed181d1ea76a9e30
4
- data.tar.gz: ac25972328c16933a33e242b5cf048e5e4b38d1c3b7ff7fff4c46255ed542ed1
3
+ metadata.gz: e549b8cc69dc3899d4607f03743a5043311fa16d4798e3d9e23c720781e44aac
4
+ data.tar.gz: a60245fa5c45664a228bd40765b295892b95fdad82ff5ec8149da4733e4ba54a
5
5
  SHA512:
6
- metadata.gz: 865d737bf00495d78f6261d2be560d414a40a0cd12990fc8fc9c403e19b64c630c75ecbc18c9e93f118183db09dd1c00854ed2b05f104e904a76a1be219e352a
7
- data.tar.gz: 465d316adbafcac2396c5d642bc5908556e50b65e09271c8b24dc450bddd3268757aeddd31277819261c0424714265aa86fda797dfbd7e70ddff604f5722ce33
6
+ metadata.gz: 9412cb38b4a4a3d0593d0dcd4cd6656f78995a5a61eeeb01d8c9eb933a44435b6bab25287a566cdb50446943e7744f14f164869bec94800783479f6c3e2f75c8
7
+ data.tar.gz: 79454751e0af70e7ef2c0b738bf6e0b046b864d4b6844e5256f339525371e992a173ff920adc38d2bf60a24faff0d739b148d32ea08a665c45541f18bf21bc68
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in ruby_leiningen.gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_leiningen (0.24.0.pre.6)
4
+ ruby_leiningen (0.24.0.pre.7)
5
5
  activesupport (>= 6.0.2, < 8)
6
6
  lino (~> 3.0)
7
7
 
@@ -15,9 +15,11 @@ GEM
15
15
  tzinfo (~> 2.0)
16
16
  addressable (2.8.0)
17
17
  public_suffix (>= 2.0.2, < 5.0)
18
+ ast (2.4.2)
18
19
  colored2 (3.1.2)
19
20
  concurrent-ruby (1.1.9)
20
21
  diff-lcs (1.5.0)
22
+ docile (1.4.0)
21
23
  excon (0.92.0)
22
24
  faraday (1.10.0)
23
25
  faraday-em_http (~> 1.0)
@@ -56,7 +58,11 @@ GEM
56
58
  faraday (>= 0.9)
57
59
  sawyer (~> 0.8.0, >= 0.5.3)
58
60
  open4 (1.3.4)
61
+ parallel (1.22.1)
62
+ parser (3.1.1.0)
63
+ ast (~> 2.4.1)
59
64
  public_suffix (4.0.6)
65
+ rainbow (3.1.1)
60
66
  rake (13.0.6)
61
67
  rake_circle_ci (0.9.0)
62
68
  colored2 (~> 3.1)
@@ -78,6 +84,8 @@ GEM
78
84
  colored2 (~> 3.1)
79
85
  rake_factory (~> 0.23)
80
86
  sshkey (~> 2.0)
87
+ regexp_parser (2.2.1)
88
+ rexml (3.2.5)
81
89
  rspec (3.11.0)
82
90
  rspec-core (~> 3.11.0)
83
91
  rspec-expectations (~> 3.11.0)
@@ -91,15 +99,38 @@ GEM
91
99
  diff-lcs (>= 1.2.0, < 2.0)
92
100
  rspec-support (~> 3.11.0)
93
101
  rspec-support (3.11.0)
102
+ rubocop (1.27.0)
103
+ parallel (~> 1.10)
104
+ parser (>= 3.1.0.0)
105
+ rainbow (>= 2.2.2, < 4.0)
106
+ regexp_parser (>= 1.8, < 3.0)
107
+ rexml
108
+ rubocop-ast (>= 1.16.0, < 2.0)
109
+ ruby-progressbar (~> 1.7)
110
+ unicode-display_width (>= 1.4.0, < 3.0)
111
+ rubocop-ast (1.16.0)
112
+ parser (>= 3.1.1.0)
113
+ rubocop-rake (0.6.0)
114
+ rubocop (~> 1.0)
115
+ rubocop-rspec (2.9.0)
116
+ rubocop (~> 1.19)
117
+ ruby-progressbar (1.11.0)
94
118
  ruby2_keywords (0.0.5)
95
119
  ruby_gpg2 (0.8.0)
96
120
  lino (>= 1.5)
97
121
  sawyer (0.8.2)
98
122
  addressable (>= 2.3.5)
99
123
  faraday (> 0.8, < 2.0)
124
+ simplecov (0.21.2)
125
+ docile (~> 1.1)
126
+ simplecov-html (~> 0.11)
127
+ simplecov_json_formatter (~> 0.1)
128
+ simplecov-html (0.12.3)
129
+ simplecov_json_formatter (0.1.4)
100
130
  sshkey (2.0.0)
101
131
  tzinfo (2.0.4)
102
132
  concurrent-ruby (~> 1.0)
133
+ unicode-display_width (2.1.0)
103
134
 
104
135
  PLATFORMS
105
136
  ruby
@@ -115,7 +146,11 @@ DEPENDENCIES
115
146
  rake_gpg
116
147
  rake_ssh
117
148
  rspec
149
+ rubocop
150
+ rubocop-rake
151
+ rubocop-rspec
118
152
  ruby_leiningen!
153
+ simplecov
119
154
 
120
155
  BUNDLED WITH
121
- 2.3.9
156
+ 2.3.11
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
  require 'rake_circle_ci'
3
5
  require 'rake_github'
@@ -5,17 +7,26 @@ require 'rake_ssh'
5
7
  require 'rake_gpg'
6
8
  require 'securerandom'
7
9
  require 'rspec/core/rake_task'
10
+ require 'rubocop/rake_task'
8
11
 
9
- task :default => :spec
10
-
11
- RSpec::Core::RakeTask.new(:spec)
12
+ task default: %i[
13
+ library:fix
14
+ test:unit
15
+ ]
12
16
 
13
17
  namespace :encryption do
18
+ namespace :directory do
19
+ desc 'Ensure CI secrets directory exists.'
20
+ task :ensure do
21
+ FileUtils.mkdir_p('config/secrets/ci')
22
+ end
23
+ end
24
+
14
25
  namespace :passphrase do
15
- task :generate do
16
- File.open('config/secrets/ci/encryption.passphrase', 'w') do |f|
17
- f.write(SecureRandom.base64(36))
18
- end
26
+ desc 'Generate encryption passphrase used by CI.'
27
+ task generate: ['directory:ensure'] do
28
+ File.write('config/secrets/ci/encryption.passphrase',
29
+ SecureRandom.base64(36))
19
30
  end
20
31
  end
21
32
  end
@@ -23,85 +34,111 @@ end
23
34
  namespace :keys do
24
35
  namespace :deploy do
25
36
  RakeSSH.define_key_tasks(
26
- path: 'config/secrets/ci/',
27
- comment: 'maintainers@infrablocks.io')
37
+ path: 'config/secrets/ci/',
38
+ comment: 'maintainers@infrablocks.io'
39
+ )
28
40
  end
29
41
 
30
42
  namespace :gpg do
31
43
  RakeGPG.define_generate_key_task(
32
- output_directory: 'config/secrets/ci',
33
- name_prefix: 'gpg',
34
- owner_name: 'InfraBlocks Maintainers',
35
- owner_email: 'maintainers@infrablocks.io',
36
- owner_comment: 'ruby_leiningen CI Key')
44
+ output_directory: 'config/secrets/ci',
45
+ name_prefix: 'gpg',
46
+ owner_name: 'InfraBlocks Maintainers',
47
+ owner_email: 'maintainers@infrablocks.io',
48
+ owner_comment: 'ruby_leiningen CI Key'
49
+ )
37
50
  end
38
51
  end
39
52
 
53
+ namespace :secrets do
54
+ desc 'Regenerate all generatable secrets.'
55
+ task regenerate: %w[
56
+ encryption:passphrase:generate
57
+ keys:deploy:generate
58
+ keys:gpg:generate
59
+ ]
60
+ end
61
+
62
+ RuboCop::RakeTask.new
63
+
64
+ namespace :library do
65
+ desc 'Run all checks of the library'
66
+ task check: [:rubocop]
67
+
68
+ desc 'Attempt to automatically fix issues with the library'
69
+ task fix: [:'rubocop:auto_correct']
70
+ end
71
+
72
+ namespace :test do
73
+ RSpec::Core::RakeTask.new(:unit)
74
+ end
75
+
40
76
  RakeCircleCI.define_project_tasks(
41
- namespace: :circle_ci,
42
- project_slug: 'github/infrablocks/ruby_leiningen'
77
+ namespace: :circle_ci,
78
+ project_slug: 'github/infrablocks/ruby_leiningen'
43
79
  ) do |t|
44
80
  circle_ci_config =
45
- YAML.load_file('config/secrets/circle_ci/config.yaml')
81
+ YAML.load_file('config/secrets/circle_ci/config.yaml')
46
82
 
47
- t.api_token = circle_ci_config["circle_ci_api_token"]
83
+ t.api_token = circle_ci_config['circle_ci_api_token']
48
84
  t.environment_variables = {
49
- ENCRYPTION_PASSPHRASE:
50
- File.read('config/secrets/ci/encryption.passphrase')
51
- .chomp
85
+ ENCRYPTION_PASSPHRASE:
86
+ File.read('config/secrets/ci/encryption.passphrase')
87
+ .chomp
52
88
  }
53
89
  t.checkout_keys = []
54
90
  t.ssh_keys = [
55
- {
56
- hostname: "github.com",
57
- private_key: File.read('config/secrets/ci/ssh.private')
58
- }
91
+ {
92
+ hostname: 'github.com',
93
+ private_key: File.read('config/secrets/ci/ssh.private')
94
+ }
59
95
  ]
60
96
  end
61
97
 
62
98
  RakeGithub.define_repository_tasks(
63
- namespace: :github,
64
- repository: 'infrablocks/ruby_leiningen',
99
+ namespace: :github,
100
+ repository: 'infrablocks/ruby_leiningen'
65
101
  ) do |t, args|
66
102
  github_config =
67
- YAML.load_file('config/secrets/github/config.yaml')
103
+ YAML.load_file('config/secrets/github/config.yaml')
68
104
 
69
- t.access_token = github_config["github_personal_access_token"]
105
+ t.access_token = github_config['github_personal_access_token']
70
106
  t.deploy_keys = [
71
- {
72
- title: 'CircleCI',
73
- public_key: File.read('config/secrets/ci/ssh.public')
74
- }
107
+ {
108
+ title: 'CircleCI',
109
+ public_key: File.read('config/secrets/ci/ssh.public')
110
+ }
75
111
  ]
76
112
  t.branch_name = args.branch_name
77
113
  t.commit_message = args.commit_message
78
114
  end
79
115
 
80
116
  namespace :pipeline do
81
- task :prepare => [
82
- :'circle_ci:project:follow',
83
- :'circle_ci:env_vars:ensure',
84
- :'circle_ci:checkout_keys:ensure',
85
- :'circle_ci:ssh_keys:ensure',
86
- :'github:deploy_keys:ensure'
117
+ desc 'Prepare CircleCI Pipeline'
118
+ task prepare: %i[
119
+ circle_ci:project:follow
120
+ circle_ci:env_vars:ensure
121
+ circle_ci:checkout_keys:ensure
122
+ circle_ci:ssh_keys:ensure
123
+ github:deploy_keys:ensure
87
124
  ]
88
125
  end
89
126
 
90
127
  namespace :version do
91
- desc "Bump version for specified type (pre, major, minor, patch)"
128
+ desc 'Bump version for specified type (pre, major, minor, patch)'
92
129
  task :bump, [:type] do |_, args|
93
130
  bump_version_for(args.type)
94
131
  end
95
132
  end
96
133
 
97
- desc "Release gem"
134
+ desc 'Release gem'
98
135
  task :release do
99
- sh "gem release --tag --push"
136
+ sh 'gem release --tag --push'
100
137
  end
101
138
 
102
139
  def bump_version_for(version_type)
103
- sh "gem bump --version #{version_type} " +
104
- "&& bundle install " +
105
- "&& export LAST_MESSAGE=\"$(git log -1 --pretty=%B)\" " +
106
- "&& git commit -a --amend -m \"${LAST_MESSAGE} [ci skip]\""
140
+ sh "gem bump --version #{version_type} " \
141
+ '&& bundle install ' \
142
+ '&& export LAST_MESSAGE="$(git log -1 --pretty=%B)" ' \
143
+ '&& git commit -a --amend -m "${LAST_MESSAGE} [ci skip]"'
107
144
  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 "ruby_leiningen"
4
+ require 'bundler/setup'
5
+ require 'ruby_leiningen'
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 "ruby_leiningen"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  module RubyLeiningen
@@ -14,40 +16,33 @@ module RubyLeiningen
14
16
  end
15
17
 
16
18
  def stdout
17
- STDOUT
19
+ $stdout
18
20
  end
19
21
 
20
22
  def stderr
21
- STDERR
23
+ $stderr
22
24
  end
23
25
 
24
26
  def execute(opts = {})
25
- builder = instantiate_builder
26
-
27
27
  do_before(opts)
28
- configure_command(builder, opts)
29
- .build
30
- .execute(
31
- stdin: stdin,
32
- stdout: stdout,
33
- stderr: stderr)
28
+ configure_command(instantiate_builder, opts)
29
+ .build
30
+ .execute(stdin: stdin, stdout: stdout, stderr: stderr)
34
31
  do_after(opts)
35
32
  end
36
33
 
37
34
  def instantiate_builder
38
35
  Lino::CommandLineBuilder
39
- .for_command(binary)
36
+ .for_command(binary)
40
37
  end
41
38
 
42
- def do_before(opts)
43
- end
39
+ def do_before(opts); end
44
40
 
45
- def configure_command(builder, opts)
41
+ def configure_command(builder, _opts)
46
42
  builder
47
43
  end
48
44
 
49
- def do_after(opts)
50
- end
45
+ def do_after(opts); end
51
46
  end
52
47
  end
53
- end
48
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLeiningen
4
+ module Commands
5
+ module Helpers
6
+ end
7
+ end
8
+ end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RubyLeiningen
2
4
  module Commands
3
5
  module Mixins
4
6
  module Environment
5
- def initialize(opts={})
7
+ def initialize(opts = {})
6
8
  super(opts)
7
9
  @environment = opts[:environment]
8
10
  end
@@ -17,7 +19,7 @@ module RubyLeiningen
17
19
  environment = opts[:environment] || @environment
18
20
  if environment
19
21
  builder = environment.to_a
20
- .inject(builder) do |b, environment_variable|
22
+ .inject(builder) do |b, environment_variable|
21
23
  b.with_environment_variable(*environment_variable)
22
24
  end
23
25
  end
@@ -26,4 +28,4 @@ module RubyLeiningen
26
28
  end
27
29
  end
28
30
  end
29
- end
31
+ end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RubyLeiningen
2
4
  module Commands
3
5
  module Mixins
4
6
  module Profile
5
- def initialize(opts={})
7
+ def initialize(opts = {})
6
8
  super(opts)
7
9
  @profile = opts[:profile]
8
10
  end
@@ -17,12 +19,12 @@ module RubyLeiningen
17
19
  profile = opts[:profile] || @profile
18
20
  if profile
19
21
  builder = builder
20
- .with_subcommand('with-profile')
21
- .with_subcommand(profile)
22
+ .with_subcommand('with-profile')
23
+ .with_subcommand(profile)
22
24
  end
23
25
  builder
24
26
  end
25
27
  end
26
28
  end
27
29
  end
28
- end
30
+ end
@@ -1,51 +1,93 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../commands'
2
4
 
3
- RubyLeiningen::Commands.define_custom_command("bikeshed") do |config, opts|
4
- show_help = opts[:show_help]
5
- verbose = opts[:verbose]
6
- maximum_line_length = opts[:maximum_line_length]
7
- long_lines = opts[:long_lines]
8
- trailing_whitespace = opts[:trailing_whitespace]
9
- trailing_blank_lines = opts[:trailing_blank_lines]
10
- var_redefs = opts[:var_redefs]
11
- docstrings = opts[:docstrings]
12
- name_collisions = opts[:name_collisions]
13
- exclude_profiles = opts[:exclude_profiles]
14
-
15
- config.on_subcommand_builder do |command|
16
- unless show_help.nil?
17
- command = command.with_flag(show_help ? '--help-me' : '--no-help-me')
18
- end
19
- unless verbose.nil?
20
- command = command.with_flag(verbose ? '--verbose' : '--no-verbose')
21
- end
22
- if maximum_line_length
23
- command = command.with_option('--max-line-length', maximum_line_length)
24
- end
25
- unless long_lines.nil?
26
- command = command.with_option('--long-lines', long_lines)
27
- end
28
- unless trailing_whitespace.nil?
29
- command = command
30
- .with_option('--trailing-whitespace', trailing_whitespace)
31
- end
32
- unless trailing_blank_lines.nil?
33
- command = command
34
- .with_option('--trailing-blank-lines', trailing_blank_lines)
35
- end
36
- unless var_redefs.nil?
37
- command = command.with_option('--var-redefs', var_redefs)
38
- end
39
- unless docstrings.nil?
40
- command = command.with_option('--docstrings', docstrings)
41
- end
42
- unless name_collisions.nil?
43
- command = command.with_option('--name-collisions', name_collisions)
44
- end
45
- unless exclude_profiles.nil?
46
- command = command
47
- .with_option('--exclude-profiles', exclude_profiles.join(","))
5
+ module RubyLeiningen
6
+ module Commands
7
+ module Helpers
8
+ module Bikeshed
9
+ class << self
10
+ def with_show_help(command, show_help)
11
+ return command if show_help.nil?
12
+
13
+ command.with_flag(show_help ? '--help-me' : '--no-help-me')
14
+ end
15
+
16
+ def with_verbose(command, verbose)
17
+ return command if verbose.nil?
18
+
19
+ command.with_flag(verbose ? '--verbose' : '--no-verbose')
20
+ end
21
+
22
+ def with_maximum_line_length(command, maximum_line_length)
23
+ return command unless maximum_line_length
24
+
25
+ command.with_option('--max-line-length', maximum_line_length)
26
+ end
27
+
28
+ def with_long_lines(command, long_lines)
29
+ return command if long_lines.nil?
30
+
31
+ command.with_option('--long-lines', long_lines)
32
+ end
33
+
34
+ def with_trailing_whitespace(command, trailing_whitespace)
35
+ return command if trailing_whitespace.nil?
36
+
37
+ command.with_option('--trailing-whitespace', trailing_whitespace)
38
+ end
39
+
40
+ def with_trailing_blank_lines(command, trailing_blank_lines)
41
+ return command if trailing_blank_lines.nil?
42
+
43
+ command.with_option('--trailing-blank-lines', trailing_blank_lines)
44
+ end
45
+
46
+ def with_var_redefs(command, var_redefs)
47
+ return command if var_redefs.nil?
48
+
49
+ command.with_option('--var-redefs', var_redefs)
50
+ end
51
+
52
+ def with_docstrings(command, docstrings)
53
+ return command if docstrings.nil?
54
+
55
+ command.with_option('--docstrings', docstrings)
56
+ end
57
+
58
+ def with_name_collisions(command, name_collisions)
59
+ return command if name_collisions.nil?
60
+
61
+ command.with_option('--name-collisions', name_collisions)
62
+ end
63
+
64
+ def with_exclude_profiles(command, exclude_profiles)
65
+ return command if exclude_profiles.nil?
66
+
67
+ command.with_option(
68
+ '--exclude-profiles', exclude_profiles.join(',')
69
+ )
70
+ end
71
+ end
72
+ end
48
73
  end
49
- command
74
+ end
75
+ end
76
+
77
+ RubyLeiningen::Commands.define_custom_command('bikeshed') do |config, opts|
78
+ helper = RubyLeiningen::Commands::Helpers::Bikeshed
79
+
80
+ config.on_subcommand_builder do |sub|
81
+ sub = helper.with_show_help(sub, opts[:show_help])
82
+ sub = helper.with_verbose(sub, opts[:verbose])
83
+ sub = helper.with_maximum_line_length(sub, opts[:maximum_line_length])
84
+ sub = helper.with_long_lines(sub, opts[:long_lines])
85
+ sub = helper.with_trailing_whitespace(sub, opts[:trailing_whitespace])
86
+ sub = helper.with_trailing_blank_lines(sub, opts[:trailing_blank_lines])
87
+ sub = helper.with_var_redefs(sub, opts[:var_redefs])
88
+ sub = helper.with_docstrings(sub, opts[:docstrings])
89
+ sub = helper.with_name_collisions(sub, opts[:name_collisions])
90
+ sub = helper.with_exclude_profiles(sub, opts[:exclude_profiles])
91
+ sub
50
92
  end
51
93
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../commands'
2
4
 
3
- RubyLeiningen::Commands.define_custom_command("cljfmt") do |config, opts|
5
+ RubyLeiningen::Commands.define_custom_command('cljfmt') do |config, opts|
4
6
  mode = opts[:mode] || :check
5
7
  paths = opts[:paths] || []
6
8
 
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../commands'
2
4
 
3
- RubyLeiningen::Commands.define_custom_command("cljstyle") do |config, opts|
5
+ RubyLeiningen::Commands.define_custom_command('cljstyle') do |config, opts|
4
6
  mode = opts[:mode] || :check
5
7
  paths = opts[:paths] || []
6
8
 
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../commands'
2
4
 
3
- RubyLeiningen::Commands.define_custom_command("eastwood") do |config, opts|
5
+ RubyLeiningen::Commands.define_custom_command('eastwood') do |config, opts|
4
6
  config.on_command_builder do |command|
5
7
  command = command.with_argument("\"#{opts[:config]}\"") if opts[:config]
6
8
  command
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../commands'
2
4
 
3
- RubyLeiningen::Commands.define_custom_command("eftest") do |config, opts|
5
+ RubyLeiningen::Commands.define_custom_command('eftest') do |config, opts|
4
6
  only = opts[:only] ? [":only #{opts[:only]}"] : []
5
7
  specific = (opts[:test_selectors] || [])
6
- .map { |m| m.is_a?(Symbol) ? ":#{m}" : "#{m}" }
7
- all = [":all"]
8
+ .map { |m| m.is_a?(Symbol) ? ":#{m}" : m.to_s }
9
+ all = [':all']
8
10
 
9
11
  test_selectors =
10
12
  if only.any?
@@ -1,13 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../commands'
2
4
 
3
- RubyLeiningen::Commands.define_custom_command("kibit") do |config, opts|
5
+ RubyLeiningen::Commands.define_custom_command('kibit') do |config, opts|
4
6
  paths = opts[:paths] || []
5
7
 
6
8
  config.on_subcommand_builder do |command|
7
- command = command.with_flag("--replace") if opts[:replace]
8
- command = command.with_flag("--interactive") if opts[:interactive]
9
- command = command
10
- .with_option("--reporter", opts[:reporter]) if opts[:reporter]
9
+ command = command.with_flag('--replace') if opts[:replace]
10
+ command = command.with_flag('--interactive') if opts[:interactive]
11
+ if opts[:reporter]
12
+ command = command
13
+ .with_option('--reporter', opts[:reporter])
14
+ end
11
15
  command
12
16
  end
13
17
  config.on_command_builder do |subcommand|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -10,28 +12,43 @@ module RubyLeiningen
10
12
  include Mixins::Profile
11
13
  include Mixins::Environment
12
14
 
15
+ # rubocop:disable Style/RedundantAssignment
13
16
  def configure_command(builder, opts)
14
17
  builder = super(builder, opts)
15
-
16
- main_function = opts[:main_function]
17
- arguments = opts[:arguments] || []
18
- quote_arguments = opts[:quote_arguments]
19
-
20
18
  builder = builder.with_subcommand('run') do |sub|
21
- sub = sub.with_option('-m', main_function) if main_function
22
- sub = sub.with_flag('--quote-args') if quote_arguments
19
+ sub = with_main_function(sub, opts[:main_function])
20
+ sub = with_quote_arguments(sub, opts[:quote_arguments])
23
21
  sub
24
22
  end
23
+ builder = with_arguments(builder, opts[:arguments])
24
+ builder
25
+ end
26
+ # rubocop:enable Style/RedundantAssignment
27
+
28
+ private
25
29
 
30
+ def with_arguments(builder, arguments)
31
+ arguments ||= []
26
32
  if arguments.any?
27
- builder = builder.with_argument("--")
33
+ builder = builder.with_argument('--')
28
34
  builder = arguments.inject(builder) do |b, argument|
29
35
  b.with_argument(argument)
30
36
  end
31
37
  end
32
-
33
38
  builder
34
39
  end
40
+
41
+ def with_main_function(builder, main_function)
42
+ return builder unless main_function
43
+
44
+ builder.with_option('-m', main_function)
45
+ end
46
+
47
+ def with_quote_arguments(builder, quote_arguments)
48
+ return builder unless quote_arguments
49
+
50
+ builder.with_flag('--quote-args')
51
+ end
35
52
  end
36
53
  end
37
54
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -12,7 +14,7 @@ module RubyLeiningen
12
14
  @version_string
13
15
  end
14
16
 
15
- def do_before(opts)
17
+ def do_before(_opts)
16
18
  @version_string = StringIO.new
17
19
  end
18
20
 
@@ -21,7 +23,7 @@ module RubyLeiningen
21
23
  builder.with_argument('version')
22
24
  end
23
25
 
24
- def do_after(opts)
26
+ def do_after(_opts)
25
27
  @version_string.string.gsub(/\n/, '')
26
28
  end
27
29
  end
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
  require 'active_support/core_ext/string/inflections'
3
5
 
6
+ require_relative 'commands/helpers'
4
7
  require_relative 'commands/check'
5
8
  require_relative 'commands/clean'
6
9
  require_relative 'commands/deps'
@@ -14,19 +17,28 @@ module RubyLeiningen
14
17
  class << self
15
18
  def define_custom_command(name, options = {}, &config_block)
16
19
  klass_name = name.classify
20
+ klass = define_command_class(name, options, &config_block)
21
+ const_set(klass_name, klass)
17
22
 
18
- klass = Class.new(Base) do
23
+ return if options[:skip_singleton_method]
24
+
25
+ RubyLeiningen.define_singleton_method name do |opts = {}|
26
+ klass.new.execute(opts)
27
+ end
28
+ end
29
+
30
+ # rubocop:disable Metrics/MethodLength
31
+ def define_command_class(name, options, &config_block)
32
+ Class.new(Base) do
19
33
  unless options[:include_profile_support] == false
20
34
  include Mixins::Profile
21
35
  end
22
36
  unless options[:include_environment_support] == false
23
37
  include Mixins::Environment
24
38
  end
25
-
26
- define_method "configure_command" do |builder, opts|
27
- config = (config_block || lambda { |conf, _| conf })
28
- .call(Config.new, opts)
29
-
39
+ define_method 'configure_command' do |builder, opts|
40
+ config = (config_block || ->(conf, _) { conf })
41
+ .call(Config.new, opts)
30
42
  builder = super(builder, opts)
31
43
  builder = builder.with_subcommand(name) do |sub|
32
44
  config.subcommand_block.call(sub)
@@ -34,25 +46,16 @@ module RubyLeiningen
34
46
  config.command_block.call(builder)
35
47
  end
36
48
  end
37
-
38
- const_set(klass_name, klass)
39
-
40
- unless options[:skip_singleton_method]
41
- RubyLeiningen.define_singleton_method name do |opts = {}|
42
- klass.new.execute(opts)
43
- end
44
- end
45
49
  end
50
+ # rubocop:enable Metrics/MethodLength
46
51
  end
47
52
 
48
- private
49
-
50
53
  class Config
51
54
  attr_accessor :command_block, :subcommand_block
52
55
 
53
56
  def initialize
54
- self.command_block = lambda { |command| command }
55
- self.subcommand_block = lambda { |sub| sub }
57
+ self.command_block = ->(command) { command }
58
+ self.subcommand_block = ->(sub) { sub }
56
59
  end
57
60
 
58
61
  def on_command_builder(&block)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'commands'
2
4
 
3
5
  require_relative 'commands/plugins/bikeshed'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RubyLeiningen
2
- VERSION = '0.24.0.pre.6'
4
+ VERSION = '0.24.0.pre.7'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ruby_leiningen/version'
2
4
  require 'ruby_leiningen/commands'
3
5
 
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'ruby_leiningen/version'
6
+
7
+ files = %w[
8
+ bin
9
+ lib
10
+ CODE_OF_CONDUCT.md
11
+ ruby_leiningen.gemspec
12
+ Gemfile
13
+ LICENSE.txt
14
+ Rakefile
15
+ README.md
16
+ ]
17
+
18
+ Gem::Specification.new do |spec|
19
+ spec.name = 'ruby_leiningen'
20
+ spec.version = RubyLeiningen::VERSION
21
+ spec.authors = ['InfraBlocks Maintainers']
22
+ spec.email = ['maintainers@infrablocks.io']
23
+
24
+ spec.summary = 'A simple Ruby wrapper for invoking leiningen commands.'
25
+ spec.description = 'Wraps the leiningen CLI so that leiningen can be ' \
26
+ 'invoked from a Ruby script or Rakefile.'
27
+ spec.homepage = 'https://github.com/infrablocks/ruby_leiningen'
28
+ spec.license = 'MIT'
29
+
30
+ spec.files = `git ls-files -z`.split("\x0").select do |f|
31
+ f.match(/^(#{files.map { |g| Regexp.escape(g) }.join('|')})/)
32
+ end
33
+ spec.bindir = 'exe'
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ['lib']
36
+
37
+ spec.required_ruby_version = '>= 2.7'
38
+
39
+ spec.add_dependency 'activesupport', '>= 6.0.2', '< 8'
40
+ spec.add_dependency 'lino', '~> 3.0'
41
+
42
+ spec.add_development_dependency 'bundler'
43
+ spec.add_development_dependency 'gem-release'
44
+ spec.add_development_dependency 'rake'
45
+ spec.add_development_dependency 'rake_circle_ci'
46
+ spec.add_development_dependency 'rake_github'
47
+ spec.add_development_dependency 'rake_gpg'
48
+ spec.add_development_dependency 'rake_ssh'
49
+ spec.add_development_dependency 'rspec'
50
+ spec.add_development_dependency 'rubocop'
51
+ spec.add_development_dependency 'rubocop-rake'
52
+ spec.add_development_dependency 'rubocop-rspec'
53
+ spec.add_development_dependency 'simplecov'
54
+
55
+ spec.metadata['rubygems_mfa_required'] = 'false'
56
+ end
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_leiningen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0.pre.6
4
+ version: 0.24.0.pre.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-21 00:00:00.000000000 Z
11
+ date: 2022-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.2
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 6.0.2
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8'
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: lino
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -25,27 +45,21 @@ dependencies:
25
45
  - !ruby/object:Gem::Version
26
46
  version: '3.0'
27
47
  - !ruby/object:Gem::Dependency
28
- name: activesupport
48
+ name: bundler
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
51
  - - ">="
32
52
  - !ruby/object:Gem::Version
33
- version: 6.0.2
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '8'
37
- type: :runtime
53
+ version: '0'
54
+ type: :development
38
55
  prerelease: false
39
56
  version_requirements: !ruby/object:Gem::Requirement
40
57
  requirements:
41
58
  - - ">="
42
59
  - !ruby/object:Gem::Version
43
- version: 6.0.2
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '8'
60
+ version: '0'
47
61
  - !ruby/object:Gem::Dependency
48
- name: bundler
62
+ name: gem-release
49
63
  requirement: !ruby/object:Gem::Requirement
50
64
  requirements:
51
65
  - - ">="
@@ -101,7 +115,7 @@ dependencies:
101
115
  - !ruby/object:Gem::Version
102
116
  version: '0'
103
117
  - !ruby/object:Gem::Dependency
104
- name: rake_ssh
118
+ name: rake_gpg
105
119
  requirement: !ruby/object:Gem::Requirement
106
120
  requirements:
107
121
  - - ">="
@@ -115,7 +129,7 @@ dependencies:
115
129
  - !ruby/object:Gem::Version
116
130
  version: '0'
117
131
  - !ruby/object:Gem::Dependency
118
- name: rake_gpg
132
+ name: rake_ssh
119
133
  requirement: !ruby/object:Gem::Requirement
120
134
  requirements:
121
135
  - - ">="
@@ -143,7 +157,49 @@ dependencies:
143
157
  - !ruby/object:Gem::Version
144
158
  version: '0'
145
159
  - !ruby/object:Gem::Dependency
146
- name: gem-release
160
+ name: rubocop
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ - !ruby/object:Gem::Dependency
174
+ name: rubocop-rake
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ - !ruby/object:Gem::Dependency
188
+ name: rubocop-rspec
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ - !ruby/object:Gem::Dependency
202
+ name: simplecov
147
203
  requirement: !ruby/object:Gem::Requirement
148
204
  requirements:
149
205
  - - ">="
@@ -178,6 +234,7 @@ files:
178
234
  - lib/ruby_leiningen/commands/check.rb
179
235
  - lib/ruby_leiningen/commands/clean.rb
180
236
  - lib/ruby_leiningen/commands/deps.rb
237
+ - lib/ruby_leiningen/commands/helpers.rb
181
238
  - lib/ruby_leiningen/commands/mixins/environment.rb
182
239
  - lib/ruby_leiningen/commands/mixins/profile.rb
183
240
  - lib/ruby_leiningen/commands/plugins/bikeshed.rb
@@ -192,10 +249,12 @@ files:
192
249
  - lib/ruby_leiningen/commands/version.rb
193
250
  - lib/ruby_leiningen/plugins.rb
194
251
  - lib/ruby_leiningen/version.rb
252
+ - ruby_leiningen.gemspec
195
253
  homepage: https://github.com/infrablocks/ruby_leiningen
196
254
  licenses:
197
255
  - MIT
198
- metadata: {}
256
+ metadata:
257
+ rubygems_mfa_required: 'false'
199
258
  post_install_message:
200
259
  rdoc_options: []
201
260
  require_paths: