lino 1.9.0 → 1.10.0.pre.1

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: 2c5b311ecc9ed33d7222eec9275914b3840b78eb8a50adc6cceede54a7583e72
4
- data.tar.gz: 82d9b820187201cddb543cb120ba288cd00d6605dcf1dc29939e4f566cdb1cac
3
+ metadata.gz: 6b2d97cd89debbd53f7eae071f39fd98568652e7771957c1e6584ca3756edc76
4
+ data.tar.gz: d1e6e64522855b0b0ac7dab0f7d309d4bf79a894bac43690fa965dbc94e4ce02
5
5
  SHA512:
6
- metadata.gz: a88c15ab1e68b60a9e4c2ff7fc8201a50955789fd9b608b484d1ed70036ebe71d65727d5af7f306e496b797f73c84e195347c9960eaf549d412dd27075f9ac5d
7
- data.tar.gz: 775f44d3d5966a0befd993345e48f60474f0867ef42f51865e66361750b1ada4325c137524d49ce64d002a2042f211fe92511bb464d1b355aacaa6b727ef5ee3
6
+ metadata.gz: 85f9539da48b728c57ff7725650d5a6fb16c41e401b6313a7bc6dfcfa91747617c21f8732e6b516d4b8f3dd28c21fa96a478b6977b431214d03e335dee3e49b0
7
+ data.tar.gz: 73ec86a9cfbabc102ee71d83c954541724eaf7454731568e9c00d7f50691e0726a39332a696a3df49f05feedfae72281ed1d79ead14929f88a60c4207b5ba26d
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify dependencies in lino.gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lino (1.9.0)
4
+ lino (1.10.0.pre.1)
5
5
  hamster (~> 3.0)
6
6
  open4 (~> 1.3)
7
7
 
@@ -16,6 +16,7 @@ GEM
16
16
  zeitwerk (~> 2.3)
17
17
  addressable (2.7.0)
18
18
  public_suffix (>= 2.0.2, < 5.0)
19
+ ast (2.4.2)
19
20
  colored2 (3.1.2)
20
21
  concurrent-ruby (1.1.7)
21
22
  diff-lcs (1.4.4)
@@ -37,7 +38,11 @@ GEM
37
38
  faraday (>= 0.9)
38
39
  sawyer (~> 0.8.0, >= 0.5.3)
39
40
  open4 (1.3.4)
41
+ parallel (1.20.1)
42
+ parser (3.0.0.0)
43
+ ast (~> 2.4.1)
40
44
  public_suffix (4.0.6)
45
+ rainbow (3.0.0)
41
46
  rake (13.0.3)
42
47
  rake_circle_ci (0.9.0)
43
48
  colored2 (~> 3.1)
@@ -59,6 +64,8 @@ GEM
59
64
  colored2 (~> 3.1)
60
65
  rake_factory (~> 0.23)
61
66
  sshkey (~> 2.0)
67
+ regexp_parser (2.1.1)
68
+ rexml (3.2.4)
62
69
  rspec (3.10.0)
63
70
  rspec-core (~> 3.10.0)
64
71
  rspec-expectations (~> 3.10.0)
@@ -72,6 +79,23 @@ GEM
72
79
  diff-lcs (>= 1.2.0, < 2.0)
73
80
  rspec-support (~> 3.10.0)
74
81
  rspec-support (3.10.1)
82
+ rubocop (1.12.0)
83
+ parallel (~> 1.10)
84
+ parser (>= 3.0.0.0)
85
+ rainbow (>= 2.2.2, < 4.0)
86
+ regexp_parser (>= 1.8, < 3.0)
87
+ rexml
88
+ rubocop-ast (>= 1.2.0, < 2.0)
89
+ ruby-progressbar (~> 1.7)
90
+ unicode-display_width (>= 1.4.0, < 3.0)
91
+ rubocop-ast (1.4.1)
92
+ parser (>= 2.7.1.5)
93
+ rubocop-rake (0.5.1)
94
+ rubocop
95
+ rubocop-rspec (2.2.0)
96
+ rubocop (~> 1.0)
97
+ rubocop-ast (>= 1.1.0)
98
+ ruby-progressbar (1.11.0)
75
99
  ruby2_keywords (0.0.2)
76
100
  ruby_gpg2 (0.6.0)
77
101
  lino (>= 1.5)
@@ -87,6 +111,7 @@ GEM
87
111
  sshkey (2.0.0)
88
112
  tzinfo (2.0.4)
89
113
  concurrent-ruby (~> 1.0)
114
+ unicode-display_width (2.0.0)
90
115
  zeitwerk (2.4.2)
91
116
 
