remote_ruby 0.1.3 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4ca4ae0f79adc6808a812e4e602e6f494ea18cf6
4
- data.tar.gz: 5f2c4d145537c60a31d7993ba1460d90804edf76
2
+ SHA256:
3
+ metadata.gz: 3cedd66138541336a6fbb5518c94c1b8bae4baa005f8326bb08958c5e87f669e
4
+ data.tar.gz: d93ac29bf86d2cb44c94fb6c9dcea8cfb82fa5d7a24bcfa2d831077a8b26f6f9
5
5
  SHA512:
6
- metadata.gz: 19fefa7fa66cfb83d57985c048ca73201c62c86149dcda365333349da2d452ba722ca662a78b9f3e7873f8e45219f0ae40a236585673f022fcdda6fd2a8e8f3f
7
- data.tar.gz: aae7df487861b0cc0185e2df02c767ccd9e980a158aeeaf73c01edd909b5801bc213a414c1073b10e3fe58cd0a7d8e85d30d14b0089621f4c7849ef5e7eac7bb
6
+ metadata.gz: d7ad4224cfcb7e1659c72b4022be4f2b50b08be8e2e7339bef855a46c04d9b5a40fd9ff929a2576c4bea69026b51e375ede8155a8816fd96f30e0fa9bcf0cd5f
7
+ data.tar.gz: 99177a9d0e62197a65f986be84154f26bb7be6b32a9538af515614ffe3f1575770ad7b836cd0fdd0b19f9c3e6383e34fe4b53c10c4adc0c4ca073d405ec74db9
@@ -0,0 +1,28 @@
1
+ name: "Lint & Test"
2
+ on: [push, pull_request]
3
+ jobs:
4
+ rubocop:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v2
8
+ - uses: ruby/setup-ruby@v1
9
+ with:
10
+ ruby-version: 3.0.2
11
+ bundler-cache: true
12
+ - run: bundle exec rubocop
13
+ rspec:
14
+ strategy:
15
+ matrix:
16
+ os: [ubuntu-latest, macos-latest]
17
+ ruby: [2.6, 2.7, '3.0', head]
18
+ runs-on: ${{ matrix.os }}
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ bundler-cache: true
25
+ - run: bundle exec rspec
26
+
27
+
28
+
data/.rubocop.yml CHANGED
@@ -1,3 +1,12 @@
1
+ AllCops:
2
+ NewCops: enable
3
+
1
4
  Metrics/BlockLength:
2
- ExcludedMethods: ['describe', 'context', 'shared_context']
5
+ IgnoredMethods: ['describe', 'context', 'shared_context']
6
+
7
+ Style/GlobalStdStream:
8
+ Exclude:
9
+ - spec/remote_ruby/connection_adapter/eval_adapter_spec.rb
3
10
 
11
+ Style/DocumentDynamicEvalDefinition:
12
+ Enabled: false
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
@@ -5,16 +7,16 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
5
7
  gemspec
6
8
 
7
9
  group :development do
8
- gem 'rubocop'
9
- gem 'yard'
10
+ gem 'rubocop', '~> 1.23'
11
+ gem 'yard', '~> 0.9'
10
12
  end
11
13
 
12
14
  group :development, :test do
13
- gem 'byebug', '>= 8.0'
14
- gem 'pry-byebug'
15
- gem 'rspec', '~> 3.0'
15
+ gem 'byebug', '~> 11.1'
16
+ gem 'pry-byebug', '~> 3.9'
17
+ gem 'rspec', '~> 3.10'
16
18
  end
17
19
 
18
20
  group :test do
