taketo 0.2.0.alpha → 0.2.0

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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.travis.yml +9 -0
  4. data/.yardopts +7 -0
  5. data/Gemfile +9 -7
  6. data/Gemfile.lock +26 -10
  7. data/README.md +3 -1
  8. data/Rakefile +7 -1
  9. data/VERSION +1 -1
  10. data/bin/taketo +2 -1
  11. data/lib/taketo/actions/edit_config.rb +16 -0
  12. data/lib/taketo/actions/generate_ssh_config.rb +0 -3
  13. data/lib/taketo/actions/list.rb +2 -4
  14. data/lib/taketo/actions/login.rb +2 -4
  15. data/lib/taketo/actions/matches.rb +9 -9
  16. data/lib/taketo/actions/view.rb +2 -4
  17. data/lib/taketo/actions.rb +5 -1
  18. data/lib/taketo/commands/ssh_command.rb +2 -0
  19. data/lib/taketo/config_printer_visitor.rb +2 -0
  20. data/lib/taketo/config_traverser.rb +2 -0
  21. data/lib/taketo/config_validator.rb +1 -0
  22. data/lib/taketo/constructs/base_construct.rb +1 -0
  23. data/lib/taketo/constructs/command.rb +2 -0
  24. data/lib/taketo/constructs/config.rb +2 -0
  25. data/lib/taketo/constructs/environment.rb +2 -0
  26. data/lib/taketo/constructs/group.rb +2 -0
  27. data/lib/taketo/constructs/project.rb +2 -0
  28. data/lib/taketo/constructs/server.rb +2 -0
  29. data/lib/taketo/constructs_factory.rb +2 -1
  30. data/lib/taketo/destination_matcher.rb +2 -0
  31. data/lib/taketo/dsl.rb +2 -0
  32. data/lib/taketo/group_list_visitor.rb +2 -0
  33. data/lib/taketo/node_resolver.rb +2 -0
  34. data/lib/taketo/printer.rb +2 -0
  35. data/lib/taketo/ssh_config_generator_visitor.rb +2 -0
  36. data/lib/taketo/support/inflections.rb +44 -0
  37. data/lib/taketo/support/named_nodes_collection.rb +3 -1
  38. data/lib/taketo/support.rb +1 -0
  39. data/scripts/zsh/completion/_taketo +36 -0
  40. data/spec/acceptance/edit_config_spec.rb +12 -0
  41. data/spec/lib/taketo/support/inflections_spec.rb +44 -0
  42. data/spec/spec_helper.rb +3 -0
  43. data/taketo.gemspec +41 -0
  44. metadata +80 -42
  45. data/lib/taketo/actions/group_action.rb +0 -15
  46. data/lib/taketo/actions/node_action.rb +0 -15
  47. data/lib/taketo/actions/server_action.rb +0 -14
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 029c1faa2c6ca7f98624297fb06f91d808fcb0f7
4
+ data.tar.gz: b271faf2011fcc1df7c02a8a4faaf5f058539579
5
+ SHA512:
6
+ metadata.gz: 6c3e8368d01c29ca74ab7bd0162fdd37bed1c56cf2258f2b621e992e116ed709c4667b01e0cdcf1011b262004765d35b163c017e692a838c0f190722f72e98c3
7
+ data.tar.gz: b3117151aded8ce18fb21961aea05ae3745fa9523393b1379d05bc332a657dc02421fcc3742cb67066d5a1cb4cb185e7239fe79c1a5825643028e8af1331caf6
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ tmp/
2
+ doc/
3
+ .yardoc/
4
+ .DS_Store
5
+ .tags*
6
+ .rvmrc
7
+ .exrc
8
+ nohup.out
9
+ pkg/
10
+ coverage/
11
+ *.sublime-project
12
+ *.sublime-workspace
13
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - ree-1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - 2.0.0
7
+ branches:
8
+ only:
9
+ - master
data/.yardopts ADDED
@@ -0,0 +1,7 @@
1
+ --markup markdown
2
+ --markup-provider redcarpet
3
+ --charset utf-8
4
+ --readme README.md
5
+ -
6
+ README.md
7
+ LICENSE.txt
data/Gemfile CHANGED
@@ -1,10 +1,12 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
2
4
 
3
5
  group :development do
4
- gem "rspec", "~> 2.11"
5
- gem "rake", "~> 0.9"
6
- gem 'simplecov', '~> 0.6', :require => false
7
- gem 'open4', '~> 1.3'
8
- gem 'pry'
9
- end
6
+ gem 'simplecov', :require => false
7
+ gem 'coveralls', :require => false
10
8
 
9
+ gem "ripper", :platforms => :ruby_18
10
+ gem "redcarpet", "~> 2.2"
11
+ gem "yard", "~> 0.8.5"
12
+ end
data/Gemfile.lock CHANGED
@@ -1,16 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ taketo (0.2.0)
5
+
1
6
  GEM
2
- remote: http://rubygems.org/
7
+ remote: https://rubygems.org/
3
8
  specs:
4
- coderay (1.0.7)
9
+ colorize (0.5.8)
10
+ coveralls (0.6.3)
11
+ colorize
12
+ multi_json (~> 1.3)
13
+ rest-client
14
+ simplecov (>= 0.7)
15
+ thor
5
16
  diff-lcs (1.1.3)