92
117
  PLATFORMS
@@ -102,6 +127,9 @@ DEPENDENCIES
102
127
  rake_gpg (~> 0.12)
103
128
  rake_ssh (~> 0.4)
104
129
  rspec (~> 3.9)
130
+ rubocop (~> 1.12)
131
+ rubocop-rake (~> 0.5)
132
+ rubocop-rspec (~> 2.2)
105
133
  simplecov (~> 0.16)
106
134
 
107
135
  BUNDLED WITH
data/README.md CHANGED
@@ -183,7 +183,7 @@ To install dependencies and run the build, run the pre-commit build:
183
183
  ./go
184
184
  ```
185
185
 
186
- Tou can also run only the specs:
186
+ To run only the specs:
187
187
 
188
188
  ```shell script
189
189
  ./go spec
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,10 +7,12 @@ 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
14
18
  namespace :passphrase do
@@ -23,83 +27,99 @@ end
23
27
  namespace :keys do
24
28
  namespace :deploy do
25
29
  RakeSSH.define_key_tasks(
26
- path: 'config/secrets/ci/',
27
- comment: 'maintainers@infrablocks.io')
30
+ path: 'config/secrets/ci/',
31
+ comment: 'maintainers@infrablocks.io'
32
+ )
28
33
  end
29
34
 
30
35
  namespace :gpg do
31
36
  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: 'lino CI Key')
37
+ output_directory: 'config/secrets/ci',
38
+ name_prefix: 'gpg',
39
+ owner_name: 'InfraBlocks Maintainers',
40
+ owner_email: 'maintainers@infrablocks.io',
41
+ owner_comment: 'lino CI Key'
42
+ )
37
43
  end
38
44
  end
39
45
 
46
+ RuboCop::RakeTask.new
47
+
48
+ namespace :library do
49
+ desc 'Run all checks of the library'
50
+ task check: [:rubocop]
51
+
52
+ desc 'Attempt to automatically fix issues with the library'
53
+ task fix: [:'rubocop:auto_correct']
54
+ end
55
+
56
+ namespace :test do
57
+ RSpec::Core::RakeTask.new(:unit)
58
+ end
59
+
40
60
  RakeCircleCI.define_project_tasks(
41
- namespace: :circle_ci,
42
- project_slug: 'github/infrablocks/lino'
61
+ namespace: :circle_ci,
62
+ project_slug: 'github/infrablocks/lino'
43
63
  ) do |t|
44
64
  circle_ci_config =
45
- YAML.load_file('config/secrets/circle_ci/config.yaml')
65
+ YAML.load_file('config/secrets/circle_ci/config.yaml')
46
66
 
47
- t.api_token = circle_ci_config["circle_ci_api_token"]
67
+ t.api_token = circle_ci_config['circle_ci_api_token']
48
68
  t.environment_variables = {
49
- ENCRYPTION_PASSPHRASE:
50
- File.read('config/secrets/ci/encryption.passphrase')
51
- .chomp
69
+ ENCRYPTION_PASSPHRASE:
70
+ File.read('config/secrets/ci/encryption.passphrase')
71
+ .chomp
52
72
  }
53
73
  t.checkout_keys = []
54
74
  t.ssh_keys = [
55
- {
56
- hostname: "github.com",
57
- private_key: File.read('config/secrets/ci/ssh.private')
58
- }
75
+ {
76
+ hostname: 'github.com',
77
+ private_key: File.read('config/secrets/ci/ssh.private')
78
+ }
59
79
  ]
60
80
  end
61
81
 
62
82
  RakeGithub.define_repository_tasks(
63
- namespace: :github,
64
- repository: 'infrablocks/lino',
83
+ namespace: :github,
84
+ repository: 'infrablocks/lino'
65
85
  ) do |t|
66
86
  github_config =
67
- YAML.load_file('config/secrets/github/config.yaml')
87
+ YAML.load_file('config/secrets/github/config.yaml')
68
88
 
69
- t.access_token = github_config["github_personal_access_token"]
89
+ t.access_token = github_config['github_personal_access_token']
70
90
  t.deploy_keys = [
71
- {
72
- title: 'CircleCI',
73
- public_key: File.read('config/secrets/ci/ssh.public')
74
- }
91
+ {
92
+ title: 'CircleCI',
93
+ public_key: File.read('config/secrets/ci/ssh.public')
94
+ }
75
95
  ]
76
96
  end
77
97
 
78
98
  namespace :pipeline do