19
- gem 'coveralls', require: false
21
+ gem 'coveralls', '~> 0.8', require: false
20
22
  end
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Nikita Chernukhin
3
+ Copyright (c) 2021 Nikita Chernukhin
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # remote_ruby
2
-
3
- [![Build Status](https://travis-ci.org/Nu-hin/remote_ruby.svg?branch=master)](https://travis-ci.org/Nu-hin/remote_ruby)
2
+ ![Lint & Test](https://github.com/nu-hin/remote_ruby/actions/workflows/main.yml/badge.svg)
4
3
  [![Coverage Status](https://coveralls.io/repos/github/Nu-hin/remote_ruby/badge.svg?branch=master)](https://coveralls.io/github/Nu-hin/remote_ruby?branch=master)
5
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/e57430aa6f626aeca41d/maintainability)](https://codeclimate.com/github/Nu-hin/remote_ruby/maintainability)
6
5
  [![Gem Version](https://badge.fury.io/rb/remote_ruby.svg)](https://badge.fury.io/rb/remote_ruby)
@@ -8,6 +7,7 @@
8
7
  RemoteRuby allows you to execute Ruby code on remote servers via SSH right from the Ruby script running on your local machine, as if it was executed locally.
9
8
 
10
9
  ## Contents
10
+ * [Requirements](#requirements)
11
11
  * [Overview](#overview)
12
12
  * [How it works](#how-it-works)
13
13
  * [Key features](#key-features)
@@ -27,6 +27,10 @@ RemoteRuby allows you to execute Ruby code on remote servers via SSH right from
27
27
  * [Contributing](#contributing)
28
28
  * [License](#license)
29
29
 
30
+ ## Requirements
31
+
32
+ RemoteRuby requires at least Ruby 2.6 to run.
33
+
30
34
  ## Overview
31
35
 
32
36
  Here is a short example on how you can run your code remotely.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'base64'
2
4
  require 'digest'
3
5
  require 'erb'
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RemoteRuby
2
4
  # An adapter which takes stdout and stderr from files and ignores
3
5
  # all stdin. Only used to read from cache.
4
6
  class CacheAdapter < ConnectionAdapter
5
7
  def initialize(connection_name:, cache_path:)
8
+ super
6
9
  @cache_path = cache_path
7
10
  @connection_name = connection_name
8
11
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'remote_ruby/stream_cacher'
2
4
 
3
5
  module RemoteRuby
@@ -5,6 +7,7 @@ module RemoteRuby
5
7
  # initializer to cache stdout and stderr to local filesystem
6
8
  class CachingAdapter < ConnectionAdapter
7
9
  def initialize(cache_path:, adapter:)
10
+ super
8
11
  @cache_path = cache_path
9
12
  @adapter = adapter
10
13
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RemoteRuby
2
4
  # An adapter to expecute Ruby code in the current process in an isolated
3
5
  # scope
@@ -5,6 +7,7 @@ module RemoteRuby
5
7
  attr_reader :async, :working_dir
6
8
 
7
9
  def initialize(working_dir: Dir.pwd, async: false)
10
+ super
8
11
  @async = async
9
12
  @working_dir = working_dir
10
13
  end
@@ -13,15 +16,11 @@ module RemoteRuby
13
16
  ''
14
17
  end
15
18
 
16
- def open(code)
19
+ def open(code, &block)
17
20
  if async
18
- run_async(code) do |out, err|
19
- yield out, err
20
- end
21
+ run_async(code, &block)
21
22
  else
22
- run_sync(code) do |out, err|
23
- yield out, err
24
- end
23
+ run_sync(code, &block)
25
24
  end
26
25
  end
27
26
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RemoteRuby
2
4
  # An adapter to expecute Ruby code on the local macine
3
5
  # inside a specified directory
@@ -5,6 +7,7 @@ module RemoteRuby
5
7
  attr_reader :working_dir
6
8
 
7
9
  def initialize(working_dir: '.')
10
+ super
8
11
  @working_dir = working_dir
9
12
  end
10
13
 
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RemoteRuby
2
4
  # An adapter to execute Ruby code on the remote server via SSH
3
5
  class SSHStdinAdapter < StdinProcessAdapter
4
6
  attr_reader :server, :working_dir, :user, :key_file
5
7
 
6
8
  def initialize(server:, working_dir: '~', user: nil, key_file: nil)
9
+ super
7
10
  @working_dir = working_dir
8
11
  @server = user.nil? ? server : "#{user}@#{server}"
9
12
  @user = user
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'open3'
2
4
 
3
5
  module RemoteRuby
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RemoteRuby
2
4
  # Base class for other connection adapters.
3
5
  class ConnectionAdapter
@@ -20,7 +22,7 @@ module RemoteRuby
20
22
  end
21
23
  end
22
24
 
23
- require 'remote_ruby/connection_adapter/eval_adapter.rb'
25
+ require 'remote_ruby/connection_adapter/eval_adapter'
24
26
  require 'remote_ruby/connection_adapter/stdin_process_adapter'
25
27
  require 'remote_ruby/connection_adapter/ssh_stdin_adapter'
26
28
  require 'remote_ruby/connection_adapter/local_stdin_adapter'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'digest'
2
4
  require 'fileutils'
3
5
 
@@ -12,7 +14,6 @@ module RemoteRuby
12
14
  # This class is responsible for executing blocks on the remote host with the
13
15
  # specified adapters. This is the entrypoint to RemoteRuby logic.
14
16
  class ExecutionContext
15
- # rubocop:disable Metrics/CyclomaticComplexity
16
17
  def initialize(**params)
17
18
  add_flavours(params)
18
19
  @use_cache = params.delete(:use_cache) || false
@@ -25,7 +26,6 @@ module RemoteRuby
25
26
 
26
27
  FileUtils.mkdir_p(@cache_dir)
27
28
  end
28
- # rubocop:enable Metrics/CyclomaticComplexity
29
29
 
30
30
  def execute(locals = nil, &block)
31
31
  source = code_source(block)
@@ -103,7 +103,7 @@ module RemoteRuby
103
103
  end
104
104
 
105
105
  def adapter(code_hash)
106
- actual_adapter = adapter_klass.new(params)
106
+ actual_adapter = adapter_klass.new(**params)
107
107
 
108
108
  if use_cache && cache_exists?(code_hash)
109
109
  cache_adapter(actual_adapter, code_hash)
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RemoteRuby
2
4
  # Flavour to load Rails environment
3
5
  class RailsFlavour < ::RemoteRuby::Flavour
4
6
  def initialize(environment: :development)
7
+ super
5
8
  @environment = environment
6
9
  end
7
10
 
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RemoteRuby
2
4
  # Base class for Flavours: addons to execution context to insert additonal
3
5
  # code to the generated remote code.
4
6
  class Flavour
5
- def self.build_flavours(params = {})
7
+ def self.build_flavours(args = {})
6
8
  res = []
7
9
 
8
10
  {
9
11
  rails: RemoteRuby::RailsFlavour
10
12
  }.each do |name, klass|
11
- options = params.delete(name)
13
+ options = args.delete(name)
12
14
 
13
15
  res << klass.new(**options) if options
14
16
  end
@@ -16,7 +18,7 @@ module RemoteRuby
16
18
  res
17
19
  end
18
20
 
19
- def initialize(params: {}); end
21
+ def initialize(**args); end
20
22
 
21
23
  def code_header; end
22
24
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RemoteRuby
2
4
  # Extracts local variable from given context
3
5
  class LocalsExtractor
@@ -11,7 +13,7 @@ module RemoteRuby
11
13
  def locals
12
14
  locals = {}
13
15
 
14
- local_variable_names.each do |name|
16
+ block.binding.local_variables.each do |name|
15
17
  value = block.binding.eval(name.to_s)
16
18
  next if ignored_type?(value)
17
19
 
@@ -23,18 +25,6 @@ module RemoteRuby
23
25
 
24
26
  private
25
27
 
26
- def local_variable_names
27
- if RUBY_VERSION >= '2.2'
28
- block.binding.local_variables
29
- else
30
- # A hack to support Ruby 2.1 due to the absence
31
- # of Binding#local_variables method. For some reason
32
- # just calling `block.binding.send(:local_variables)`
33
- # returns variables of the current context.
34
- block.binding.eval('binding.send(:local_variables)')
35
- end
36
- end
37
-
38
28
  def ignored_type?(var)
39
29
  ignore_types.any? { |klass| var.is_a? klass }
40
30
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'colorize'
2
4
 
3
5
  require 'remote_ruby/unmarshaler'
@@ -1,7 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'method_source'
2
4
  require 'parser/current'
3
5
  require 'unparser'
4
6
 
7
+ # Opt-in to most recent AST format
8
+ Parser::Builders::Default.emit_lambda = true
9
+ Parser::Builders::Default.emit_procarg0 = true
10
+ Parser::Builders::Default.emit_encoding = true
11
+ Parser::Builders::Default.emit_index = true
12
+ Parser::Builders::Default.emit_arg_inside_procarg0 = true
13
+ Parser::Builders::Default.emit_forward_arg = true
14
+ Parser::Builders::Default.emit_kwargs = true
15
+ Parser::Builders::Default.emit_match_pattern = true
16
+
5
17
  module RemoteRuby
6
18
  # Receives a block and extracts Ruby code (as a string) with this block's
7
19
  # source
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RemoteRuby
2
4
  # Decorates the source stream and writes to the cache stream as
3
5
  # the source is being read
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RemoteRuby
2
4
  # Unmarshals variables from given stream
3
5
  class Unmarshaler
@@ -41,9 +43,8 @@ module RemoteRuby
41
43
  def read_var_header(line)
42
44
  varname, length = line.split(':')
43
45
 
44
- if varname.nil? || length.nil?
45
- raise UnmarshalError, "Incorrect header '#{line}'"
46
- end
46
+ raise UnmarshalError, "Incorrect header '#{line}'" \
47
+ if varname.nil? || length.nil?
47
48
 
48
49
  [varname, length]
49
50
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RemoteRuby
2
- VERSION = '0.1.3'.freeze
4
+ VERSION = '0.2'
3
5
  end
data/lib/remote_ruby.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'remote_ruby/version'
2
4
  require 'remote_ruby/execution_context'
3
5
 
data/remote_ruby.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'remote_ruby/version'
@@ -8,6 +10,12 @@ Gem::Specification.new do |spec|
8
10
  spec.authors = ['Nikita Chernukhin']
9
11
  spec.email = ['nuinuhin@gmail.com']
10
12
 
13
+ spec.metadata = {
14
+ 'rubygems_mfa_required' => 'true'
15
+ }
16
+
17
+ spec.required_ruby_version = '>= 2.6'
18
+
11
19
  spec.summary = 'Execute Ruby code on the remote servers.'
12
20
  spec.description =
13
21
  'Execute Ruby code on the remote servers from local Ruby script.'
@@ -21,7 +29,7 @@ Gem::Specification.new do |spec|
21
29
  spec.require_paths = ['lib']
22
30
 
23
31
  spec.add_runtime_dependency 'colorize', '~> 0.8'
24
- spec.add_runtime_dependency 'method_source', '~> 0.9'
25
- spec.add_runtime_dependency 'parser', '~> 2.5'
26
- spec.add_runtime_dependency 'unparser', '~> 0.2.6'
32
+ spec.add_runtime_dependency 'method_source', '~> 1.0'
33
+ spec.add_runtime_dependency 'parser', '~> 3.0'
34
+ spec.add_runtime_dependency 'unparser', '~> 0.6'
27
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Chernukhin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-14 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -30,42 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.9'
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.9'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: parser
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.5'
47
+ version: '3.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.5'
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: unparser
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.2.6
61
+ version: '0.6'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.2.6
68
+ version: '0.6'
69
69
  description: Execute Ruby code on the remote servers from local Ruby script.
70
70
  email:
71
71
  - nuinuhin@gmail.com
@@ -73,11 +73,10 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".github/workflows/main.yml"
76
77
  - ".gitignore"
77
- - ".gitlab-ci.yml"
78
78
  - ".rspec"
79
79
  - ".rubocop.yml"
80
- - ".travis.yml"
81
80
  - Gemfile
82
81
  - LICENSE.txt
83
82
  - README.md
@@ -104,8 +103,9 @@ files:
104
103
  homepage: https://github.com/nu-hin/remote_ruby
105
104
  licenses:
106
105
  - MIT
107
- metadata: {}
108
- post_install_message:
106
+ metadata:
107
+ rubygems_mfa_required: 'true'
108
+ post_install_message:
109
109
  rdoc_options: []
110
110
  require_paths:
111
111
  - lib
@@ -113,16 +113,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: '0'
116
+ version: '2.6'
117
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - ">="
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubyforge_project:
124
- rubygems_version: 2.4.5.1
125
- signing_key:
123
+ rubygems_version: 3.2.22
124
+ signing_key:
126
125
  specification_version: 4
127
126
  summary: Execute Ruby code on the remote servers.
128
127
  test_files: []
data/.gitlab-ci.yml DELETED
@@ -1,38 +0,0 @@
1
- variables:
2
- BUNDLE_APP_CONFIG: '.bundle'
3
-
4
- stages:
5
- - build
6
- - lint
7
- - test
8
-
9
- cache:
10
- key: ${CI_COMMIT_REF_SLUG}
11
- paths:
12
- - vendor/bundle/
13
- - .bundle/
14
-
15
- bundle:
16
- stage: build
17
- script:
18
- - bundle config --local path vendor/bundle
19
- - bundle config --local jobs $(nproc)
20
- - bundle config --local with development test
21
- - bundle install
22
- - bundle env
23
- - ls -la
24
-
25
- rubocop:
26
- stage: lint
27
- script:
28
- - ls -la
29
- - ls -la vendor/bundle/ruby/*/gems
30
- - bundle exec rubocop
31
- dependencies:
32
- - bundle
33
-
34
- rspec:
35
- stage: test
36
- script: bundle exec rspec
37
- dependencies:
38
- - bundle
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1
4
- - 2.2
5
- - 2.2.3
6
- - 2.3
7
- - 2.4
8
- - 2.5
9
- script:
10
- - bundle exec rspec
11
- os:
12
- - linux
13
- - osx