6
- method_source (0.8)
17
+ mime-types (1.21)
7
18
  multi_json (1.3.7)
8
19
  open4 (1.3.0)
9
- pry (0.9.10)
10
- coderay (~> 1.0.5)
11
- method_source (~> 0.8)
12
- slop (~> 3.3.1)
13
20
  rake (0.9.5)
21
+ redcarpet (2.2.2)
22
+ rest-client (1.6.7)
23
+ mime-types (>= 1.16)
24
+ ripper (1.0.5)
14
25
  rspec (2.12.0)
15
26
  rspec-core (~> 2.12.0)
16
27
  rspec-expectations (~> 2.12.0)
@@ -23,14 +34,19 @@ GEM
23
34
  multi_json (~> 1.0)
24
35
  simplecov-html (~> 0.7.1)
25
36
  simplecov-html (0.7.1)
26
- slop (3.3.2)
37
+ thor (0.18.0)
38
+ yard (0.8.5.2)
27
39
 
28
40
  PLATFORMS
29
41
  ruby
30
42
 
31
43
  DEPENDENCIES
44
+ coveralls
32
45
  open4 (~> 1.3)
33
- pry
34
46
  rake (~> 0.9)
47
+ redcarpet (~> 2.2)
48
+ ripper
35
49
  rspec (~> 2.11)
36
- simplecov (~> 0.6)
50
+ simplecov
51
+ taketo!
52
+ yard (~> 0.8.5)
data/README.md CHANGED
@@ -2,7 +2,8 @@ Take Me To
2
2
  ==========
3
3
 
