rash-shell 0.1.1 → 0.2.0

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
- SHA1:
3
- metadata.gz: 516af444b667cdd527d0373d413b10f10e7a5379
4
- data.tar.gz: acb013df44b9bad6dd859a018d657e99671962d0
2
+ SHA256:
3
+ metadata.gz: 66270b2fac69b602165a403ebbf915286417778fdb942c98697db90373d2fc42
4
+ data.tar.gz: a0362f5191689aad1d973d970043dda81ff5301b2ab368161ccf0f6f07641183
5
5
  SHA512:
6
- metadata.gz: fe30d417747d0c495d5731700ff7d5287d7ef6059cd2cb9256728dc303de2c379390e1490390d843585e16b367d8e9f8978db16cdfdcf1f754615e241fb5ea42
7
- data.tar.gz: fdf05f8dc7a539c06655cb5133a82308484ea1c82f51b8df9e5e1eb9945875d7a13e8dbb1a23090eb0322f61c9da5a06fd3705c1489942bb9a4ad5ee1a55b531
6
+ metadata.gz: b88eb5c4e3e34aa7a70916b073766612144fab6627c95da95f12ca05b4d1186ded339e11d9461865d7eb28f5c5a93b8d894ff9e525f871867d2297dc7c36fb0b
7
+ data.tar.gz: e0d0743d49f6ac944c37914b8e024f029df81a2405698ac00cb252a382a275cc06c16a08b7a63396b8c68010953bded14b482e29a7dad0c25c9baef12ad01b9c
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Rash::Shell
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rash/shell`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Like [racksh](https://github.com/sickill/racksh), but different.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,19 +20,29 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ ```
24
+ $ rash
25
+ rash-shell shell started in development environment. Happy Hackin'
26
26
 
