lab42_tmux 0.0.3 → 0.0.4.pre3

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
2
  SHA1:
3
- metadata.gz: 8dc676118065197a5cd977d51690037f3814d2c2
4
- data.tar.gz: c7584c2f8d3be9c1a02761224d79377b412f6ef0
3
+ metadata.gz: 6ba9d96a010dc633384c98629f67e150f289b368
4
+ data.tar.gz: 8951194e595d6c14f357256bac53bba639687b75
5
5
  SHA512:
6
- metadata.gz: 61a8732386b3395e170c04043ba50ff8149e4f666f75729c8cc65236744e6e1cd13a40ea85b36f2f9dff89ac12a41634a50e40494ebf27546b87e91925ca0291
7
- data.tar.gz: 39f97a1ab9130d792766aa1f9d43551503504fa91ed15507d98e0cdc02e83bc9896c9089641db821208895a72a0af482bbdaddf453602e9fc688cb2d190274d4
6
+ metadata.gz: 756ec301f52d12920e0ceadae872ec36ace0de8085dca27d7c24be0612e23751aa23f9dfc65ee4375d73f4f34f97cfc75d85ac9e3db18156f84fc4c728f785d0
7
+ data.tar.gz: 91305be52449905cb816565d923681554ac1a407ec8fe9072779bb47d94c02eb56f43c026b23b2394df0a8b61a19d5581d9f2d84af0df58937ae123e981d30b6
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Tmux
4
4
 
5
+ Read [Release Notes](RELEASE.md) for information concerning a specific version.
6
+
5
7
  ### Predefined Scripts
6
8
 
7
9
  #### lab42\_tmux
@@ -30,3 +32,8 @@ Opens a tmux session with the following windows
30
32
 
31
33
  If a session with the basename of `some_path` exists will attach to it. Otherwise