4
4
  [![Build Status](https://secure.travis-ci.org/v-yarotsky/taketo.png)](http://travis-ci.org/v-yarotsky/taketo)
5
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/v-yarotsky/taketo)
5
+ [![Coverage Status](https://coveralls.io/repos/v-yarotsky/taketo/badge.png?branch=master)](https://coveralls.io/r/v-yarotsky/taketo)
6
+ [![Code Climate](https://codeclimate.com/github/v-yarotsky/taketo.png)](https://codeclimate.com/github/v-yarotsky/taketo)
6
7
  [![Gem Version](https://badge.fury.io/rb/taketo.png)](http://badge.fury.io/rb/taketo)
7
8
 
8
9
  A tiny helper utility to make access to servers easier for different projects and environments.
@@ -12,6 +13,7 @@ Taketo is known to work on:
12
13
  * ree 1.8.7
13
14
  * MRI 1.9.2
14
15
  * MRI 1.9.3
16
+ * MRI 2.0.0
15
17
 
16
18
  Important note:
17
19
  ---------------
data/Rakefile CHANGED
@@ -12,8 +12,11 @@ rescue Bundler::BundlerError => e
12
12
  end
13
13
 
14
14
  require 'rake'
15
- require 'rspec/core/rake_task'
16
15
 
16
+ require 'rake/clean'
17
+ CLOBBER.include('doc/**', 'pkg/**', 'coverage/**')
18
+
19
+ require 'rspec/core/rake_task'
17
20
  RSpec::Core::RakeTask.new do |t|
18
21
  t.pattern = 'spec/lib/**/*_spec.rb'
19
22
  end
@@ -26,5 +29,8 @@ RSpec::Core::RakeTask.new(:acceptance_spec) do |t|
26
29
  t.pattern = 'spec/acceptance/**/*_spec.rb'
27
30
  end
28
31
 
32
+ require 'yard'
33
+ YARD::Rake::YardocTask.new
34
+
29
35
  task :default => [:spec, :acceptance_spec]
30
36
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0.alpha
1
+ 0.2.0
data/bin/taketo CHANGED
@@ -37,8 +37,9 @@ def parse_options
37
37
  opts.separator "Special options:"
38
38
 
39
39
  opts.on("--dry-run", "Print out what would be run") { |v| options[:dry_run] = v }
40
- opts.on("--debug") { |v| options[:debug] = v }
41
40
  opts.on("--matches") { |v| options[:action] = :matches }
41
+ opts.on("--edit-config") { |v| options[:action] = :edit_config }
42
+ opts.on("--debug") { |v| options[:debug] = v }
42
43
  end.parse!
43
44
 
44
45
  options.merge!(:destination_path => ARGV.shift.to_s)
@@ -0,0 +1,16 @@
1
+ require 'taketo/actions/base_action'
2
+
3
+ module Taketo
4
+ module Actions
5
+
6
+ class EditConfig < BaseAction
7
+ def run
8
+ editor = ENV["EDITOR"]
9
+ system("#{editor} #{options[:config]}")
10
+ end
11
+ end
12
+
13
+ end
14
+ end
15
+
16
+
@@ -1,14 +1,11 @@
1
1
  require 'taketo/config_traverser'
2
2
  require 'taketo/ssh_config_generator_visitor'
3
3
  require 'taketo/actions/base_action'
4
- require 'taketo/actions/server_action'
5
4
 
6
5
  module Taketo
7
6
  module Actions
8
7
 
9
8
  class GenerateSshConfig < BaseAction
10
- include ServerAction
11
-
12
9
  def run
13
10
  traverser = ConfigTraverser.new(config)
14
11
  ssh_config_generator = SSHConfigGeneratorVisitor.new
@@ -1,15 +1,13 @@
1
1
  require 'taketo/group_list_visitor'
2
2
  require 'taketo/actions/base_action'
3
- require 'taketo/actions/group_action'
3
+ require 'taketo/group_resolver'
4
4
 
5
5
  module Taketo
6
6
  module Actions
7
7
 
8
8
  class List < BaseAction
9
- include GroupAction
10
-
11
9
  def run
12
- node = resolver.resolve
10
+ node = GroupResolver.new(config, destination_path).resolve
13
11
  traverser = ConfigTraverser.new(node)
14
12
  lister = GroupListVisitor.new
15
13
  traverser.visit_depth_first(lister)
@@ -1,15 +1,13 @@
1
1
  require 'taketo/commands/ssh_command'
2
2
  require 'taketo/actions/base_action'
3
- require 'taketo/actions/server_action'
3
+ require 'taketo/server_resolver'
4
4
 
5
5
  module Taketo
6
6
  module Actions
7
7
 
8
8
  class Login < BaseAction
9
- include ServerAction
10
-
11
9
  def run
12
- server = resolver.resolve
10
+ server = ServerResolver.new(config, destination_path).resolve
13
11
  server_command = remote_command(server)
14
12
  command_to_execute = Commands::SSHCommand.new(server).render(server_command.render(server, options))
15
13
  execute(command_to_execute)
@@ -1,8 +1,8 @@
1
1
  require 'taketo/destination_matcher'
2
2
  require 'taketo/actions/base_action'
3
- require 'taketo/actions/server_action'
4
- require 'taketo/actions/group_action'
5
- require 'taketo/actions/node_action'
3
+ require 'taketo/group_resolver'
4
+ require 'taketo/node_resolver'
5
+ require 'taketo/server_resolver'
6
6
 
7
7
  module Taketo
8
8
  module Actions
@@ -10,17 +10,17 @@ module Taketo
10
10
  class Matches < BaseAction
11
11
  def initialize(options)
12
12
  super
13
- if options[:list]
14
- self.extend(GroupAction)
13
+ @resolver = if options[:list]
14
+ GroupResolver
15
15
  elsif options[:view]
16
- self.extend(NodeAction)
16
+ NodeResolver
17
17
  else
18
- self.extend(ServerAction)
19
- end
18
+ ServerResolver
19
+ end.new(config, destination_path)
20
20
  end
21
21
 
22
22
  def run
23
- puts DestinationMatcher.new(resolver.nodes).matches.join(" ")
23
+ puts DestinationMatcher.new(@resolver.nodes).matches.join(" ")
24
24
  end
25
25
  end
26
26
 
@@ -1,17 +1,15 @@
1
1
  require 'taketo/config_traverser'
2
2
  require 'taketo/config_printer_visitor'
3
3
  require 'taketo/actions/base_action'
4
- require 'taketo/actions/node_action'
4
+ require 'taketo/node_resolver'
5
5
 
6
6
  module Taketo
7
7
  module Actions
8
8
 
9
9
  class View < BaseAction
10
- include NodeAction
11
-
12
10
  def run
13
11
  config.default_destination = nil
14
- node = resolver.resolve
12
+ node = NodeResolver.new(config, destination_path).resolve
15
13
  traverser = ConfigTraverser.new(node)
16
14
  config_printer = ConfigPrinterVisitor.new
17
15
  traverser.visit_depth_first(config_printer)
@@ -3,8 +3,10 @@ require 'taketo/actions/view'
3
3
  require 'taketo/actions/list'
4
4
  require 'taketo/actions/matches'
5
5
  require 'taketo/actions/generate_ssh_config'
6
+ require 'taketo/actions/edit_config'
6
7
 
7
8
  module Taketo
9
+
8
10
  module Actions
9
11
  def self.[](name)
10
12
  actions_map = {
@@ -12,10 +14,12 @@ module Taketo
12
14
  :view => View,
13
15
  :list => List,
14
16
  :matches => Matches,
15
- :generate_ssh_config => GenerateSshConfig
17
+ :generate_ssh_config => GenerateSshConfig,
18
+ :edit_config => EditConfig
16
19
  }
17
20
  actions_map.fetch(name) { Login }
18
21
  end
19
22
  end
23
+
20
24
  end
21
25
 
@@ -3,6 +3,7 @@ require 'shellwords'
3
3
 
4
4
  module Taketo
5
5
  module Commands
6
+
6
7
  class SSHCommand
7
8
  extend Forwardable
8
9
  include Shellwords
@@ -31,6 +32,7 @@ module Taketo
31
32
  %Q[-i #{shellescape @server.identity_file}] if @server.identity_file
32
33
  end
33
34
  end
35
+
34
36
  end
35
37
  end
36
38
 
@@ -2,6 +2,7 @@ require 'taketo/config_visitor'
2
2
  require 'taketo/printer'
3
3
 
4
4
  module Taketo
5
+
5
6
  class ConfigPrinterVisitor < ConfigVisitor
6
7
  include Printer
7
8
 
@@ -49,5 +50,6 @@ module Taketo
49
50
  indent(4) { put command.name.to_s + (" - " + command.description if command.description).to_s }
50
51
  end
51
52
  end
53
+
52
54
  end
53
55
 
@@ -2,6 +2,7 @@ require 'delegate'
2
2
  require 'forwardable'
3
3
 
4
4
  module Taketo
5
+
5
6
  class ConfigTraverser
6
7
  def initialize(root)
7
8
  @root = root
@@ -22,5 +23,6 @@ module Taketo
22
23
  end
23
24
  end
24
25
  end
26
+
25
27
  end
26
28
 
@@ -2,6 +2,7 @@ require 'taketo/config_traverser'
2
2
  require 'taketo/config_visitor'
3
3
 
4
4
  module Taketo
5
+
5
6
  class ConfigError < StandardError; end
6
7
 
7
8
  class ConfigValidatorVisitor < ConfigVisitor
@@ -3,6 +3,7 @@ require 'taketo/associated_nodes'
3
3
 
4
4
  module Taketo
5
5
  module Constructs
6
+
6
7
  class BaseConstruct
7
8
  include AssociatedNodes
8
9
 
@@ -3,6 +3,7 @@ require 'shellwords'
3
3
 
4
4
  module Taketo
5
5
  module Constructs
6
+
6
7
  class Command < BaseConstruct
7
8
  include Shellwords
8
9
 
@@ -35,6 +36,7 @@ module Taketo
35
36
  server.environment_variables.map { |k, v| %Q[#{k}=#{shellescape v}] }.join(" ")
36
37
  end
37
38
  end
39
+
38
40
  end
39
41
  end
40
42
 
@@ -3,6 +3,7 @@ require 'taketo/support'
3
3
 
4
4
  module Taketo
5
5
  module Constructs
6
+
6
7
  class Config < BaseConstruct
7
8
  has_nodes :groups, :group
8
9
  has_nodes :projects, :project
@@ -18,6 +19,7 @@ module Taketo
18
19
  has_deeply_nested_nodes?(:servers)
19
20
  end
20
21
  end
22
+
21
23
  end
22
24
  end
23
25
 
@@ -4,6 +4,7 @@ require 'taketo/support'
4
4
 
5
5
  module Taketo
6
6
  module Constructs
7
+
7
8
  class Environment < BaseConstruct
8
9
  has_nodes :servers, :server
9
10
  has_nodes :groups, :group
@@ -28,6 +29,7 @@ module Taketo
28
29
  has_deeply_nested_nodes?(:servers)
29
30
  end
30
31
  end
32
+
31
33
  end
32
34
  end
33
35
 
@@ -3,6 +3,7 @@ require 'taketo/support'
3
3
 
4
4
  module Taketo
5
5
  module Constructs
6
+
6
7
  class Group < BaseConstruct
7
8
  has_nodes :servers, :server
8
9
 
@@ -14,6 +15,7 @@ module Taketo
14
15
  has_deeply_nested_nodes?(:servers)
15
16
  end
16
17
  end
18
+
17
19
  end
18
20
  end
19
21
 
@@ -3,6 +3,7 @@ require 'taketo/support'
3
3
 
4
4
  module Taketo
5
5
  module Constructs
6
+
6
7
  class Project < BaseConstruct
7
8
  has_nodes :environments, :environment
8
9
  has_nodes :servers, :server
@@ -12,6 +13,7 @@ module Taketo
12
13
  has_deeply_nested_nodes?(:servers)
13
14
  end
14
15
  end
16
+
15
17
  end
16
18
  end
17
19
 
@@ -4,6 +4,7 @@ require 'taketo/support'
4
4
 
5
5
  module Taketo
6
6
  module Constructs
7
+
7
8
  class Server < BaseConstruct
8
9
  attr_reader :environment_variables
9
10
  attr_accessor :host, :port, :username, :default_location, :default_command, :global_alias, :identity_file
@@ -36,6 +37,7 @@ module Taketo
36
37
  end
37
38
  end
38
39
  end
40
+
39
41
  end
40
42
  end
41
43
 
@@ -1,8 +1,8 @@
1
1
  require 'taketo/constructs'
2
2
 
3
3
  module Taketo
4
- class ConstructsFactory
5
4
 
5
+ class ConstructsFactory
6
6
  def create(type, *args)
7
7
  send("create_#{type}", *args)
8
8
  end
@@ -31,5 +31,6 @@ module Taketo
31
31
  Constructs::Command.new(*args)
32
32
  end
33
33
  end
34
+
34
35
  end
35
36
 
@@ -1,4 +1,5 @@
1
1
  module Taketo
2
+
2
3
  class DestinationMatcher
3
4
  def initialize(nodes)
4
5
  @nodes = nodes
@@ -18,5 +19,6 @@ module Taketo
18
19
  @nodes.select { |n| n.respond_to?(:global_alias) }.map(&:global_alias).map(&:to_s).reject(&:empty?)
19
20
  end
20
21
  end
22
+
21
23
  end
22
24
 
data/lib/taketo/dsl.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'taketo/constructs_factory'
2
2
 
3
3
  module Taketo
4
+
4
5
  class DSL
5
6
  class ScopeError < StandardError; end
6
7
  class ConfigError < StandardError; end
@@ -130,5 +131,6 @@ module Taketo
130
131
  end
131
132
 
132
133
  end
134
+
133
135
  end
134
136
 
@@ -2,10 +2,12 @@ require 'taketo/config_visitor'
2
2
  require 'taketo/printer'
3
3
 
4
4
  module Taketo
5
+
5
6
  class GroupListVisitor < SimpleCollector(Constructs::Server)
6
7
  def result
7
8
  @result.map(&:path).join("\n")
8
9
  end
9
10
  end
11
+
10
12
  end
11
13
 
@@ -2,6 +2,7 @@ require 'taketo/config_visitor'
2
2
  require 'taketo/config_traverser'
3
3
 
4
4
  module Taketo
5
+
5
6
  class AmbiguousDestinationError < StandardError; end
6
7
  class NonExistentDestinationError < StandardError; end
7
8
 
@@ -45,6 +46,7 @@ module Taketo
45
46
  end
46
47
  end
47
48
  end
49
+
48
50
  end
49
51
 
50
52
 
@@ -1,4 +1,5 @@
1
1
  module Taketo
2
+
2
3
  module Printer
3
4
  def initialize
4
5
  @indent_level = 0
@@ -25,5 +26,6 @@ module Taketo
25
26
  put "#{str} #{value}" if value
26
27
  end
27
28
  end
29
+
28
30
  end
29
31
 
@@ -2,6 +2,7 @@ require 'taketo/config_visitor'
2
2
  require 'taketo/printer'
3
3
 
4
4
  module Taketo
5
+
5
6
  class SSHConfigGeneratorVisitor < ConfigVisitor
6
7
  include Printer
7
8
 
@@ -19,4 +20,5 @@ module Taketo
19
20
  put
20
21
  end
21
22
  end
23
+
22
24
  end
@@ -0,0 +1,44 @@
1
+ module Taketo
2
+ module Support
3
+
4
+ module Inflections
5
+ extend self
6
+
7
+ def to_singular(thing)
8
+ str = name(thing)
9
+ str.chop! if plural?(str)
10
+ str.to_sym
11
+ end
12
+
13
+ def to_plural(thing)
14
+ str = name(thing)
15
+ str << "s" unless plural?(str)
16
+ str.to_sym
17
+ end
18
+
19
+ def to_class(thing, nesting = Module.nesting.first || Object)
20
+ nesting.const_get(class_name_from_string(to_singular(thing)))
21
+ end
22
+
23
+ private
24
+
25
+ def name(thing)
26
+ thing.is_a?(Class) ? name_from_class(thing) : thing.to_s
27
+ end
28
+
29
+ def name_from_class(klass)
30
+ klass.name.gsub(/[A-Za-z0-9]+::/, "").gsub(/[A-Z][^A-Z]*/) { |s| s.gsub("::", "").downcase + "_" }.chop
31
+ end
32
+
33
+ def class_name_from_string(singular)
34
+ singular.to_s.gsub(/(^|_)\w/) { |s| s.gsub(/_/, "").capitalize }
35
+ end
36
+
37
+ def plural?(str)
38
+ str =~ /s$/
39
+ end
40
+ end
41
+
42
+ end
43
+ end
44
+
@@ -3,6 +3,7 @@ require 'taketo/support'
3
3
 
4
4
  module Taketo
5
5
  module Support
6
+
6
7
  class NamedNodesCollection
7
8
  include Enumerable
8
9
  extend Forwardable
@@ -37,9 +38,10 @@ module Taketo
37
38
  end
38
39
 
39
40
  protected
40
-
41
+
41
42
  attr_reader :nodes
42
43
  end
44
+
43
45
  end
44
46
  end
45
47
 
@@ -3,6 +3,7 @@ module Taketo
3
3
  end
4
4
  end
5
5
 
6
+ require 'taketo/support/inflections'
6
7
  require 'taketo/support/named_nodes_collection'
7
8
  require 'taketo/support/key_error'
8
9
 
@@ -0,0 +1,36 @@
1
+ #compdef taketo
2
+
3
+ typeset curcontext state line cmds ret
4
+
5
+ curcontext="$curcontext"
6
+ ret=1
7
+
8
+ _taketo() {
9
+ _arguments -C \
10
+ '(--command)--command[Command to execute on destination server]' \
11
+ '(--directory)--directory[Directory on destination server to cd to]' \
12
+ '(--config)--config[Use custom config file]' \
13
+ '(--view)--view[Show config contents in a tree form]' \
14
+ '(--list)--list[List scopes]' \
15
+ '(--dry-run)--dry-run[Print out what would be run]' \
16
+ '(--generate-ssh-config)--generate-ssh-config[Generate SSH config from taketo config]' \
17
+ '(--version)--version[Display taketo version and exit]' \
18
+ '1: :->dest' && ret=0
19
+
20
+ _taketo_destinations() {
21
+ matching_destinations=(`taketo --matches $@ 2> /dev/null`)
22
+ }
23
+
24
+ local -a matching_destinations
25
+ local expl
26
+
27
+ case $state in
28
+ dest)
29
+ _taketo_destinations
30
+ _wanted matching_destinations expl 'all matching destinations' _multi_parts -i : matching_destinations
31
+ ;;
32
+ esac
33
+ }
34
+
35
+ _taketo "$@"
36
+
@@ -0,0 +1,12 @@
1
+ require 'acceptance_spec_helper'
2
+
3
+ feature "Edit taketo config" do
4
+ scenario "Open config in editor" do
5
+ run "EDITOR='echo editing' taketo --edit-config"
6
+ stdout.should =~ /editing.*taketo.*/
7
+ stderr.should be_empty
8
+ exit_status.should be_success
9
+ end
10
+ end
11
+
12
+
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+ require 'taketo/support/inflections'
3
+
4
+ include Taketo::Support
5
+
6
+ describe "Inflections" do
7
+ module Nest1
8
+ module Nest2
9
+ class Thing; end
10
+ end
11
+ end
12
+
13
+ describe "#to_singular" do
14
+ it "returns singularized sumbol for klass" do
15
+ expect(Inflections.to_singular(Nest1::Nest2::Thing)).to eq(:thing)
16
+ end
17
+
18
+ it "returns singularized sumbol for pluralized symbol" do
19
+ expect(Inflections.to_singular(:things)).to eq(:thing)
20
+ end
21
+ end
22
+
23
+ describe "#to_plural" do
24
+ it "returns pluralized sumbol for klass" do
25
+ expect(Inflections.to_plural(Nest1::Nest2::Thing)).to eq(:things)
26
+ end
27
+
28
+ it "returns pluralized sumbol for singularized symbol" do
29
+ expect(Inflections.to_plural(:thing)).to eq(:things)
30
+ end
31
+ end
32
+
33
+ describe "#to_class" do
34
+ it "returns klass by pluralized symbol" do
35
+ expect(Inflections.to_class(:things, Nest1::Nest2)).to eq(Nest1::Nest2::Thing)
36
+ end
37
+
38
+ it "returns klass by singularized symbol" do
39
+ expect(Inflections.to_class(:thing, Nest1::Nest2)).to eq(Nest1::Nest2::Thing)
40
+ end
41
+ end
42
+ end
43
+
44
+
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,9 @@ if ENV['COVERAGE']
10
10
  f.lines.count < 5
11
11
  end
12
12
  end
13
+ elsif ENV["TRAVIS"]
14
+ require 'coveralls'
15
+ Coveralls.wear!
13
16
  end
14
17
 
15
18
  require 'rspec'
data/taketo.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ $:.unshift File.expand_path('../lib/', __FILE__)
4
+
5
+ require 'taketo'
6
+ require 'date'
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = "taketo"
10
+ s.summary = "A tiny helper utility to make access to servers eaiser " \
11
+ "for different projects and environments"
12
+ s.description = <<-DESC
13
+ Taketo is an utility to aid quick access to often used servers for web-developers.
14
+ Taketo uses a config written in ruby using light DSL.
15
+ See http://github.com/v-yarotsky/taketo for additional instructions
16
+ DESC
17
+
18
+ s.version = Taketo::VERSION.dup
19
+ s.authors = ["Vladimir Yarotsky"]
20
+ s.date = Date.today.to_s
21
+ s.email = "vladimir.yarotksy@gmail.com"
22
+ s.homepage = "http://github.com/v-yarotsky/taketo"
23
+ s.licenses = ["MIT"]
24
+
25
+ s.rubygems_version = "1.8.21"
26
+ s.required_rubygems_version = ">= 1.3.6"
27
+ s.specification_version = 3
28
+
29
+ s.files = `git ls-files`.split($/)
30
+ s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
31
+ s.test_files = s.files.grep(%r{^(spec)/})
32
+ s.require_paths = ["lib"]
33
+ s.extra_rdoc_files = %w[LICENSE.txt README.md]
34
+
35
+ s.add_development_dependency("rspec", "~> 2.11")
36
+ s.add_development_dependency("rake", "~> 0.9")
37
+ s.add_development_dependency("simplecov", "~> 0.6")
38
+ s.add_development_dependency("open4", "~> 1.3")
39
+ end
40
+
41
+
metadata CHANGED
@@ -1,107 +1,110 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taketo
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 0.2.0.alpha
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Vladimir Yarotsky
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-11 00:00:00.000000000 Z
11
+ date: 2013-04-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
19
  version: '2.11'
22
20
  type: :development
21
+ prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
- none: false
25
23
  requirements:
26
24
  - - ~>
27
25
  - !ruby/object:Gem::Version
28
26
  version: '2.11'
29
- prerelease: false
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0.9'
38
34
  type: :development
35
+ prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
- none: false
41
37
  requirements:
42
38
  - - ~>
43
39
  - !ruby/object:Gem::Version
44
40
  version: '0.9'
45
- prerelease: false
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: simplecov
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0.6'
54
48
  type: :development
49
+ prerelease: false
55
50
  version_requirements: !ruby/object:Gem::Requirement
56
- none: false
57
51
  requirements:
58
52
  - - ~>
59
53
  - !ruby/object:Gem::Version
60
54
  version: '0.6'
61
- prerelease: false
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: open4
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
69
61
  version: '1.3'
70
62
  type: :development
63
+ prerelease: false
71
64
  version_requirements: !ruby/object:Gem::Requirement
72
- none: false
73
65
  requirements:
74
66
  - - ~>
75
67
  - !ruby/object:Gem::Version
76
68
  version: '1.3'
77
- prerelease: false
78
- description: ! " Taketo is an utility to aid quick access to often used servers
79
- for web-developers.\n Taketo uses a config written in ruby using light DSL.\n
80
- \ See http://github.com/v-yarotsky/taketo for additional instructions\n"
69
+ description: |2
70
+ Taketo is an utility to aid quick access to often used servers for web-developers.
71
+ Taketo uses a config written in ruby using light DSL.
72
+ See http://github.com/v-yarotsky/taketo for additional instructions
81
73
  email: vladimir.yarotksy@gmail.com
82
74
  executables:
83
75
  - taketo
84
76
  extensions: []
85
- extra_rdoc_files: []
77
+ extra_rdoc_files:
78
+ - LICENSE.txt
79
+ - README.md
86
80
  files:
81
+ - .gitignore
82
+ - .travis.yml
83
+ - .yardopts
84
+ - Gemfile
85
+ - Gemfile.lock
86
+ - LICENSE.txt
87
+ - README.md
88
+ - Rakefile
89
+ - VERSION
87
90
  - bin/taketo
91
+ - lib/taketo.rb
92
+ - lib/taketo/actions.rb
88
93
  - lib/taketo/actions/base_action.rb
94
+ - lib/taketo/actions/edit_config.rb
89
95
  - lib/taketo/actions/generate_ssh_config.rb
90
- - lib/taketo/actions/group_action.rb
91
96
  - lib/taketo/actions/list.rb
92
97
  - lib/taketo/actions/login.rb
93
98
  - lib/taketo/actions/matches.rb
94
- - lib/taketo/actions/node_action.rb
95
- - lib/taketo/actions/server_action.rb
96
99
  - lib/taketo/actions/view.rb
97
- - lib/taketo/actions.rb
98
100
  - lib/taketo/associated_nodes.rb
99
- - lib/taketo/commands/ssh_command.rb
100
101
  - lib/taketo/commands.rb
102
+ - lib/taketo/commands/ssh_command.rb
101
103
  - lib/taketo/config_printer_visitor.rb
102
104
  - lib/taketo/config_traverser.rb
103
105
  - lib/taketo/config_validator.rb
104
106
  - lib/taketo/config_visitor.rb
107
+ - lib/taketo/constructs.rb
105
108
  - lib/taketo/constructs/base_construct.rb
106
109
  - lib/taketo/constructs/command.rb
107
110
  - lib/taketo/constructs/config.rb
@@ -109,7 +112,6 @@ files:
109
112
  - lib/taketo/constructs/group.rb
110
113
  - lib/taketo/constructs/project.rb
111
114
  - lib/taketo/constructs/server.rb
112
- - lib/taketo/constructs.rb
113
115
  - lib/taketo/constructs_factory.rb
114
116
  - lib/taketo/destination_matcher.rb
115
117
  - lib/taketo/dsl.rb
@@ -119,15 +121,17 @@ files:
119
121
  - lib/taketo/printer.rb
120
122
  - lib/taketo/server_resolver.rb
121
123
  - lib/taketo/ssh_config_generator_visitor.rb
124
+ - lib/taketo/support.rb
125
+ - lib/taketo/support/inflections.rb
122
126
  - lib/taketo/support/key_error.rb
123
127
  - lib/taketo/support/named_nodes_collection.rb
124
- - lib/taketo/support.rb
125
- - lib/taketo.rb
128
+ - scripts/zsh/completion/_taketo
126
129
  - spec/acceptance/command_spec.rb
127
130
  - spec/acceptance/completion_spec.rb
128
131
  - spec/acceptance/config_dsl_spec.rb
129
132
  - spec/acceptance/config_validation_spec.rb
130
133
  - spec/acceptance/connect_to_server_spec.rb
134
+ - spec/acceptance/edit_config_spec.rb
131
135
  - spec/acceptance/error_handling_spec.rb
132
136
  - spec/acceptance/generate_ssh_config_spec.rb
133
137
  - spec/acceptance/help_spec.rb
@@ -155,6 +159,7 @@ files:
155
159
  - spec/lib/taketo/group_resolver_spec.rb
156
160
  - spec/lib/taketo/server_resolver_spec.rb
157
161
  - spec/lib/taketo/ssh_config_generator_visitor_spec.rb
162
+ - spec/lib/taketo/support/inflections_spec.rb
158
163
  - spec/lib/taketo/support/named_nodes_collection_spec.rb
159
164
  - spec/spec_helper.rb
160
165
  - spec/support/helpers/construct_spec_helper.rb
@@ -162,39 +167,72 @@ files:
162
167
  - spec/support/matchers/be_appropriate_construct_matcher.rb
163
168
  - spec/support/matchers/enclose_scope_matcher.rb
164
169
  - spec/support/matchers/have_accessor_matcher.rb
165
- - Gemfile
166
- - Gemfile.lock
167
- - Rakefile
168
- - LICENSE.txt
169
- - README.md
170
- - VERSION
170
+ - taketo.gemspec
171
171
  homepage: http://github.com/v-yarotsky/taketo
172
172
  licenses:
173
173
  - MIT
174
+ metadata: {}
174
175
  post_install_message:
175
176
  rdoc_options: []
176
177
  require_paths:
177
178
  - lib
178
179
  required_ruby_version: !ruby/object:Gem::Requirement
179
- none: false
180
180
  requirements:
181
- - - ! '>='
181
+ - - '>='
182
182
  - !ruby/object:Gem::Version
183
- segments:
184
- - 0
185
- hash: -2702655235104001250
186
183
  version: '0'
187
184
  required_rubygems_version: !ruby/object:Gem::Requirement
188
- none: false
189
185
  requirements:
190
- - - ! '>='
186
+ - - '>='
191
187
  - !ruby/object:Gem::Version
192
188
  version: 1.3.6
193
189
  requirements: []
194
190
  rubyforge_project:
195
- rubygems_version: 1.8.25
191
+ rubygems_version: 2.0.3
196
192
  signing_key:
197
193
  specification_version: 3
198
194
  summary: A tiny helper utility to make access to servers eaiser for different projects
199
195
  and environments
200
- test_files: []
196
+ test_files:
197
+ - spec/acceptance/command_spec.rb
198
+ - spec/acceptance/completion_spec.rb
199
+ - spec/acceptance/config_dsl_spec.rb
200
+ - spec/acceptance/config_validation_spec.rb
201
+ - spec/acceptance/connect_to_server_spec.rb
202
+ - spec/acceptance/edit_config_spec.rb
203
+ - spec/acceptance/error_handling_spec.rb
204
+ - spec/acceptance/generate_ssh_config_spec.rb
205
+ - spec/acceptance/help_spec.rb
206
+ - spec/acceptance/location_spec.rb
207
+ - spec/acceptance_spec_helper.rb
208
+ - spec/integration/dsl_integration_spec.rb
209
+ - spec/lib/taketo/actions_spec.rb
210
+ - spec/lib/taketo/associated_nodes_spec.rb
211
+ - spec/lib/taketo/commands/ssh_command_spec.rb
212
+ - spec/lib/taketo/config_printer_visitor_spec.rb
213
+ - spec/lib/taketo/config_traverser_spec.rb
214
+ - spec/lib/taketo/config_validator_spec.rb
215
+ - spec/lib/taketo/config_visitor_spec.rb
216
+ - spec/lib/taketo/constructs/base_construct_spec.rb
217
+ - spec/lib/taketo/constructs/command_spec.rb
218
+ - spec/lib/taketo/constructs/config_spec.rb
219
+ - spec/lib/taketo/constructs/environment_spec.rb
220
+ - spec/lib/taketo/constructs/group_spec.rb
221
+ - spec/lib/taketo/constructs/project_spec.rb
222
+ - spec/lib/taketo/constructs/server_spec.rb
223
+ - spec/lib/taketo/constructs_factory_spec.rb
224
+ - spec/lib/taketo/destination_matcher_spec.rb
225
+ - spec/lib/taketo/dsl_spec.rb
226
+ - spec/lib/taketo/group_list_visitor_spec.rb
227
+ - spec/lib/taketo/group_resolver_spec.rb
228
+ - spec/lib/taketo/server_resolver_spec.rb
229
+ - spec/lib/taketo/ssh_config_generator_visitor_spec.rb
230
+ - spec/lib/taketo/support/inflections_spec.rb
231
+ - spec/lib/taketo/support/named_nodes_collection_spec.rb
232
+ - spec/spec_helper.rb
233
+ - spec/support/helpers/construct_spec_helper.rb
234
+ - spec/support/helpers/dsl_spec_helper.rb
235
+ - spec/support/matchers/be_appropriate_construct_matcher.rb
236
+ - spec/support/matchers/enclose_scope_matcher.rb
237
+ - spec/support/matchers/have_accessor_matcher.rb
238
+ has_rdoc:
@@ -1,15 +0,0 @@
1
- require 'taketo/group_resolver'
2
-
3
- module Taketo
4
- module Actions
5
-
6
- module GroupAction
7
- def resolver
8
- @resolver ||= GroupResolver.new(config, destination_path)
9
- end
10
- end
11
-
12
- end
13
- end
14
-
15
-
@@ -1,15 +0,0 @@
1
- require 'taketo/node_resolver'
2
-
3
- module Taketo
4
- module Actions
5
-
6
- module NodeAction
7
- def resolver
8
- @resolver ||= NodeResolver.new(config, destination_path)
9
- end
10
- end
11
-
12
- end
13
- end
14
-
15
-
@@ -1,14 +0,0 @@
1
- require 'taketo/server_resolver'
2
-
3
- module Taketo
4
- module Actions
5
-
6
- module ServerAction
7
- def resolver
8
- @resolver ||= ServerResolver.new(config, destination_path)
9
- end
10
- end
11
-
12
- end
13
- end
14
-