ripl-profiles 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemspec +20 -0
- data/CHANGELOG.rdoc +2 -0
- data/LICENSE.txt +22 -0
- data/README.rdoc +27 -0
- data/Rakefile +35 -0
- data/deps.rip +1 -0
- data/lib/ripl/profiles.rb +80 -0
- metadata +87 -0
data/.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
name = 'ripl-profiles'
|
3
|
+
|
4
|
+
require 'rubygems' unless defined? Gem
|
5
|
+
require File.dirname(__FILE__) + "/lib/ripl/profiles"
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = name
|
9
|
+
s.version = Ripl::Profiles::VERSION
|
10
|
+
s.authors = ["Jan Lelis"]
|
11
|
+
s.email = "mail@janlelis.de"
|
12
|
+
s.homepage = "http://github.com/janlelis/" + name
|
13
|
+
s.summary = "This ripl plugin adds a --profile option to ripl that loads profile files in ~/.ripl/profiles."
|
14
|
+
s.description = "This ripl plugin adds a --profile option to ripl that loads profile files in ~/.ripl/profiles before starting ripl."
|
15
|
+
s.required_rubygems_version = ">= 1.3.6"
|
16
|
+
s.add_dependency 'ripl', '>= 0.2.6'
|
17
|
+
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
18
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
19
|
+
s.license = 'MIT'
|
20
|
+
end
|
data/CHANGELOG.rdoc
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2010 Jan Lelis
|
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.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
== Description
|
2
|
+
This {ripl}[https://github.com/cldwalker/ripl] plugin adds a <tt>--profile</tt> option to ripl that loads profile files in <tt>~/.ripl/profiles/</tt> before ripl starts.
|
3
|
+
|
4
|
+
== Install
|
5
|
+
Install the gem with:
|
6
|
+
|
7
|
+
gem install ripl-profiles
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
Add to your ~/.riplrc
|
12
|
+
|
13
|
+
require 'ripl/profiles'
|
14
|
+
|
15
|
+
You can now call
|
16
|
+
|
17
|
+
ripl --profile colors
|
18
|
+
|
19
|
+
which will try to load <tt>~/.ripl/profiles/colors.rb</tt> before starting ripl. You can change the profile path with <tt>Ripl.config[:profiles_prefix]</tt>.
|
20
|
+
|
21
|
+
Multiple profiles can be separated with <tt>:</tt> .
|
22
|
+
|
23
|
+
To specify which profiles should always get loaded, you can use the <tt>Ripl.config[:profiles_base]</tt> array.
|
24
|
+
|
25
|
+
You can also set a default profile with <tt>Ripl.config[:profiles_default]</tt>, which will only be loaded, if no profile option has been passed.
|
26
|
+
|
27
|
+
J-_-L
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
def gemspec
|
5
|
+
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Build the gem"
|
9
|
+
task :gem=>:gemspec do
|
10
|
+
sh "gem build .gemspec"
|
11
|
+
FileUtils.mkdir_p 'pkg'
|
12
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Install the gem locally"
|
16
|
+
task :install => :gem do
|
17
|
+
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Generate the gemspec"
|
21
|
+
task :generate do
|
22
|
+
puts gemspec.to_ruby
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Validate the gemspec"
|
26
|
+
task :gemspec do
|
27
|
+
gemspec.validate
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Run tests'
|
31
|
+
task :test do |t|
|
32
|
+
sh 'bacon -q -Ilib -I. test/*_test.rb'
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
data/deps.rip
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ripl >=0.2.7
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'ripl'
|
2
|
+
|
3
|
+
module Ripl::Profiles
|
4
|
+
VERSION = '0.1.0'
|
5
|
+
|
6
|
+
@loaded = []
|
7
|
+
|
8
|
+
Ripl::Runner::OPTIONS << ['-p', '--profile NAME', 'Use a profile']
|
9
|
+
|
10
|
+
class << self
|
11
|
+
attr_reader :loaded
|
12
|
+
|
13
|
+
def available
|
14
|
+
Dir[ File.expand_path( File.join( Ripl.config[:profiles_prefix], '*' ) )].map{ |path|
|
15
|
+
File.basename( path ).sub( /#{File.extname(path)}$/,'' )
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def load( names )
|
20
|
+
Array(names).each{ |name|
|
21
|
+
profile_path = File.expand_path( File.join( Ripl.config[:profiles_prefix], "#{ name }.rb" ) )
|
22
|
+
if File.exists? profile_path
|
23
|
+
Ripl::Runner.load_rc profile_path
|
24
|
+
puts "Loaded profile: #{ name }" if Ripl.config[:profiles_verbose]
|
25
|
+
@loaded << name
|
26
|
+
else
|
27
|
+
warn "ripl: Couldn't load the profile #{ name } at: #{ profile_path }"
|
28
|
+
end
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# command shortcuts
|
34
|
+
module Commands
|
35
|
+
def available_profiles
|
36
|
+
Ripl::Profiles.list
|
37
|
+
end
|
38
|
+
|
39
|
+
def load_profile( name )
|
40
|
+
Ripl::Profiles.load name
|
41
|
+
end
|
42
|
+
|
43
|
+
def loaded_profiles
|
44
|
+
Ripl::Profiles.loaded
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module Shell
|
49
|
+
# load default profile if non is set
|
50
|
+
def before_loop
|
51
|
+
super
|
52
|
+
if Ripl.config[:profiles_default] && Ripl::Profiles.loaded.empty?
|
53
|
+
Ripl::Profiles.load Ripl.config[:profiles_default]
|
54
|
+
end
|
55
|
+
if Ripl.config[:profiles_base]
|
56
|
+
Ripl::Profiles.load Ripl.config[:profiles_base]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
module Runner
|
62
|
+
# add command line option
|
63
|
+
def parse_option( option, argv )
|
64
|
+
if option =~ /(?:-p|--profile)=?(.*)/
|
65
|
+
Ripl::Profiles.load ($1.empty? ? argv.shift.to_s : $1).split(':')
|
66
|
+
else
|
67
|
+
super
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
Ripl::Runner.send :extend, Ripl::Profiles::Runner
|
74
|
+
Ripl::Shell.send :include, Ripl::Profiles::Shell
|
75
|
+
Ripl::Commands.send :include, Ripl::Profiles::Commands
|
76
|
+
|
77
|
+
Ripl.config[:profiles_prefix] ||= "~/.ripl/profiles/"
|
78
|
+
Ripl.config[:profiles_verbose] ||= false
|
79
|
+
|
80
|
+
# J-_-L
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ripl-profiles
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jan Lelis
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-09 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: ripl
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 2
|
31
|
+
- 6
|
32
|
+
version: 0.2.6
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: This ripl plugin adds a --profile option to ripl that loads profile files in ~/.ripl/profiles before starting ripl.
|
36
|
+
email: mail@janlelis.de
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README.rdoc
|
43
|
+
- LICENSE.txt
|
44
|
+
files:
|
45
|
+
- lib/ripl/profiles.rb
|
46
|
+
- LICENSE.txt
|
47
|
+
- README.rdoc
|
48
|
+
- CHANGELOG.rdoc
|
49
|
+
- deps.rip
|
50
|
+
- Rakefile
|
51
|
+
- .gemspec
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://github.com/janlelis/ripl-profiles
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
segments:
|
75
|
+
- 1
|
76
|
+
- 3
|
77
|
+
- 6
|
78
|
+
version: 1.3.6
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.3.7
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: This ripl plugin adds a --profile option to ripl that loads profile files in ~/.ripl/profiles.
|
86
|
+
test_files: []
|
87
|
+
|