tobias-script_finder 0.0.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 tobias
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,17 +1,18 @@
1
- = script_finder
1
+ h1. script_finder
2
2
 
3
3
  * http://github.com/tobias/script_finder
4
4
 
5
- == DESCRIPTION:
5
+ h1. DESCRIPTION
6
6
 
7
- script_finder provides a script (called 's') that searches in and up from the current dir
8
- for a folder (default: script/) containing an executable file uniquely identified by the a
7
+ script_finder provides a script (called @s@) that searches in and up from the current dir
8
+ for a folder (default: @script/@) containing an executable file uniquely identified by the a
9
9
  prefix given as the first argument. It then calls that executable, passing the rest of the
10
10
  arguments to the called executable. If the given prefix is ambiguous, the script suggests
11
11
  unique prefixes.
12
12
 
13
13
  Examples (in a rails app):
14
-
14
+
15
+ <pre lang="ruby">
15
16
  ~/rails_app/app/views$ s c
16
17
  --> calling '/Users/tobias/rails_app/script/console'
17
18
  Loading development environment (Rails 2.1.0)
@@ -24,30 +25,33 @@ Examples (in a rails app):
24
25
  ~/rails_app/app/views$ s ru 'some ruby'
25
26
  --> calling '/Users/tobias/rails_app/script/runner some ruby'
26
27
  ...
28
+ </pre>
27
29
 
28
30
  The gem is not rails specific - out of the box it will work with any project that has a
29
- 'script/' directory. If you want to make your own version of the 's' script that looks for
30
- executables in a different dir (I would save this one as 'c'):
31
-
31
+ @script/@ directory. If you want to make your own version of the @s@ script that looks for
32
+ executables in a different dir (I would save this one as @c@):
33
+
34
+ <pre lang="ruby">
32
35
  #!/usr/bin/env ruby
33
36
 
34
37
  require 'script_finder'
35
38
 
36
39
  # looks for executables in a commands/ dir instead of script/.
37
40
  ScriptFinder.find_and_execute(ARGV, 'commands')
38
-
39
- == FEATURES/PROBLEMS:
41
+ </pre>
42
+
43
+ h1. FEATURES/PROBLEMS
40
44
 
41
45
  * may not yet properly handle quoted arguments
42
46
 
43
47
  Email me at: tcrawley@gmail.com if you find any problems.
44
48
 
45
- == INSTALL:
49
+ h1. INSTALL
46
50
 
47
51
  * gem sources -a http://gems.github.com
48
52
  * sudo gem install tobias-script_finder
49
53
 
50
- == LICENSE:
54
+ h1. LICENSE
51
55
 
52
56
  Copyright (c) 2009 Tobias Crawley
53
57
 
@@ -68,4 +72,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
68
72
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
69
73
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
70
74
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
71
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
75
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 2
4
+ :patch: 0
data/lib/script_finder.rb CHANGED
@@ -2,6 +2,3 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  require File.join(File.dirname(__FILE__), 'script_finder', 'script_finder')
5
- module ScriptFinder
6
- VERSION = '0.0.3'
7
- end
@@ -37,7 +37,7 @@ module ScriptFinder
37
37
  too_many_cmds_found(cmd)
38
38
  else
39
39
  command.shift
40
- cmd_string = "#{cmd} #{command.join(' ')}".strip
40
+ cmd_string = "#{cmd} #{commands_to_command_string(command)}".strip
41
41
  puts "--> calling '#{cmd_string}'"
42
42
  exec cmd_string
43
43
  end
@@ -125,6 +125,9 @@ module ScriptFinder
125
125
  puts "\t'#{exec_name} #{prefix}' for '#{File.join(bin_dir, cmd)}'"
126
126
  end
127
127
  end
128
-
128
+
129
+ def commands_to_command_string(commands)
130
+ commands.collect {|x| "'#{x}'"}.join(' ')
131
+ end
129
132
  end
130
133
  end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,12 @@
1
- require 'stringio'
1
+ require 'rubygems'
2
2
  require 'test/unit'
3
- require File.dirname(__FILE__) + '/../lib/script_finder'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+
8
+ require 'script_finder'
9
+
10
+ class Test::Unit::TestCase
11
+
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tobias-script_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Crawley
@@ -9,58 +9,35 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-11 00:00:00 -07:00
12
+ date: 2009-03-31 00:00:00 -07:00
13
13
  default_executable: s
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: newgem
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.2.3
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: hoe
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.8.0
34
- version:
35
- description: "script_finder provides a script (called 's') that searches in and up from the current dir for a folder (default: script/) containing an executable file uniquely identified by the a prefix given as the first argument. It then calls that executable, passing the rest of the arguments to the called executable. If the given prefix is ambiguous, the script suggests unique prefixes. Examples (in a rails app): ~/rails_app/app/views$ s c --> calling '/Users/tobias/rails_app/script/console' Loading development environment (Rails 2.1.0) RowsLogger plugin enables mysql >> exit ~/rails_app/app/views$ s r 'some ruby' 's r' was too ambiguous. Try: 's ru' for 'script/runner' 's re' for 'script/remote' ~/rails_app/app/views$ s ru 'some ruby' --> calling '/Users/tobias/rails_app/script/runner some ruby' ... The gem is not rails specific - out of the box it will work with any project that has a 'script/' directory. If you want to make your own version of the 's' script that looks for executables in a different dir (I would save this one as 'c'): #!/usr/bin/env ruby require 'script_finder' # looks for executables in a commands/ dir instead of script/. ScriptFinder.find_and_execute(ARGV, 'commands')"
36
- email:
37
- - tcrawley@gmail.com
14
+ dependencies: []
15
+
16
+ description:
17
+ email: tcrawley@gmail.com
38
18
  executables:
39
19
  - s
40
20
  extensions: []
41
21
 
42
22
  extra_rdoc_files:
43
- - History.txt
44
- - Manifest.txt
45
- - PostInstall.txt
46
- - README.rdoc
23
+ - README.textile
24
+ - LICENSE
47
25
  files:
48
- - History.txt
49
- - Manifest.txt
50
- - PostInstall.txt
51
- - README.rdoc
52
- - Rakefile
53
- - lib/script_finder.rb
54
- - lib/script_finder/script_finder.rb
26
+ - README.textile
27
+ - VERSION.yml
55
28
  - bin/s
29
+ - lib/script_finder
30
+ - lib/script_finder/script_finder.rb
31
+ - lib/script_finder.rb
56
32
  - test/test_helper.rb
57
33
  - test/test_script_finder.rb
34
+ - LICENSE
58
35
  has_rdoc: true
59
36
  homepage: http://github.com/tobias/script_finder
60
- post_install_message: PostInstall.txt
37
+ post_install_message:
61
38
  rdoc_options:
62
- - --main
63
- - README.rdoc
39
+ - --inline-source
40
+ - --charset=UTF-8
64
41
  require_paths:
65
42
  - lib
66
43
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -77,11 +54,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
54
  version:
78
55
  requirements: []
79
56
 
80
- rubyforge_project: script_finder
57
+ rubyforge_project:
81
58
  rubygems_version: 1.2.0
82
59
  signing_key:
83
60
  specification_version: 2
84
- summary: "script_finder provides a script (called 's') that searches in and up from the current dir for a folder (default: script/) containing an executable file uniquely identified by the a prefix given as the first argument"
85
- test_files:
86
- - test/test_helper.rb
87
- - test/test_script_finder.rb
61
+ summary: A gem that provides tools to find and execute scripts in a project.
62
+ test_files: []
63
+
data/History.txt DELETED
@@ -1,13 +0,0 @@
1
- == 0.0.3 2009-03-11
2
-
3
- * fixed issue with exception when command not found
4
-
5
- == 0.0.2 2009-03-11
6
-
7
- * added readme
8
- * updated gemspec with contents from readme
9
-
10
- == 0.0.1 2009-03-10
11
-
12
- * 1 major enhancement:
13
- * Initial release
data/Manifest.txt DELETED
@@ -1,8 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- PostInstall.txt
4
- README.rdoc
5
- Rakefile
6
- lib/script_finder.rb
7
- lib/script_finder/script_finder.rb
8
- bin/s
data/PostInstall.txt DELETED
@@ -1,5 +0,0 @@
1
-
2
- For more information on script_finder, see http://github.com/tobias/script_finder
3
-
4
-
5
-
data/Rakefile DELETED
@@ -1,28 +0,0 @@
1
- %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
- require File.dirname(__FILE__) + '/lib/script_finder'
3
-
4
- # Generate all the Rake tasks
5
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
- $hoe = Hoe.new('script_finder', ScriptFinder::VERSION) do |p|
7
- p.developer('Tobias Crawley', 'tcrawley@gmail.com')
8
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
- p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
10
- p.rubyforge_name = p.name # TODO this is default value
11
- # p.extra_deps = [
12
- # ['activesupport','>= 2.0.2'],
13
- # ]
14
- p.extra_dev_deps = [
15
- ['newgem', ">= #{::Newgem::VERSION}"]
16
- ]
17
-
18
- p.clean_globs |= %w[**/.DS_Store tmp *.log]
19
- path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
20
- p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
21
- p.rsync_args = '-av --delete --ignore-errors'
22
- end
23
-
24
- require 'newgem/tasks' # load /tasks/*.rake
25
- Dir['tasks/**/*.rake'].each { |t| load t }
26
-
27
- # TODO - want other tests/tasks run by default? Add them to the list
28
- # task :default => [:spec, :features]
@@ -1,24 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestScriptFinder < Test::Unit::TestCase
4
-
5
- def test_unique_prefixes
6
- prefixes = ScriptFinder::Finder.new([]).unique_prefixes( %w{db dbconsole destroy desmond})
7
- assert_equal prefixes.values.size, prefixes.values.uniq.size
8
- end
9
-
10
- def test_unique_prefixes_gives_shortest_prefix
11
- prefixes = ScriptFinder::Finder.new([]).unique_prefixes(%w{db dbconsole destroy desmond funball})
12
- assert_equal 'db', prefixes['db']
13
- assert_equal 'dbc', prefixes['dbconsole']
14
- assert_equal 'dest', prefixes['destroy']
15
- assert_equal 'desm', prefixes['desmond']
16
- assert_equal 'f', prefixes['funball']
17
-
18
- end
19
-
20
-
21
- def test_truth
22
- assert true
23
- end
24
- end