32
34
  will open a session with that name and n *additional* windows, each window will be cwed into `some_path.
35
+
36
+
37
+ #### lab42\_ruby\_session
38
+
39
+ ...
data/bin/lab42_nodejs ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'lab42/tmux/predefined/nodejs'
3
+
4
+ Lab42::Tmux::Predefined::NodeJS.new( *ARGV.dup ).exec!
@@ -0,0 +1,13 @@
1
+ module Enumerable
2
+ alias_method :__original_map__, :map
3
+ def map behavior=nil,&blk
4
+ __original_map__(&(behavior||blk))
5
+ end
6
+ end
7
+
8
+ class Array
9
+ alias_method :__original_map__, :map
10
+ def map behavior=nil,&blk
11
+ __original_map__(&(behavior||blk))
12
+ end
13
+ end
@@ -0,0 +1,55 @@
1
+ class File
2
+ class << self
3
+ # TODO: Get rid of this and use expand_path
4
+ alias_method :__orig_absolute_path__, :absolute_path
5
+ def absolute_path fn
6
+ if %r{\A~} === fn && home = ENV["HOME"]
7
+ File.join home, fn.sub(%r{\A~#{File::Separator}},"")
8
+ else
9
+ __orig_absolute_path__ fn
10
+ end
11
+ end
12
+ end
13
+
14
+ module YAML extend self
15
+ def exists? fn, search_path: []
16
+ exists_as_specified?( fn ) ||
17
+ exists_in_search_path?( fn, search_path: search_path )
18
+ end
19
+
20
+ def exists_as_specified? fn
21
+ # remove extension without preceding .
22
+ f = fn.sub %r{(?<=\.)[^.]*\z}, ""
23
+ if f != fn
24
+ check_for( fn )
25
+ else
26
+ %w{yaml yml}.inject false do |fnorf, ext|
27
+ fnorf || check_for( "#{f}.#{ext}" )
28
+ end
29
+ end
30
+ end
31
+
32
+ def exists_in_search_path? fn, search_path: required
33
+ # remove extension without preceding .
34
+ f = fn.sub %r{(?<=\.)[^.]*\z}, ""
35
+ if f != fn
36
+ Array( search_path ).inject false do |false_or_file, sp|
37
+ false_or_file || check_for( File.join(sp, fn) )
38
+ end
39
+ else
40
+ Array( search_path ).inject false do |false_or_file, sp|
41
+ false_or_file or %w{yaml yml}.inject false do |fnorf, ext|
42
+ fnorf ||
43
+ check_for( File.join(sp, "#{f}.#{ext}") )
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ private
50
+ # Maybe rename to file_exists_and_name ???
51
+ def check_for fn
52
+ File.readable?( fn ) && fn
53
+ end
54
+ end
55
+ end
@@ -7,4 +7,20 @@ class Object
7
7
  blk.( val )
8
8
  rescue NoMethodError
9
9
  end
10
+
11
+ # TODO: This shall go into lab42_core
12
+ def fn
13
+ return @__fn__ if @__fn__
14
+ myself = self
15
+ @__fn__ = BasicObject.new
16
+ class << @__fn__; self end
17
+ .module_eval do
18
+ alias_method :__original_method_missing__, :method_missing
19
+ define_method :method_missing do |*args,&blk|
20
+ super unless blk.nil? && args.size == 1
21
+ # TODO: Catch error and call origianl method for better Error Messages
22
+ myself.method args.first.to_sym
23
+ end
24
+ end
25
+ end
10
26
  end
@@ -0,0 +1,42 @@
1
+ require 'lab42/tmux/predefined/abstract_session'
2
+ require 'forwarder'
3
+
4
+ module Lab42
5
+ class Tmux
6
+ module Predefined
7
+ class NodeJS
8
+ include AbstractSession
9
+
10
+ private
11
+ def initialize *args, &blk
12
+ @tmux = Lab42::Tmux.new args do
13
+ add_window "repl", command: options.fetch(:repl,"node")
14
+ add_window "vi", command: "vi ."
15
+ # require 'pry'
16
+ # binding.pry
17
+ if_dir "src" do
18
+ add_window "src", command: "vi src" do
19
+ vim_command "colorscheme morning"
20
+ end
21
+ end
22
+ if_dir "spec" do
23
+ add_window "spec", command: "vi spec" do
24
+ vim_commands "colorscheme solarized", background: "light"
25
+ end
26
+ end
27
+ if_dir "features" do
28
+ add_window "features", command: "vi features"
29
+ add_window "cucu"
30
+ end
31
+ add_window "sh"
32
+ # TODO: Specify this later if needed
33
+ # instance_eval_or_call blk if blk
34
+ if options[:rails_server]
35
+ add_window "server", command: "bundle exec rails server"
36
+ end
37
+ end
38
+ end
39
+ end # class NodeJS
40
+ end # module Predefined
41
+ end # class Tmux
42
+ end # module Lab42
@@ -1,5 +1,5 @@
1
1
  module Lab42
2
2
  class Tmux
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4.pre3"
4
4
  end
5
5
  end
data/lib/lab42/tmux.rb CHANGED
@@ -3,6 +3,8 @@ require 'lab42/tmux/core_helpers'
3
3
  require 'lab42/tmux/commands'
4
4
  require 'lab42/tmux/command'
5
5
  require 'lab42/tmux/window'
6
+ require 'lab42/tmux/extensions/enumerable'
7
+ require 'lab42/tmux/extensions/file'
6
8
  require 'lab42/tmux/extensions/ostruct'
7
9
  require 'lab42/tmux/extensions/hash'
8
10
  require 'lab42/tmux/extensions/object'
@@ -14,7 +16,7 @@ module Lab42
14
16
  include Command
15
17
  include Helpers
16
18
 
17
- attr_reader :commands, :options, :project_home, :session_name, :windows
19
+ attr_reader :commands, :options, :project_home, :session_name, :windows, :yaml_file_name
18
20
 
19
21
  def add_window name=nil, options={}, &blk
20
22
  window = Window.new windows.size.succ, self, name: name, command: options[:command]
@@ -40,21 +42,31 @@ module Lab42
40
42
 
41
43
  private
42
44
  def initialize args, &blk
43
- @options = Lab42::Options.new.parse( *args.dup )
45
+ version! args.first
46
+ @options = Lab42::Options.new
47
+ yaml_or_project_home args.first
48
+ @options = @options.parse( *args.dup )
44
49
  @commands = []
45
50
  @windows = []
46
- process_options
51
+ set_basic_ivars
47
52
  raise ArgumentError, "unable to determine session name" unless session_name
48
- raise ArgumentError, "no such directory #{project_home}" unless project_home && File.directory?( project_home )
49
53
  session_commands
50
54
  instance_eval_or_call blk
51
55
  end
52
56
 
53
- def process_options
54
- @project_home = options.args.first
55
- @project_home = File.join Dir.pwd, @project_home unless
56
- !@project_home || %r{\A[/~]} === @project_home
57
- @session_name = File.basename project_home rescue nil
57
+ def yaml_or_project_home fn
58
+ f = File.absolute_path fn
59
+ if @yaml_file_name = File::YAML.exists?( f )
60
+ @options.read_from @yaml_file_name
61
+ else
62
+ if File.directory? f
63
+ @project_home = f
64
+ else
65
+ @yaml_file_name = File::YAML.exists?( fn,search_path: File.join(ENV["HOME"],".lab42_tmux","yaml_files"))
66
+ raise ArgumentError, "#{fn} is neither a yaml file nor a directory (yaml files are looked for with an added .yaml or .yml extension)" unless @yaml_file_name
67
+ @options.read_from @yaml_file_name
68
+ end
69
+ end
58
70
  end
59
71
 
60
72
  def final_attach_command
@@ -63,6 +75,12 @@ module Lab42
63
75
  ]
64
76
  end
65
77
 
78
+ def set_basic_ivars
79
+ @session_name = @options.fetch :session_name, nil
80
+ @project_home ||= @options.fetch :project_home, nil
81
+ @session_name ||= File.basename project_home rescue nil
82
+ end
83
+
66
84
  def session_commands
67
85
  return if session_exists?
68
86
  tmux_new_session
@@ -74,5 +92,13 @@ module Lab42
74
92
  system "tmux has-session -t #{session_name}"
75
93
  $?.to_i.zero?
76
94
  end
95
+
96
+ def version! arg
97
+ require 'lab42/tmux/version'
98
+ if %r{\A(?::|--)version\z} === arg
99
+ puts Lab42::Tmux::VERSION
100
+ exit -1
101
+ end
102
+ end
77
103
  end
78
104
  end # module Lab42
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lab42_tmux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-17 00:00:00.000000000 Z
11
+ date: 2013-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lab42_options
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.0
19
+ version: 0.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.0
26
+ version: 0.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: forwarder19
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +99,7 @@ description: A Gem that will give us helpers to dry up the creation of TMUX wind
99
99
  usage of this gem
100
100
  email: robert.dober@gmail.com
101
101
  executables:
102
+ - lab42_nodejs
102
103
  - lab42_tmux
103
104
  - lab42_ruby_session
104
105
  extensions: []
@@ -107,12 +108,15 @@ files:
107
108
  - lib/lab42/tmux.rb
108
109
  - lib/lab42/tmux/core_helpers.rb
109
110
  - lib/lab42/tmux/current_window.rb
111
+ - lib/lab42/tmux/extensions/enumerable.rb
112
+ - lib/lab42/tmux/extensions/file.rb
110
113
  - lib/lab42/tmux/extensions/ostruct.rb
111
114
  - lib/lab42/tmux/extensions/object.rb
112
115
  - lib/lab42/tmux/extensions/hash.rb
113
116
  - lib/lab42/tmux/options.rb
114
117
  - lib/lab42/tmux/helpers.rb
115
118
  - lib/lab42/tmux/version.rb
119
+ - lib/lab42/tmux/predefined/nodejs.rb
116
120
  - lib/lab42/tmux/predefined/tmux_session.rb
117
121
  - lib/lab42/tmux/predefined/abstract_session.rb
118
122
  - lib/lab42/tmux/predefined/ruby_session.rb
@@ -123,6 +127,7 @@ files:
123
127
  - lib/lab42/tmux/window.rb
124
128
  - LICENSE
125
129
  - README.md
130
+ - bin/lab42_nodejs
126
131
  - bin/lab42_tmux
127
132
  - bin/lab42_ruby_session
128
133
  homepage: https://github.com/RobertDober/lab42_tmux
@@ -140,12 +145,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
145
  version: 2.0.0
141
146
  required_rubygems_version: !ruby/object:Gem::Requirement
142
147
  requirements:
143
- - - '>='
148
+ - - '>'
144
149
  - !ruby/object:Gem::Version
145
- version: '0'
150
+ version: 1.3.1
146
151
  requirements: []
147
152
  rubyforge_project:
148
- rubygems_version: 2.0.3
153
+ rubygems_version: 2.1.0
149
154
  signing_key:
150
155
  specification_version: 4
151
156
  summary: Creating Tmux Windows And Panes Without Pains