workplaces 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +1 -0
- data/bin/workplace +3 -0
- data/lib/workplaces.rb +8 -0
- data/lib/workplaces/cli.rb +122 -0
- data/lib/workplaces/context.rb +30 -0
- data/lib/workplaces/dirs.rb +21 -0
- data/lib/workplaces/settings.rb +77 -0
- data/lib/workplaces/version.rb +3 -0
- data/lib/workplaces/workplace.rb +7 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/cli.rb +10 -0
- data/spec/workplaces/cli_spec.rb +15 -0
- data/spec/workplaces/contexts_spec.rb +69 -0
- data/spec/workplaces/dirs_spec.rb +35 -0
- data/spec/workplaces/settings_spec.rb +71 -0
- data/spec/workplaces/workplace_spec.rb +3 -0
- data/todo +9 -0
- data/workplaces.gemspec +29 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3d86e981c875756479eba327325c1aa57e1b4fba
|
4
|
+
data.tar.gz: 9c667c190fe684d6484d84355f3c527cad7dc2af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a7fa471681736ba79ed041a164f3b47b1babfe13a8b97ffb302e14870d97783168e9b4eef60d3bb356be9ae92820dcbfc2baf8805cde7dfa555fd87a9319e75
|
7
|
+
data.tar.gz: 2c8e52261006b673fa69ed2be53d15999ac3b49e4862231e3026bb8787ff65475f087fed645f75d7517c6fbf6141e8218bcc27bb529b429d597857796c3a57c7
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Sergey Kucher
|
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,47 @@
|
|
1
|
+
# Workplaces
|
2
|
+
|
3
|
+
Tool for make context based aliases of your commands.
|
4
|
+
|
5
|
+
|
6
|
+
## How to use
|
7
|
+
|
8
|
+
* Make simple aliases for the commands you use and bind them to the context.
|
9
|
+
* Set context to your working directories.
|
10
|
+
* Use aliases to run your directory relative tasks.
|
11
|
+
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'workplaces'
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install workplaces
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Workplaces commands:
|
30
|
+
|
31
|
+
workplace alias [NAME] (-d | -c CONTEXT -e EXPRESSION) # Create alias (NAME) for an expression (EXECUTE) in the CONTEXT.
|
32
|
+
workplace aliases [CONTEXT] # Show list of aliases for the CONTEXT.
|
33
|
+
workplace context [*LIST] # Add LIST to a context for a current directory.
|
34
|
+
workplace exclude CONTEXT -f, --from=FROM # Exclude CONTEXT from the ANOTHER
|
35
|
+
workplace execute ALIAS # Find alias in the current context and execute command
|
36
|
+
workplace help [COMMAND] # Describe available commands or one specific command
|
37
|
+
workplace include CONTEXT -t, --to=TO # Include CONTEXT to the target
|
38
|
+
workplace included [CONTEXT] # Show contexts included to specified CONTEXT
|
39
|
+
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it ( http://github.com/<my-github-username>/workplaces/fork )
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/workplace
ADDED
data/lib/workplaces.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Workplaces
|
5
|
+
|
6
|
+
class Cli < Thor
|
7
|
+
package_name 'Workplaces'
|
8
|
+
|
9
|
+
desc 'context [*LIST]', 'Add LIST to a context for a current directory.'
|
10
|
+
long_desc 'Add LIST to a context for a current directory. If list is empty, show current context.'
|
11
|
+
option :set, aliases: '-s', type: :boolean, desc: 'set context instead of add to it', default: false
|
12
|
+
option :delete, aliases: '-d', type: :boolean, default: false, desc: 'delete from current context instead of replace it'
|
13
|
+
def context(*context)
|
14
|
+
Dirs.open do |dirs|
|
15
|
+
dir = dirs[::Dir.pwd]
|
16
|
+
if context.empty? # request for show current context
|
17
|
+
if dir.context.empty?
|
18
|
+
puts 'has no context for this directory'
|
19
|
+
else
|
20
|
+
puts dir.context.to_a.join(' ')
|
21
|
+
end
|
22
|
+
elsif options[:set]
|
23
|
+
dir.context = context.to_set
|
24
|
+
elsif options[:delete]
|
25
|
+
dir.context -= context
|
26
|
+
else
|
27
|
+
dir.context += context
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'alias [NAME] (-d | -c CONTEXT -e EXPRESSION)', "Create alias (NAME) for an expression (EXECUTE) in the CONTEXT."
|
33
|
+
option :execute, aliases: '-e', desc: 'command to execute'
|
34
|
+
option :context, aliases: '-c', desc: 'set CONTEXT where create alias'
|
35
|
+
option :delete, aliases: '-d', type: :boolean, desc: 'delete alias instead of create it', default: false
|
36
|
+
def alias(*name)
|
37
|
+
raise "No alias provided" if name.empty?
|
38
|
+
raise "-c (--context) option didn't provided" unless options[:context]
|
39
|
+
Contexts.open do |contexts|
|
40
|
+
aliases = contexts[options[:context]].aliases
|
41
|
+
unless options[:delete]
|
42
|
+
raise "-e (--execute) option didn't provided" unless options[:execute]
|
43
|
+
aliases[name] = options[:execute]
|
44
|
+
else
|
45
|
+
aliases.delete name
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'aliases [CONTEXT]', "Show list of aliases for the CONTEXT."
|
51
|
+
long_desc "Show list of aliases for the CONTEXT. If no CONTEXT provided, show aliases for a current directory context."
|
52
|
+
def aliases(*context)
|
53
|
+
context = if context.empty?
|
54
|
+
Dirs.open[::Dir.pwd].context
|
55
|
+
else
|
56
|
+
context.to_set
|
57
|
+
end
|
58
|
+
puts "context: #{context.empty? ? '<none>' : context.to_a.join(' ')}"
|
59
|
+
aliases = Contexts.open.aliases(context)
|
60
|
+
puts "aliases: #{'<none>' if aliases.empty?}\n"
|
61
|
+
aliases.each_pair do |aliaz, expression|
|
62
|
+
puts " #{aliaz.join(' ')} => #{expression}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
desc 'include CONTEXT', 'Include CONTEXT to the target'
|
67
|
+
option :to, aliases: '-t', required: true,
|
68
|
+
desc: 'target of inclusion'
|
69
|
+
def include(*context)
|
70
|
+
Contexts.open do |contexts|
|
71
|
+
ctx = contexts[options[:to]]
|
72
|
+
ctx.included += context.kind_of?(Array) ? context : [context]
|
73
|
+
ctx.included = ctx.included.to_set.to_a
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc 'exclude CONTEXT', 'Exclude CONTEXT from the ANOTHER'
|
78
|
+
option :from, aliases: '-f', required: true,
|
79
|
+
desc: 'context which exclude from'
|
80
|
+
def exclude(*context)
|
81
|
+
Contexts.open do |contexts|
|
82
|
+
ctx = contexts[options[:from]]
|
83
|
+
ctx.included -= context.kind_of?(Array) ? context : [context]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
desc 'included [CONTEXT]', 'Show contexts included to specified CONTEXT'
|
88
|
+
long_desc 'Show contexts included into specified CONTEXT. If no CONTEXT specified, use context of current directory.'
|
89
|
+
def included(*context)
|
90
|
+
context = if context.empty?
|
91
|
+
Dirs.open[::Dir.pwd].context
|
92
|
+
else
|
93
|
+
context.to_set
|
94
|
+
end
|
95
|
+
contexts = Contexts.open
|
96
|
+
included = context.each_with_object(Set.new) do |ctx, included|
|
97
|
+
contexts[ctx].included.each { |i| included << i }
|
98
|
+
end
|
99
|
+
puts "context: #{context.to_a.join(' ')}"
|
100
|
+
puts "include: #{included.to_a.join(' ')}"
|
101
|
+
end
|
102
|
+
|
103
|
+
desc 'execute ALIAS', 'Find alias in the current context and execute command'
|
104
|
+
option :context, aliases: '-c', desc: 'try to find alias in the CONTEXT'
|
105
|
+
def execute(*command)
|
106
|
+
raise "Alias for the command didn't provided" if command.empty?
|
107
|
+
context = if options[:context]
|
108
|
+
[options[:context]].to_set
|
109
|
+
else
|
110
|
+
Dirs.open[::Dir.pwd].context
|
111
|
+
end
|
112
|
+
contexts = Contexts.open
|
113
|
+
aliases = contexts.aliases(context)
|
114
|
+
aliases.merge! contexts['global'].aliases
|
115
|
+
expression = aliases[command]
|
116
|
+
raise "Alias '#{command.join(' ')}' didn't exists in current context (#{context.to_a.join(' ')})" unless expression
|
117
|
+
puts "executing: #{expression}"
|
118
|
+
system expression
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Workplaces
|
2
|
+
class Contexts < Settings
|
3
|
+
|
4
|
+
settings_subclass
|
5
|
+
|
6
|
+
def aliases(context)
|
7
|
+
context.to_a.try(:each_with_object, {}) do |ctx, all_aliases|
|
8
|
+
info = self[ctx]
|
9
|
+
all_aliases.merge! info.aliases
|
10
|
+
all_aliases.merge! aliases(info.included)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
class Context < Settings::Item
|
17
|
+
|
18
|
+
attr_accessor :aliases, :included
|
19
|
+
|
20
|
+
def initialize(aliases: {}, included: [])
|
21
|
+
@aliases = aliases
|
22
|
+
@included = included
|
23
|
+
end
|
24
|
+
|
25
|
+
def ==(ctx)
|
26
|
+
aliases == ctx.aliases && included == ctx.included
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Workplaces
|
2
|
+
|
3
|
+
class Dirs < Settings
|
4
|
+
|
5
|
+
settings_subclass
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
class Dir < Settings::Item
|
10
|
+
attr_accessor :context
|
11
|
+
|
12
|
+
def initialize(context=[])
|
13
|
+
@context = context.to_set
|
14
|
+
end
|
15
|
+
|
16
|
+
def ==(dir)
|
17
|
+
self.context == dir.context
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Workplaces
|
2
|
+
|
3
|
+
class Settings < Hash
|
4
|
+
class Item
|
5
|
+
def ==(item)
|
6
|
+
self.class == item.class
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
DIR = File.join(::Dir.home, '.config', 'workplaces')
|
11
|
+
class << self
|
12
|
+
def path(name)
|
13
|
+
File.join(DIR, "#{name}.yml")
|
14
|
+
end
|
15
|
+
|
16
|
+
def open(name, &block)
|
17
|
+
settings = Settings.new name, load_data(name)
|
18
|
+
eval_block settings, &block
|
19
|
+
end
|
20
|
+
|
21
|
+
def class_name
|
22
|
+
index = name.reverse.index('::')
|
23
|
+
index ? name[-index..-1] : name
|
24
|
+
end
|
25
|
+
|
26
|
+
def settings_subclass
|
27
|
+
self.class_eval do
|
28
|
+
def self.open(&block)
|
29
|
+
settings = self.new load_data(class_name.underscore)
|
30
|
+
eval_block settings, &block
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(hash={})
|
34
|
+
super self.class.class_name.underscore, hash
|
35
|
+
item_class = self.class.name.singularize.constantize
|
36
|
+
self.default_proc = proc do |hash, key|
|
37
|
+
hash[key] = item_class.new
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
def load_data(name)
|
45
|
+
file = path name
|
46
|
+
File.exists?(file) ? YAML::load_file(file) : {}
|
47
|
+
end
|
48
|
+
|
49
|
+
def eval_block(settings)
|
50
|
+
if block_given?
|
51
|
+
yield settings
|
52
|
+
settings.save
|
53
|
+
settings
|
54
|
+
else
|
55
|
+
settings
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
attr_reader :name, :path
|
62
|
+
|
63
|
+
def initialize(name, hash={})
|
64
|
+
@name = name
|
65
|
+
@path = Settings.path name
|
66
|
+
merge! hash
|
67
|
+
end
|
68
|
+
|
69
|
+
def save
|
70
|
+
FileUtils.mkdir_p DIR unless ::Dir.exists?(DIR)
|
71
|
+
File.open(@path, 'w') do |f|
|
72
|
+
f.write({}.merge(self).to_yaml)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/support/cli.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Workplaces
|
4
|
+
describe Cli do
|
5
|
+
|
6
|
+
# context 'context command' do
|
7
|
+
# it 'should add list to a current directory context' do
|
8
|
+
# $stdout = captured_stdout = StringIO.new
|
9
|
+
# begin
|
10
|
+
# execute
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Workplaces
|
4
|
+
|
5
|
+
describe Contexts do
|
6
|
+
context 'aliases' do
|
7
|
+
let(:contexts) do
|
8
|
+
list = %w(a b c d e f)
|
9
|
+
contexts = list.each_with_object({}) do |k, contexts|
|
10
|
+
contexts[k] = ctx = Context.new
|
11
|
+
rand(1..5).times do
|
12
|
+
ctx.aliases[rand(100)] = rand(100)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
contexts['a'].included = ['b', 'c']
|
16
|
+
contexts['b'].included = ['d']
|
17
|
+
contexts
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:expected) do
|
21
|
+
%w(a b c d f).each_with_object({}) do |k, expected|
|
22
|
+
expected.merge! contexts[k].aliases
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should collect from array context' do
|
27
|
+
Contexts.new(contexts).aliases(%w{a f}).should eq expected
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should collect from set context' do
|
31
|
+
Contexts.new(contexts).aliases(%w{a f}.to_set).should eq expected
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe Context do
|
37
|
+
context 'initialize' do
|
38
|
+
it 'should have default values' do
|
39
|
+
context = Context.new
|
40
|
+
context.aliases.should eq Hash.new
|
41
|
+
context.included.should eq []
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should take aliases hash and included list' do
|
45
|
+
context = Context.new aliases: {a: 'a', b: 'b'}, included: %w(a b c)
|
46
|
+
context.aliases.should eq Hash[:a, 'a', :b, 'b']
|
47
|
+
context.included.should eq %w(a b c)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'comparision:' do
|
52
|
+
it 'should be equal another context' do
|
53
|
+
ctx1 = Context.new aliases: {a: 'a', b: 'b'}, included: %w(a b c)
|
54
|
+
ctx2 = Context.new aliases: {a: 'a', b: 'b'}, included: %w(a b c)
|
55
|
+
ctx1.should eq ctx2
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should not be equal another context" do
|
59
|
+
ctx1 = Context.new aliases: {a: 'a'}, included: ['a']
|
60
|
+
ctx2 = Context.new aliases: {b: 'b'}, included: ['a']
|
61
|
+
ctx1.should_not eq ctx2
|
62
|
+
ctx1 = Context.new aliases: {a: 'a'}, included: ['a']
|
63
|
+
ctx2 = Context.new aliases: {a: 'a'}, included: ['b']
|
64
|
+
ctx1.should_not eq ctx2
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'workplaces/dirs'
|
2
|
+
|
3
|
+
module Workplaces
|
4
|
+
|
5
|
+
describe Dir do
|
6
|
+
|
7
|
+
context 'initialize' do
|
8
|
+
it 'should have default context' do
|
9
|
+
instance = Dir.new
|
10
|
+
instance.context.should eq [].to_set
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should take list of contexts' do
|
14
|
+
instance = Dir.new %w(a b c d)
|
15
|
+
instance.context.should eq %w(a b c d).to_set
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'comparision:' do
|
20
|
+
it 'should be equal with another dir' do
|
21
|
+
dir1 = Dir.new %w(a b c d)
|
22
|
+
dir2 = Dir.new %w(d c b a)
|
23
|
+
dir1.should eq dir2
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should not be equal with another dir' do
|
27
|
+
dir1 = Dir.new %w(a b c d)
|
28
|
+
dir2 = Dir.new %w(b c d e)
|
29
|
+
dir1.should_not eq dir2
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'workplaces'
|
3
|
+
|
4
|
+
module Workplaces
|
5
|
+
|
6
|
+
describe Settings do
|
7
|
+
include FakeFS::SpecHelpers
|
8
|
+
let(:dummy_path) do
|
9
|
+
File.join(::Dir.home, '.config', 'workplaces', 'dummy.yml')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should calculate path' do
|
13
|
+
Settings.path('dummy').should eq dummy_path
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'instance' do
|
17
|
+
let(:instance) do
|
18
|
+
Settings.new('dummy', {a: 'a', b: 'b'})
|
19
|
+
end
|
20
|
+
let(:values) do
|
21
|
+
{a: 'a', b: 'b'}
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should be initialized' do
|
25
|
+
instance.name.should eq 'dummy'
|
26
|
+
instance.path.should eq dummy_path
|
27
|
+
instance.should eq values
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should save and open values' do
|
31
|
+
instance.save
|
32
|
+
settings = Settings.open instance.name
|
33
|
+
settings.name.should eq instance.name
|
34
|
+
settings.path.should eq instance.path
|
35
|
+
settings.should eq instance
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'subclass' do
|
40
|
+
before(:all) do
|
41
|
+
Workplaces.module_eval do
|
42
|
+
class Items < Settings
|
43
|
+
settings_subclass
|
44
|
+
end
|
45
|
+
class Item < Settings::Item
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
let(:instance) { Items.new a: 'a', b: 'b' }
|
51
|
+
|
52
|
+
it 'should save and open settings' do
|
53
|
+
instance.save
|
54
|
+
items = Items.open
|
55
|
+
items.name.should eq 'items'
|
56
|
+
items.path.should eq instance.path
|
57
|
+
items.should eq instance
|
58
|
+
items[:c].should eq Item.new
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should initialize instance' do
|
62
|
+
instance.name.should eq 'items'
|
63
|
+
instance[:c].should eq Item.new
|
64
|
+
instance.should eq(a: 'a', b: 'b', c: Item.new)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/todo
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
---- make rspec tests for cli
|
2
|
+
---- make aliases available without call of workplace command
|
3
|
+
--- make auto completion with zsh
|
4
|
+
-- `worklace aliases` must show aliases by the contexts
|
5
|
+
+---- Make tests
|
6
|
+
+---- find and execute alias
|
7
|
+
+---- include and exclude context to/from another
|
8
|
+
+---- create alias for context
|
9
|
+
+---- set context to the directories
|
data/workplaces.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'workplaces/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "workplaces"
|
8
|
+
spec.version = Workplaces::VERSION
|
9
|
+
spec.authors = ["Sergey Kucher"]
|
10
|
+
spec.email = ["s.e.kucher@gmail.com"]
|
11
|
+
spec.summary = "Tool to make context based aliases of your commands."
|
12
|
+
spec.description = "Tool to make context based aliases of your commands."
|
13
|
+
spec.homepage = "https://github.com/sergey-kucher/workplaces"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
|
22
|
+
spec.add_dependency "thor", "~> 0.18.1"
|
23
|
+
spec.add_dependency "activesupport", "4.0.0"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec", "~> 2.14.1"
|
28
|
+
spec.add_development_dependency "fakefs", "~> 0.5.1"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: workplaces
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sergey Kucher
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.18.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.18.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.14.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.14.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fakefs
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.5.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.5.1
|
97
|
+
description: Tool to make context based aliases of your commands.
|
98
|
+
email:
|
99
|
+
- s.e.kucher@gmail.com
|
100
|
+
executables:
|
101
|
+
- workplace
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/workplace
|
111
|
+
- lib/workplaces.rb
|
112
|
+
- lib/workplaces/cli.rb
|
113
|
+
- lib/workplaces/context.rb
|
114
|
+
- lib/workplaces/dirs.rb
|
115
|
+
- lib/workplaces/settings.rb
|
116
|
+
- lib/workplaces/version.rb
|
117
|
+
- lib/workplaces/workplace.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
- spec/support/cli.rb
|
120
|
+
- spec/workplaces/cli_spec.rb
|
121
|
+
- spec/workplaces/contexts_spec.rb
|
122
|
+
- spec/workplaces/dirs_spec.rb
|
123
|
+
- spec/workplaces/settings_spec.rb
|
124
|
+
- spec/workplaces/workplace_spec.rb
|
125
|
+
- todo
|
126
|
+
- workplaces.gemspec
|
127
|
+
homepage: https://github.com/sergey-kucher/workplaces
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.2.2
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Tool to make context based aliases of your commands.
|
151
|
+
test_files:
|
152
|
+
- spec/spec_helper.rb
|
153
|
+
- spec/support/cli.rb
|
154
|
+
- spec/workplaces/cli_spec.rb
|
155
|
+
- spec/workplaces/contexts_spec.rb
|
156
|
+
- spec/workplaces/dirs_spec.rb
|
157
|
+
- spec/workplaces/settings_spec.rb
|
158
|
+
- spec/workplaces/workplace_spec.rb
|