openup 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -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 openup.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Sam Murphy
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.
data/Linkfile ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "github": "http://www.github.com",
3
+ "docs": "http://www.example.com",
4
+ "editor": {
5
+ "command": "mate ."
6
+ }
7
+ }
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Openup
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'openup'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install openup
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
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/openup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
4
+ require 'openup'
5
+
6
+ Openup::Commander.run!(ARGV)
data/lib/openup.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "openup/version"
2
+ require "openup/commander"
3
+
4
+
5
+ module Openup
6
+ # Your code goes here...
7
+
8
+ end
@@ -0,0 +1,97 @@
1
+ module Openup
2
+
3
+ class Command
4
+
5
+ def initialize(command)
6
+ @command = command
7
+ end
8
+
9
+ def run!
10
+ if url?
11
+ `open #{url}`
12
+ elsif shell_command?
13
+ `#{shell_command}`
14
+ end
15
+ end
16
+
17
+ def url?
18
+ @command.is_a? String
19
+ end
20
+
21
+ def url
22
+ url? ? @command : nil
23
+ end
24
+
25
+ def shell_command?
26
+ @command.is_a?(Hash) && @command["command"]
27
+ end
28
+
29
+ def shell_command
30
+ shell_command? ? @command["command"] : nil
31
+ end
32
+
33
+ end
34
+
35
+ class Commander
36
+
37
+ def self.run!(args)
38
+ new(args).run!
39
+ end
40
+
41
+ def initialize(args)
42
+ @arguments = args
43
+ end
44
+
45
+ def run!
46
+ if !linkfile_exists?
47
+ puts "No Linkfile in path #{current_directory}!"
48
+ else
49
+
50
+ link = @arguments.first
51
+ command = Command.new(linkfile[link]) if linkfile[link]
52
+
53
+ if !link
54
+ show_help
55
+ elsif command && link
56
+ command.run!
57
+ else # unknown link
58
+ puts "Unknown link #{command} in Linkfile"
59
+ end
60
+ end
61
+ end
62
+
63
+ def show_help
64
+ linkfile.each do |k, v|
65
+ puts "\t#{k}: #{v}"
66
+ end
67
+ end
68
+
69
+ def current_directory
70
+ @current_directory ||= `pwd`.strip
71
+ end
72
+
73
+ def linkfile_path
74
+ File.join(current_directory, '/Linkfile')
75
+ end
76
+
77
+ def linkfile_exists?
78
+ File.exists?(linkfile_path)
79
+ end
80
+
81
+ def linkfile
82
+ @linkfile ||= begin
83
+ if linkfile_exists?
84
+ require 'json'
85
+ JSON.parse(File.open(linkfile_path).read)
86
+ else
87
+ nil
88
+ end
89
+ end
90
+ end
91
+
92
+
93
+
94
+ end
95
+
96
+
97
+ end
@@ -0,0 +1,3 @@
1
+ module Openup
2
+ VERSION = "0.0.1"
3
+ end
data/openup.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/openup/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Sam Murphy"]
6
+ gem.email = ["sam.murphy@gmail.com"]
7
+ gem.description = %q{Quickly open project-related links from your project's root}
8
+ gem.summary = %q{Create a Linkfile document to point to important links relating to your project}
9
+ gem.homepage = ""
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 = "openup"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Openup::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sam Murphy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-10 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Quickly open project-related links from your project's root
15
+ email:
16
+ - sam.murphy@gmail.com
17
+ executables:
18
+ - openup
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE
25
+ - Linkfile
26
+ - README.md
27
+ - Rakefile
28
+ - bin/openup
29
+ - lib/openup.rb
30
+ - lib/openup/commander.rb
31
+ - lib/openup/version.rb
32
+ - openup.gemspec
33
+ homepage: ''
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 1.8.21
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Create a Linkfile document to point to important links relating to your project
57
+ test_files: []