27
- ## Development
27
+ rash-shell [development] %
28
+ ```
28
29
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec rash-shell` to use the gem in this directory, ignoring other installed copies of this gem.
30
+ ## Development
30
31
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+ To release a new version, update the version number in `version.rb`, and then
33
+ run `rake release`, which will create a git tag for the version, push git
34
+ commits and tags, and push the `.gem` file to
35
+ [rubygems.org](https://rubygems.org).
32
36
 
33
37
  ## Contributing
34
38
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rash-shell. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
-
39
+ Bug reports and pull requests are welcome on GitHub at
40
+ <https://github.com/JeanMertz/rash-shell>. This project is intended to be a
41
+ safe, welcoming space for collaboration, and contributors are expected to
42
+ adhere to the [Contributor Covenant](http://contributor-covenant.org) code of
43
+ conduct.
37
44
 
38
45
  ## License
39
46
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
47
+ The gem is available as open source under the terms of the [MIT
48
+ License](http://opensource.org/licenses/MIT).
data/bin/rash CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'rack'
4
5
  require 'pry'
@@ -8,13 +9,15 @@ ENV['RACK_ENV'] ||= 'development'
8
9
  config_ru_path = ENV.fetch('CONFIG_RU_PATH', 'config.ru')
9
10
  Rack::Builder.parse_file(config_ru_path)
10
11
 
11
- if ARGV.empty?
12
- Pry.start
13
- else
14
- Pry.prompt = Pry::NO_PROMPT
12
+ cmd = ''
13
+
14
+ if !STDIN.tty? || ARGV.any?
15
+ Pry.prompt = Pry::Prompt[:none][:value]
15
16
  Pry.hooks.delete_hook(:before_session, :welcome)
17
+ Pry.config.print = proc { |output, value| output.puts value }
16
18
 
17
- puts
18
- cmd = ARGV.join(' ').concat("\n exit")
19
- Pry::CLI.parse_options(['--exec', cmd])
19
+ input = ARGV.any? ? ARGV.join(' ') : STDIN.read
20
+ cmd = 'begin;' + input + ';rescue=>e;puts(e.message);abort;else(exit);end'
20
21
  end
22
+
23
+ Pry.start(Pry.toplevel_binding, input: StringIO.new(cmd))
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rash/shell/pry'
2
4
  require 'rash/shell/version'
3
5
 
@@ -7,7 +9,7 @@ module Rash
7
9
  module_function
8
10
 
9
11
  def environment
10
- ENV['RACK_ENV'] || 'development'
12
+ ENV['APP_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
11
13
  end
12
14
 
13
15
  def environment_color
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pry'
2
4
 
3
5
  require 'rash/shell/pry/commands'
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rash/shell/pry/commands/h'
2
4
  require 'rash/shell/pry/commands/no_prompt'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Pry::Commands.create_command 'h' do
2
4
  description 'Show application specific help (if any are defined): h ARG'
3
5
  end
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Pry::Commands.create_command 'no-prompt' do
2
4
  description 'Show/hide REPL command prompt prefix'
3
5
 
4
6
  def process
5
7
  case _pry_.prompt
6
- when Pry::NO_PROMPT
8
+ when Pry::Prompt[:none][:value]
7
9
  _pry_.pop_prompt
8
10
  else
9
- _pry_.push_prompt Pry::NO_PROMPT
11
+ _pry_.push_prompt Pry::Prompt[:none][:value]
10
12
  end
11
13
  end
12
14
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Pry.hooks.add_hook(:before_session, :welcome) do |output|
2
4
  output.print "#{Pry::Helpers::Text.yellow(Pry.config.prompt_name)} shell " \
3
5
  "started in #{Rash::Shell.environment_with_color} environment. "
@@ -6,8 +8,11 @@ Pry.hooks.add_hook(:before_session, :welcome) do |output|
6
8
  output.puts "\n\n"
7
9
  end
8
10
 
11
+ name = [ENV['APP_NAME'], ENV['APP_COMPONENT']].compact.join('-')
12
+ name = File.basename(Dir.pwd) if name.empty?
13
+
9
14
  Pry.config.color = true
10
15
  Pry.config.theme = 'railscasts'
11
16
  Pry.config.pager = false
12
17
  Pry.config.history.file = '.pry_history'
13
- Pry.config.prompt_name = "\e[38;5;222m#{ENV['APP_NAME'] || File.basename(Dir.pwd)}\033[0m"
18
+ Pry.config.prompt_name = "\e[38;5;222m#{name}\033[0m"
@@ -1,13 +1,15 @@
1
- Pry.prompt = [
2
- proc do |target_self, _, pry|
3
- target = target_self.to_s == 'main' ? '' : " (#{target_self.to_s.split('::').last})"
1
+ # frozen_string_literal: true
2
+
3
+ Pry.config.prompt = [
4
+ proc do |obj, _, pry|
5
+ target = obj.to_s == 'main' ? '' : " (#{target_self.to_s.split('::').last})"
4
6
  env = Rash::Shell.environment_with_color
5
7
 
6
8
  "#{pry.config.prompt_name} [#{env}]#{target} % "
7
9
  end,
8
10
 
9
- proc do |target_self, _, pry|
10
- target = target_self.to_s == 'main' ? '' : " (#{target_self.to_s.split('::').last})"
11
+ proc do |obj, _, pry|
12
+ target = obj.to_s == 'main' ? '' : " (#{target_self.to_s.split('::').last})"
11
13
  env = Rash::Shell.environment_with_color
12
14
 
13
15
  "#{pry.config.prompt_name} [#{env}]#{target} * "
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Rash
2
4
  module Shell
3
- VERSION = '0.1.1'.freeze
5
+ VERSION = '0.2.0'
4
6
  end
5
7
  end
@@ -1,5 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'rash/shell/version'
5
6
 
@@ -19,9 +20,9 @@ Gem::Specification.new do |spec|
19
20
  spec.require_paths = ['lib']
20
21
 
21
22
  spec.add_development_dependency 'bundler', '~> 1.11'
22
- spec.add_development_dependency 'rake', '~> 10.0'
23
23
  spec.add_development_dependency 'minitest', '~> 5.0'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
24
25
 
25
- spec.add_dependency 'pry'
26
- spec.add_dependency 'pry-theme'
26
+ spec.add_dependency 'pry', '~> 0.12'
27
+ spec.add_dependency 'pry-theme', '~> 1'
27
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rash-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Mertz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-04 00:00:00.000000000 Z
11
+ date: 2019-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,61 +25,61 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.11'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '5.0'
34
34
  type: :development
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: '10.0'
40
+ version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: '10.0'
48
48
  type: :development
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: '5.0'
54
+ version: '10.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '0.12'
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'
68
+ version: '0.12'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry-theme
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '1'
83
83
  description: Write a longer description or delete this line.
84
84
  email:
85
85
  - jean@mertz.fm
@@ -123,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubyforge_project:
127
- rubygems_version: 2.6.13
126
+ rubygems_version: 3.0.3
128
127
  signing_key:
129
128
  specification_version: 4
130
129
  summary: Write a short summary, because Rubygems requires one.