79
- task :prepare => [
80
- :'circle_ci:project:follow',
81
- :'circle_ci:env_vars:ensure',
82
- :'circle_ci:checkout_keys:ensure',
83
- :'circle_ci:ssh_keys:ensure',
84
- :'github:deploy_keys:ensure'
99
+ task prepare: %i[
100
+ circle_ci:project:follow
101
+ circle_ci:env_vars:ensure
102
+ circle_ci:checkout_keys:ensure
103
+ circle_ci:ssh_keys:ensure
104
+ github:deploy_keys:ensure
85
105
  ]
86
106
  end
87
107
 
88
108
  namespace :version do
89
- desc "Bump version for specified type (pre, major, minor, patch)"
109
+ desc 'Bump version for specified type (pre, major, minor, patch)'
90
110
  task :bump, [:type] do |_, args|
91
111
  bump_version_for(args.type)
92
112
  end
93
113
  end
94
114
 
95
- desc "Release gem"
115
+ desc 'Release gem'
96
116
  task :release do
97
- sh "gem release --tag --push"
117
+ sh 'gem release --tag --push'
98
118
  end
99
119
 
100
120
  def bump_version_for(version_type)
101
- sh "gem bump --version #{version_type} " +
102
- "&& bundle install " +
103
- "&& export LAST_MESSAGE=\"$(git log -1 --pretty=%B)\" " +
104
- "&& git commit -a --amend -m \"${LAST_MESSAGE} [ci skip]\""
121
+ sh "gem bump --version #{version_type} " \
122
+ '&& bundle install ' \
123
+ '&& export LAST_MESSAGE="$(git log -1 --pretty=%B)" ' \
124
+ '&& git commit -a --amend -m "${LAST_MESSAGE} [ci skip]"'
105
125
  end
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'lino'
data/lib/lino.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino/version'
2
4
  require 'lino/command_line'
3
5
  require 'lino/command_line_builder'
@@ -1,24 +1,28 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'open4'
2
4
 
3
5
  module Lino
4
6
  class CommandLine
5
- def initialize command_line
7
+ def initialize(command_line)
6
8
  @command_line = command_line
7
9
  end
8
10
 
9
11
  def execute(
10
- stdin: '',
11
- stdout: STDOUT,
12
- stderr: STDERR)
13
- Open4::spawn(
14
- @command_line,
15
- stdin: stdin,
16
- stdout: stdout,
17
- stderr: stderr)
12
+ stdin: '',
13
+ stdout: $stdout,
14
+ stderr: $stderr
15
+ )
16
+ Open4.spawn(
17
+ @command_line,
18
+ stdin: stdin,
19
+ stdout: stdout,
20
+ stderr: stderr
21
+ )
18
22
  end
19
23
 
20
24
  def to_s
21
25
  @command_line
22
26
  end
23
27
  end
24
- end
28
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'hamster'
2
4
  require_relative 'utilities'
3
5
  require_relative 'command_line'
@@ -5,16 +7,18 @@ require_relative 'subcommand_builder'
5
7
  require_relative 'switches'
6
8
 
7
9
  module Lino
10
+ # rubocop:disable Metrics/ClassLength
8
11
  class CommandLineBuilder
9
12
  include Lino::Utilities
10
13
  include Lino::Switches
11
14
 
12
- class <<self
15
+ class << self
13
16
  def for_command(command)
14
17
  CommandLineBuilder.new(command: command)
15
18
  end
16
19
  end
17
20
 
21
+ # rubocop:disable Metrics/ParameterLists
18
22
  def initialize(
19
23
  command: nil,
20
24
  subcommands: [],
@@ -32,6 +36,7 @@ module Lino
32
36
  @option_separator = option_separator
33
37
  @option_quoting = option_quoting
34
38
  end
39
+ # rubocop:enable Metrics/ParameterLists
35
40
 
36
41
  def with_subcommand(subcommand, &block)
37
42
  with(
@@ -61,23 +66,23 @@ module Lino
61
66
  end
62
67
 
63
68
  def with_environment_variable(environment_variable, value)
64
- with(environment_variables: @environment_variables.add([environment_variable, value]))
69
+ with(
70
+ environment_variables:
71
+ @environment_variables.add(
72
+ [
73
+ environment_variable, value
74
+ ]
75
+ )
76
+ )
65
77
  end
66
78
 
67
79
  def build
68
80
  components = [
69
- map_and_join(@environment_variables) do |var|
70
- "#{var[0]}=\"#{var[1].to_s.gsub(/"/, '\\"')}\""
71
- end,
81
+ formatted_environment_variables,
72
82
  @command,
73
- map_and_join(
74
- @switches,
75
- &(quote_with(@option_quoting) >> join_with(@option_separator))
76
- ),
77
- map_and_join(@subcommands) do |sub|
78
- sub.build(@option_separator, @option_quoting)
79
- end,
80
- map_and_join(@arguments, &join_with(' '))
83
+ formatted_switches,
84
+ formatted_subcommands,
85
+ formatted_arguments
81
86
  ]
