rockt 0.1.0

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fd1f6f157960196d011e4712742e5d831043a85d
4
+ data.tar.gz: 69d4875d087cb65a5262bdd226cd076c1d8780fa
5
+ SHA512:
6
+ metadata.gz: 91717d8af6cc8bf6afdccf3e75f31af3706d108078ad0bd0ca34018f48fc939d74b88fab7eb28fd0a44a6b2f0a03f0b2522bb6ed9133b05176c1060756e229fc
7
+ data.tar.gz: 7bc161a4619720f1668d37713fe1745a25fa864d697ec6465a557c67964f4fe9e41a12fbf1a50ade116e4e5f30288a5e55955142936aff19a25bc28053d73ebb
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --fail-fast --format documentation
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - jruby-19mode
6
+ - rbx-19mode
7
+ - ruby-head
8
+ - jruby-head
@@ -0,0 +1 @@
1
+ fork it, branch it, commit, push it, pull-request it
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rockt (0.1.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.4)
10
+ rake (10.1.0)
11
+ rspec (2.14.0)
12
+ rspec-core (~> 2.14.0)
13
+ rspec-expectations (~> 2.14.0)
14
+ rspec-mocks (~> 2.14.0)
15
+ rspec-core (2.14.0)
16
+ rspec-expectations (2.14.0)
17
+ diff-lcs (>= 1.1.3, < 2.0)
18
+ rspec-mocks (2.14.1)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ rake
25
+ rockt!
26
+ rspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Fuad Saud
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,19 @@
1
+ Rockt
2
+ =====
3
+
4
+ A stupid application launcher for Ruby.
5
+
6
+ ## Usage
7
+
8
+ Just give it and URI, deadly simple:
9
+ ```Rockt.launch('http://github.com') ```
10
+
11
+ This is going to open the system default web browser at "http://github.com"
12
+
13
+ ## BEWARE: tested on OSX 10.8 only; (may not work in other OS's)
14
+
15
+ ## TODO
16
+
17
+ - JRuby support
18
+ - Handle popular desktop environments (KDE, Gnome, Xfce, etc.)
19
+ - Test it on Windows/Cygwin
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rake'
4
+ require 'rspec/core/rake_task'
5
+
6
+ task default: [:spec, :rubocop]
7
+
8
+ RSpec::Core::RakeTask.new
9
+
10
+ desc 'Run RuboCop static analyzer'
11
+ task :rubocop do
12
+ system 'bin/rubocop lib/ spec/ Gemfile Rakefile *.gemspec'
13
+ end
14
+
15
+ desc 'Start an irb session with cape-cod loaded'
16
+ task :console do
17
+ # Do we have pry available?
18
+ repl = system('pry -v &> /dev/null') ? 'pry' : 'irb'
19
+
20
+ system "#{repl} --require ./lib/cape-cod.rb"
21
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'autospec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'autospec')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'htmldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'htmldiff')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'ldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'ldiff')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -0,0 +1,65 @@
1
+ # encoding: utf-8
2
+
3
+ require 'English'
4
+
5
+ #
6
+ # Main Rockt API.
7
+ #
8
+ # It defines only on public method: launch.
9
+ #
10
+ module Rockt
11
+ # Raised when the launcher helper fails.
12
+ ApplicationLauncherFailed = Class.new(Exception)
13
+
14
+ # Raised when no launcher helper is found.
15
+ ApplicationLauncherNotFound = Class.new(Exception)
16
+
17
+ require 'rockt/version'
18
+ require 'rockt/environment'
19
+
20
+ #
21
+ # This is the method for launching applications.
22
+ #
23
+ # Valid options are:
24
+ # - dry_run: doesn't launch the application.
25
+ #
26
+ def self.launch(uri, options = {})
27
+ command = detect_environment.commands.find { |cmd| which cmd } or
28
+ fail ApplicationLauncherNotFound
29
+
30
+ unless options[:dry_run]
31
+ _spawn command, uri
32
+
33
+ fail ApplicationLauncherError unless $CHILD_STATUS.success?
34
+ end
35
+
36
+ command
37
+ end
38
+
39
+ #
40
+ # Returns the module representing the current environment.
41
+ #
42
+ def self.detect_environment
43
+ Environment.detect
44
+ end
45
+
46
+ private
47
+
48
+ def self._spawn(command, *params)
49
+ Process.wait spawn(command, *uri)
50
+ end
51
+
52
+ #
53
+ # Locate an executable file in the path
54
+ #
55
+ def self.which(cmd)
56
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
57
+
58
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
59
+ exts.each do |ext|
60
+ exe = File.join(path, "#{cmd}#{ext}")
61
+ exe if File.executable? exe
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ module Rockt
4
+ #
5
+ # This modules is responsible for detecting the current underlying
6
+ # environment.
7
+ #
8
+ # It is meant to be extended by any module that represents an
9
+ # environment; these must implement a _regex_ method, which should match the
10
+ # environment name returned by the _host_os_ property from RbConfig, and a
11
+ # _commands_ method, which returns a list of the commands that could be ran
12
+ # to launch the application.
13
+ #
14
+ module Environment
15
+ # Raised when cannot recognize the environment.
16
+ UnknownEnvironment = Class.new(Exception)
17
+
18
+ # List containing all modules extending Rockt::Environment.
19
+ KNOWN_ENVIRONMENTS = []
20
+
21
+ # Keep tack of defined environments.
22
+ def self.extended(env)
23
+ KNOWN_ENVIRONMENTS << env
24
+
25
+ env_name = "#{env.to_s.split('::').last}?"
26
+
27
+ # Define a #{environment_name}? method for each of the known.
28
+ # environments.
29
+ self.singleton_class.send(:define_method, env_name.downcase.to_sym) do
30
+ detect == env
31
+ end
32
+ end
33
+
34
+ # Detect current environment.
35
+ def self.detect
36
+ host_os = RbConfig::CONFIG['host_os']
37
+
38
+ KNOWN_ENVIRONMENTS.find { |env| env.regex =~ host_os } or
39
+ fail UnknownEnvironment
40
+ end
41
+ end
42
+ end
43
+
44
+ # Require bundled environemnts.
45
+ Dir[File.join(File.dirname(__FILE__), 'environment', '*.rb')].each do |env|
46
+ require env
47
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ module Rockt
4
+ module Environment
5
+
6
+ # Represents Cygwin enironments
7
+ module Cygwin
8
+ extend Rockt::Environment
9
+
10
+ def self.commands
11
+ ['cmd /C start /b']
12
+ end
13
+
14
+ def self.regex
15
+ /cygwin/i
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ module Rockt
4
+ module Environment
5
+
6
+ # Represents Darwin and Apple OS X environments.
7
+ module Darwin
8
+ extend Rockt::Environment
9
+
10
+ def self.commands
11
+ %w( open )
12
+ end
13
+
14
+ def self.regex
15
+ /(darwin|mac os)/i
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ module Rockt
4
+ module Environment
5
+
6
+ # Represents general Unix environments - Linux, BSD, Solaris.
7
+ # It basically depends on X's xdg-open.
8
+ module Unix
9
+ extend Rockt::Environment
10
+
11
+ def self.commands
12
+ %w( xdg-open )
13
+ end
14
+
15
+ def self.regex
16
+ /(linux|bsd|aix|solaris)/i
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ module Rockt
4
+ module Environment
5
+
6
+ # Represents Microsoft Windows NT environments.
7
+ module Windows
8
+ extend Rockt::Environment
9
+
10
+ def self.open
11
+ ['start']
12
+ end
13
+
14
+ def self.regex
15
+ /(mingw|mswin|windows)/i
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ module Rockt
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
+
5
+ require 'rockt/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'rockt'
9
+ s.version = Rockt::VERSION
10
+ s.platform = Gem::Platform::RUBY
11
+ s.author = 'Fuad Saud'
12
+ s.email = 'fuadksd@gmail.com'
13
+ s.homepage = 'http://github.com/fuadsaud/rockt'
14
+
15
+ s.summary = 'Stupid application launcher for ruby'
16
+ s.license = 'MIT'
17
+ s.description = 'Rockt helps you to launch the right application to handle' +
18
+ 'some file or webpage.'
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
22
+ s.require_paths = %w( lib )
23
+
24
+ s.add_development_dependency 'rspec'
25
+ s.add_development_dependency 'rake'
26
+ end
27
+
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Rockt::Environment do
6
+ it 'should know at least one environment' do
7
+ expect(Rockt::Environment::KNOWN_ENVIRONMENTS).not_to be_empty
8
+ end
9
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Rockt do
6
+ it 'has a version' do
7
+ expect(Rockt::VERSION).to be_a String
8
+ end
9
+
10
+ describe '.launch' do
11
+ let(:uri) { 'http://github.com/fuadsaud' }
12
+
13
+ it 'returns one of the commands for the current environment' do
14
+ command = Rockt.launch(uri, dry_run: true)
15
+
16
+ expect(Rockt.detect_environment.commands).to include(command)
17
+ end
18
+ end
19
+
20
+ describe '.detect_environment' do
21
+ it 'correctly detects the current environment' do
22
+ expect(
23
+ Rockt.detect_environment.regex).to match RbConfig::CONFIG['host_os']
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+
3
+ $LOAD_PATH << 'lib'
4
+
5
+ require 'rspec'
6
+ require 'rockt'
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rockt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Fuad Saud
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Rockt helps you to launch the right application to handlesome file or
42
+ webpage.
43
+ email: fuadksd@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .rspec
50
+ - .travis.yml
51
+ - CONTRIBUTING.md
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE.md
55
+ - README.md
56
+ - Rakefile
57
+ - bin/autospec
58
+ - bin/htmldiff
59
+ - bin/ldiff
60
+ - bin/rake
61
+ - bin/rspec
62
+ - lib/rockt.rb
63
+ - lib/rockt/environment.rb
64
+ - lib/rockt/environment/cygwin.rb
65
+ - lib/rockt/environment/darwin.rb
66
+ - lib/rockt/environment/unix.rb
67
+ - lib/rockt/environment/windows.rb
68
+ - lib/rockt/version.rb
69
+ - rockt.gemspec
70
+ - spec/rockt/environment_spec.rb
71
+ - spec/rockt_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: http://github.com/fuadsaud/rockt
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Stupid application launcher for ruby
97
+ test_files: []
98
+ has_rdoc: