darky 0.0.0.1

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.
@@ -0,0 +1,53 @@
1
+ # Darky
2
+ yet another shell wrapper....
3
+
4
+ ## Syntax
5
+ ```ruby
6
+ # Block
7
+ Darky.new do |shell|
8
+ shell['/usr/local'] do
9
+ shell.exec "pwd" # "/usr/local"
10
+ end
11
+ shell.exec "pwd" # "/home/shuki"
12
+
13
+ shell = shell['/usr/local']
14
+ shell.exec "pwd" # "/usr/local"
15
+
16
+ shell.chdir "/tmp" do
17
+ shell.exec "pwd" # "/tmp"
18
+ end
19
+ shell.exec "pwd" # "/usr/local"
20
+
21
+ shell.chdir! "/tmp"
22
+ shell.exec "pwd" # "/tmp"
23
+ end
24
+
25
+ # Instance
26
+ shell = Darky.new(:dir => '/tmp')
27
+ shell.exec "pwd" # /tmp
28
+
29
+ # By using shell.async, you can make calls asynchronously.
30
+ obj = shell.async.ln_lrth # run `ls -lrth`
31
+ obj.on_success { |resp| STDOUT.puts resp.out }
32
+ obj.on_failure { |resp| STDOUT.puts response.err }
33
+
34
+ ```
35
+ ## TODO
36
+ - use send method to send commands + think about arguments
37
+ - can be included to any class
38
+ - support environment variables (sticky or non-sticky)
39
+ - support eventmachine
40
+ - support threads
41
+ - support celluloid.io
42
+ - support threads
43
+ - support callbacks success, failure, or just .callback
44
+ - exec without fork
45
+ - support sudo prompt
46
+ - exceptions - failure, permission denied
47
+ - internal / external logger
48
+ - logger should support filters, like ignore /shuki.*/
49
+ - open4/3
50
+ - timeout + handler
51
+ - kill when using proxy object
52
+ - save the state when using custom client
53
+ - can be included into class - to describe a service
@@ -0,0 +1,6 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), 'lib')
2
+ Dir.chdir File.dirname __FILE__
3
+
4
+ require 'darky'
5
+
6
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
@@ -0,0 +1,12 @@
1
+ module Darky
2
+
3
+ autoload :Adapter, "darky/adapter"
4
+ autoload :Client, "darky/cilent"
5
+
6
+ # lib dir should be in path, our Adapter depends on it...
7
+ # it could happen when we load the libary manualy (e.g w/o using rubygems)
8
+ File.expand_path("..", __FILE__).tap do |lib|
9
+ $:.include? lib or $:.unshift lib
10
+ end
11
+
12
+ end
@@ -0,0 +1,29 @@
1
+ module Darky
2
+ class Adapter
3
+ class << self
4
+
5
+ def find adapter
6
+ fetch(adapter).send :new
7
+ end
8
+
9
+ private
10
+
11
+ def fetch adapter
12
+ load fileize adapter and constantize adapter
13
+ end
14
+
15
+ def constantize adapter
16
+ const_get camelize adapter
17
+ end
18
+
19
+ def camelize adapter
20
+ String(adapter).split(%r _ ).map(&:capitalize).join
21
+ end
22
+
23
+ def fileize adapter
24
+ "darky/adapters/#{adapter}.rb"
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ module Darky
2
+ class Adapter
3
+ class Backticks
4
+
5
+ def exec command
6
+ %x command
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module Darky
2
+ class Client
3
+
4
+ def initialize adapter = :backticks
5
+ @adapter = Adapter.find adapter
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,26 @@
1
+ require 'rubygems/package_task'
2
+
3
+ Darky::GemSpec = Gem::Specification.new do |s|
4
+ s.name = "darky"
5
+ s.version = "0.0.0.1"
6
+ s.platform = Gem::Platform::RUBY
7
+ s.summary = "Yet another shell wrapper"
8
+ s.description = "Darky is a smart a flexible shell wrapper that aims for simplicity and packed with all the syntactic sugar you need"
9
+ s.author = "Eran Barak Levi"
10
+ s.email = 'eran@kontera.com'
11
+ s.homepage = 'http://www.darky-the-wrapper.org'
12
+ s.required_ruby_version = '>= 1.8.7'
13
+ s.rubyforge_project = "graphite-api"
14
+ s.files = %w(README.md Rakefile) + Dir.glob("{bin,lib,test,tasks}/**/*")
15
+ s.require_path = "lib"
16
+ end
17
+
18
+ task :gem => [:clobber_package]
19
+ Gem::PackageTask.new(Darky::GemSpec) do |p|
20
+ p.gem_spec = Darky::GemSpec
21
+ end
22
+
23
+ task :install => [:gem] do
24
+ sh "gem install pkg/graphite-api"
25
+ Rake::Task['clobber_package'].execute
26
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: darky
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Eran Barak Levi
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-11-18 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Darky is a smart a flexible shell wrapper that aims for simplicity and packed with all the syntactic sugar you need
23
+ email: eran@kontera.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - README.md
32
+ - Rakefile
33
+ - lib/darky/adapter.rb
34
+ - lib/darky/adapters/backticks.rb
35
+ - lib/darky/client.rb
36
+ - lib/darky.rb
37
+ - tasks/build.rake
38
+ has_rdoc: true
39
+ homepage: http://www.darky-the-wrapper.org
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options: []
44
+
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 1
53
+ - 8
54
+ - 7
55
+ version: 1.8.7
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project: graphite-api
66
+ rubygems_version: 1.3.6
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Yet another shell wrapper
70
+ test_files: []
71
+