82
87
 
83
88
  command_string = components.reject(&:empty?).join(' ')
@@ -87,6 +92,29 @@ module Lino
87
92
 
88
93
  private
89
94
 
95
+ def formatted_environment_variables
96
+ map_and_join(@environment_variables) do |var|
97
+ "#{var[0]}=\"#{var[1].to_s.gsub(/"/, '\\"')}\""
98
+ end
99
+ end
100
+
101
+ def formatted_switches
102
+ map_and_join(
103
+ @switches,
104
+ &(quote_with(@option_quoting) >> join_with(@option_separator))
105
+ )
106
+ end
107
+
108
+ def formatted_subcommands
109
+ map_and_join(@subcommands) do |sub|
110
+ sub.build(@option_separator, @option_quoting)
111
+ end
112
+ end
113
+
114
+ def formatted_arguments
115
+ map_and_join(@arguments, &join_with(' '))
116
+ end
117
+
90
118
  def with(**replacements)
91
119
  CommandLineBuilder.new(**state.merge(replacements))
92
120
  end
@@ -109,4 +137,5 @@ module Lino
109
137
  @arguments = @arguments.add({ components: [argument] })
110
138
  end
111
139
  end
140
+ # rubocop:enable Metrics/ClassLength
112
141
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'hamster'
2
4
  require_relative 'utilities'
3
5
  require_relative 'switches'
data/lib/lino/switches.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Lino
2
4
  module Switches
3
5
  def with_option(switch, value, separator: nil, quoting: nil)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pp'
2
4
 
3
5
  module Lino
@@ -14,20 +16,30 @@ module Lino
14
16
 
15
17
  def quote_with(global_character)
16
18
  lambda do |item|
17
- character = item[:quoting] || global_character
18
- components = item[:components]
19
- switch = components[0]
20
- value = components[1]
21
-
22
19
  item.merge(
23
- components: (components.count > 1) ?
24
- [switch, "#{character}#{value}#{character}"] :
25
- components)
20
+ components: resolve_components(item, global_character)
21
+ )
26
22
  end
27
23
  end
28
24
 
29
25
  def missing?(value)
30
26
  value.nil? || (value.respond_to?(:empty?) && value.empty?)
31
27
  end
28
+
29
+ private
30
+
31
+ def resolve_components(item, global_character)
32
+ components = item[:components]
33
+ switch = components[0]
34
+
35
+ if components.count > 1
36
+ character = item[:quoting] || global_character
37
+ value = components[1]
38
+
39
+ [switch, "#{character}#{value}#{character}"]
40
+ else
41
+ components
42
+ end
43
+ end
32
44
  end
33
- end
45
+ end
data/lib/lino/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Lino
2
- VERSION = '1.9.0'
4
+ VERSION = '1.10.0.pre.1'
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lino
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-30 00:00:00.000000000 Z
11
+ date: 2021-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hamster
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: gem-release
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -95,33 +109,33 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0.5'
97
111
  - !ruby/object:Gem::Dependency
98
- name: rake_ssh
112
+ name: rake_gpg
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '0.4'
117
+ version: '0.12'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '0.4'
124
+ version: '0.12'
111
125
  - !ruby/object:Gem::Dependency
112
- name: rake_gpg
126
+ name: rake_ssh
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: '0.12'
131
+ version: '0.4'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: '0.12'
138
+ version: '0.4'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rspec
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -137,19 +151,47 @@ dependencies:
137
151
  - !ruby/object:Gem::Version
138
152
  version: '3.9'
139
153
  - !ruby/object:Gem::Dependency
140
- name: gem-release
154
+ name: rubocop
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: '2.0'
159
+ version: '1.12'
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: '2.0'
166
+ version: '1.12'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop-rake
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.5'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.5'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop-rspec
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '2.2'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '2.2'
153
195
  - !ruby/object:Gem::Dependency
154
196
  name: simplecov
155
197
  requirement: !ruby/object:Gem::Requirement
@@ -201,9 +243,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
243
  version: '2.6'
202
244
  required_rubygems_version: !ruby/object:Gem::Requirement
203
245
  requirements:
204
- - - ">="
246
+ - - ">"
205
247
  - !ruby/object:Gem::Version
206
- version: '0'
248
+ version: 1.3.1
207
249
  requirements: []
208
250
  rubygems_version: 3.0.1
209
251
  signing_key: