gem-console 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/gem-console.gemspec +25 -0
- data/lib/gem/console/tasks/console.rb +58 -0
- data/lib/gem/console/version.rb +5 -0
- data/lib/gem/console.rb +83 -0
- data/lib/gem-console.rb +1 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f1222523851a4a8f32554d30ad6614146bf3cf73
|
4
|
+
data.tar.gz: a75481a470b3aa1456bacca9d2e299db7aba6d52
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 16aaaa84733509e5552ea15516301be315ee44ed1d5dcc4b4e137f0cf409bf0803b99ccf037fb9651f3f39ea10a2546c95805253883329e314c5c2a3de9c9c3a
|
7
|
+
data.tar.gz: 4a2d59abbd7ca486b71125eefc7b2e076eb9ef2a60979db0598df432cddaaa6335a36b5ac676e12ffe0363454527caaab15aaf410b63b08e2dba5456bcdcabab
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Chris Keele
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Gem::Console
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'gem-console'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install gem-console
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/gem-console/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/gem-console.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gem/console/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gem-console"
|
8
|
+
spec.version = Gem::Console::VERSION
|
9
|
+
spec.authors = ["Chris Keele"]
|
10
|
+
spec.email = ["dev@chriskeele.com"]
|
11
|
+
spec.summary = "Easily add developer console support to your gems."
|
12
|
+
spec.description = spec.summary + "\n" + <<-DESC
|
13
|
+
Supports pry and irb.
|
14
|
+
DESC
|
15
|
+
spec.homepage = ""
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
module Gem
|
4
|
+
module Console
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def enable(library_load_file = $library_load_file)
|
9
|
+
|
10
|
+
library_load_file ||= catch(:file) do
|
11
|
+
throw_or_recurse Dir[File.join 'lib', '*']
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Open a console preloaded with this library'
|
15
|
+
task :console, :cmd do |_, args|
|
16
|
+
args.with_defaults(cmd: pry_enabled? ? 'pry' : 'irb')
|
17
|
+
sh [
|
18
|
+
'bundle exec',
|
19
|
+
args.cmd,
|
20
|
+
"-I lib",
|
21
|
+
"-r #{library_load_file}"
|
22
|
+
].join(' ')
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def throw_or_recurse(paths)
|
28
|
+
files, dirs = paths.partition do |path|
|
29
|
+
File.file? path
|
30
|
+
end
|
31
|
+
files.each do |file|
|
32
|
+
puts "Considering #{file}..."
|
33
|
+
throw :file, file if File.extname(file) == '.rb'
|
34
|
+
end if not files.empty?
|
35
|
+
dirs.each do |dir|
|
36
|
+
puts "recursing #{dir}..."
|
37
|
+
throw_or_recurse Dir[dir]
|
38
|
+
end if not dirs.empty?
|
39
|
+
raise 'No library file to load `rake console` from found.' +
|
40
|
+
'Set $library_load_file in your Rakefile or ' +
|
41
|
+
'provide a path in your `Gem::Console.enable` invocation.'
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def pry_enabled?
|
46
|
+
begin
|
47
|
+
require 'pry'
|
48
|
+
rescue LoadError
|
49
|
+
false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
data/lib/gem/console.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require "gem/console/version"
|
3
|
+
|
4
|
+
module Gem
|
5
|
+
module Console
|
6
|
+
|
7
|
+
extend Rake::DSL
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def enable(load_dir = 'lib', load_file = nil)
|
12
|
+
|
13
|
+
load_dir, load_file = 'lib', load_dir unless load_file or load_dir == 'lib'
|
14
|
+
|
15
|
+
load_file ||= catch(:file) do
|
16
|
+
search_gem_paths Dir[File.join load_dir, '*']
|
17
|
+
end
|
18
|
+
load_file.slice!(File.join load_dir, '')
|
19
|
+
|
20
|
+
desc "Open a ruby console preloaded with this library"
|
21
|
+
task :console do
|
22
|
+
Rake::Task["console:#{command}"].invoke
|
23
|
+
end
|
24
|
+
|
25
|
+
namespace :console do
|
26
|
+
|
27
|
+
task :irb do
|
28
|
+
run_console precommand, :irb, load_dir, load_file
|
29
|
+
end
|
30
|
+
|
31
|
+
task :pry do
|
32
|
+
run_console precommand, :pry, load_dir, load_file
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def search_gem_paths(paths)
|
42
|
+
files, dirs = paths.partition do |path|
|
43
|
+
File.file? path
|
44
|
+
end
|
45
|
+
files.each do |file|
|
46
|
+
throw :file, file if File.extname(file) == '.rb'
|
47
|
+
end if not files.empty?
|
48
|
+
dirs.each do |dir|
|
49
|
+
search_gem_paths Dir[File.join dir, '*']
|
50
|
+
end if not dirs.empty?
|
51
|
+
raise [
|
52
|
+
'No library file to load `rake console` from found.',
|
53
|
+
'Provide a path in your `Gem::Console.enable` invocation.',
|
54
|
+
].join(' ')
|
55
|
+
end
|
56
|
+
|
57
|
+
def precommand
|
58
|
+
'bundle exec' if File.exists? 'Gemfile'
|
59
|
+
end
|
60
|
+
|
61
|
+
def command
|
62
|
+
pry_enabled? ? :pry : :irb
|
63
|
+
end
|
64
|
+
|
65
|
+
def pry_enabled?
|
66
|
+
require 'pry' or true
|
67
|
+
rescue ::LoadError
|
68
|
+
false
|
69
|
+
end
|
70
|
+
|
71
|
+
def run_console(precommand, command, load_dir, load_file)
|
72
|
+
sh [
|
73
|
+
precommand,
|
74
|
+
command,
|
75
|
+
"-I #{load_dir}",
|
76
|
+
"-r #{load_file}"
|
77
|
+
].compact.join(' ')
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
data/lib/gem-console.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'gem/console'
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gem-console
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Keele
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: |
|
42
|
+
Easily add developer console support to your gems.
|
43
|
+
Supports pry and irb.
|
44
|
+
email:
|
45
|
+
- dev@chriskeele.com
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- gem-console.gemspec
|
56
|
+
- lib/gem-console.rb
|
57
|
+
- lib/gem/console.rb
|
58
|
+
- lib/gem/console/tasks/console.rb
|
59
|
+
- lib/gem/console/version.rb
|
60
|
+
homepage: ''
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.2.2
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Easily add developer console support to your gems.
|
84
|
+
test_files: []
|