reditor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in reditor.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 hibariya
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.
@@ -0,0 +1,29 @@
1
+ # Reditor
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'reditor'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install reditor
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
5
+
6
+ require 'reditor'
7
+
8
+ Reditor::Command.start
@@ -0,0 +1,44 @@
1
+ require 'pathname'
2
+ require 'rubygems'
3
+
4
+ module Reditor
5
+ class LibraryNotFound < LoadError; end
6
+
7
+ extend self
8
+
9
+ def detect(name)
10
+ path = detect_library_path(name) or raise LibraryNotFound, 'No library found'
11
+
12
+ if path.file?
13
+ [path.dirname.to_path, path.basename.to_path]
14
+ else
15
+ [path.to_path, '.']
16
+ end
17
+ end
18
+
19
+ def detect_library_path(name)
20
+ detect_library_path_from_loadpath(name) || detect_library_path_from_gem(name)
21
+ end
22
+
23
+ def detect_library_path_from_loadpath(name)
24
+ basename = "#{name}.rb"
25
+
26
+ $LOAD_PATH.map {|path|
27
+ full_path = File.expand_path(path + '/' + basename)
28
+
29
+ Pathname.new(full_path)
30
+ }.detect(&:exist?)
31
+ end
32
+
33
+ # TODO: care version specification
34
+ def detect_library_path_from_gem(name)
35
+ spec = Gem::Specification.find_by_name(name.to_s)
36
+
37
+ Pathname.new(spec.full_gem_path)
38
+ rescue Gem::LoadError
39
+ nil
40
+ end
41
+
42
+ autoload :Command, 'reditor/command'
43
+ autoload :VERSION, 'reditor/version'
44
+ end
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+
3
+ require 'thor'
4
+
5
+ module Reditor
6
+ class Command < Thor
7
+ include Reditor
8
+
9
+ desc :open, 'open a library'
10
+ def open(name)
11
+ dir, file = *detect(name)
12
+
13
+ say "Moving to #{dir}", :green
14
+ Dir.chdir dir do
15
+ say "Opening #{file}", :green
16
+
17
+ exec editor_command, file
18
+ end
19
+ rescue LibraryNotFound => e
20
+ say e.message, :red
21
+ end
22
+
23
+ desc :version, 'show version'
24
+ def version
25
+ say "Reditor version #{VERSION}"
26
+ end
27
+
28
+ # XXX FIXME: a more better implementation
29
+ def method_missing(name, *args, &block)
30
+ send :open, name
31
+ end
32
+
33
+ private
34
+
35
+ def editor_command
36
+ ENV['EDITOR']
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ module Reditor
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/reditor/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['hibariya']
6
+ gem.email = ['celluloid.key@gmail.com']
7
+ gem.description = %q{Open a ruby library by your editor}
8
+ gem.summary = %q{Open a ruby library by your editor}
9
+ gem.homepage = 'https://github.com/hibariya/reditor'
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = 'reditor'
15
+ gem.require_paths = ['lib']
16
+ gem.version = Reditor::VERSION
17
+
18
+ gem.add_runtime_dependency 'thor', '>= 0.14.6'
19
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reditor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - hibariya
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: &70322074171720 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.14.6
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70322074171720
25
+ description: Open a ruby library by your editor
26
+ email:
27
+ - celluloid.key@gmail.com
28
+ executables:
29
+ - reditor
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - bin/reditor
39
+ - lib/reditor.rb
40
+ - lib/reditor/command.rb
41
+ - lib/reditor/version.rb
42
+ - reditor.gemspec
43
+ homepage: https://github.com/hibariya/reditor
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ segments:
56
+ - 0
57
+ hash: 1804824006546242364
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ segments:
65
+ - 0
66
+ hash: 1804824006546242364
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 1.8.11
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Open a ruby library by your editor
73
+ test_files: []