ruby_engine 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 825180eaf7c35a37a39e46e1266188da31c77186
4
+ data.tar.gz: 0c359ab7b1db3fdd4740e47625f46bc7c49886b4
5
+ SHA512:
6
+ metadata.gz: 4defe868cb7edbc1210ef9413e28f90c76b918c917ebeb59e002c33754fb8acd7ee08d86866658391c0901c26b1970cd209ca0f7b9fe9398df67fea065d1c001
7
+ data.tar.gz: 5a525ee6b5599d1353a70a81c15d300f8f7eaf020dd73a4039afce77b74e49ac88043f231df8b9bbc698249283e2c593fa8ea3b558886c5c64de848979bd4441
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - ruby-head
5
+ - 2.1.0
6
+ - 2.0.0
7
+ - 1.9.3
8
+ - 1.9.2
9
+ - 1.8.7
10
+ - 1.8.6
11
+ - ree
12
+ - jruby-20mode
13
+ - jruby-19mode
14
+ - jruby-18mode
15
+ - rbx
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2014-01-14
2
+
3
+ * Return "ruby" for MRI (instead of "mri")
4
+ * Return "unknown" if RUBY_ENGINE is not set (instead of "mri")
5
+ * Moved from zucker 13.1 gem into its own gem
6
+
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ platform :rbx do
6
+ gem 'rubysl-date'
7
+ gem 'rubysl-singleton'
8
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Jan Lelis
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.
@@ -0,0 +1,32 @@
1
+ = RubyEngine
2
+
3
+ Provides a +RubyEngine+ to simplify checking on which implementation your Ruby programs is running.
4
+
5
+ == Setup
6
+
7
+ On your command-line:
8
+
9
+ $ gem install ruby_engine
10
+
11
+ In Ruby:
12
+
13
+ require 'ruby_engine'
14
+
15
+ == Usage
16
+
17
+ RubyEngine.to_s # outputs the interpreter name
18
+
19
+ RubyEngine.is? 'jruby' # true for jruby
20
+
21
+ # There are some query methods defined:
22
+ RubyEngine.mri?
23
+ RubyEngine.jruby?
24
+ RubyEngine.rubinius?
25
+ RubyEngine.ree?
26
+ RubyEngine.ironruby?
27
+ RubyEngine.macruby?
28
+ RubyEngine.cardinal?
29
+
30
+ == J-_-L
31
+
32
+ Copyright (c) 2010-2014 Jan Lelis. MIT License. Originated from the zucker gem.
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ begin
6
+ require 'bundler'
7
+ rescue LoadError => e
8
+ warn e.message
9
+ warn "Run `gem install bundler` to install Bundler."
10
+ exit -1
11
+ end
12
+
13
+ begin
14
+ Bundler.setup(:development)
15
+ rescue Bundler::BundlerError => e
16
+ warn e.message
17
+ warn "Run `bundle install` to install missing gems."
18
+ exit e.status_code
19
+ end
20
+
21
+ require 'rake'
22
+
23
+ require 'rubygems/tasks'
24
+ Gem::Tasks.new
25
+
26
+ require 'rdoc/task'
27
+ RDoc::Task.new do |rdoc|
28
+ rdoc.title = "ruby_version"
29
+ end
30
+ task :doc => :rdoc
31
+
32
+ require 'rspec/core/rake_task'
33
+ RSpec::Core::RakeTask.new
34
+
35
+ task :test => :spec
36
+ task :default => :spec
@@ -0,0 +1,66 @@
1
+ module RubyEngine
2
+ @interpreter = case
3
+ when RUBY_PLATFORM == 'parrot'
4
+ 'cardinal'
5
+ when Object.const_defined?(:RUBY_ENGINE)
6
+ if RUBY_ENGINE == 'ruby'
7
+ if RUBY_DESCRIPTION =~ /Enterprise/
8
+ 'ree'
9
+ else
10
+ 'ruby'
11
+ end
12
+ else
13
+ RUBY_ENGINE.to_s # jruby, rbx, ironruby, macruby, etc.
14
+ end
15
+ else
16
+ 'unknown'
17
+ end
18
+
19
+ class << self
20
+ def is?(what)
21
+ what === @interpreter
22
+ end
23
+ alias is is?
24
+
25
+ def to_s
26
+ @interpreter.to_s
27
+ end
28
+ alias inspect to_s
29
+
30
+ # ask methods
31
+
32
+ def mri?
33
+ RubyEngine.is? 'mri'
34
+ end
35
+ alias official_ruby? mri?
36
+ alias ruby? mri?
37
+
38
+ def jruby?
39
+ RubyEngine.is? 'jruby'
40
+ end
41
+ alias java? jruby?
42
+
43
+ def rubinius?
44
+ RubyEngine.is? 'rbx'
45
+ end
46
+ alias rbx? rubinius?
47
+
48
+ def ree?
49
+ RubyEngine.is? 'ree'
50
+ end
51
+ alias enterprise? ree?
52
+
53
+ def ironruby?
54
+ RubyEngine.is? 'ironruby'
55
+ end
56
+ alias iron_ruby? ironruby?
57
+
58
+ def cardinal?
59
+ RubyEngine.is? 'cardinal'
60
+ end
61
+ alias parrot? cardinal?
62
+ alias perl? cardinal?
63
+ end
64
+ end
65
+
66
+ # J-_-L
@@ -0,0 +1,4 @@
1
+ module RubyEngine
2
+ # ruby_engine version
3
+ VERSION = "1.0.0"
4
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/ruby_engine/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "ruby_engine"
7
+ gem.version = RubyEngine::VERSION
8
+ gem.summary = 'Adds the RubyEngine pseudo-constant.'
9
+ gem.description = 'Gives you an RubyEngine class that simplifies checking for your Ruby implementation.'
10
+ gem.license = "MIT"
11
+ gem.authors = ["Jan Lelis"]
12
+ gem.email = "mail@janlelis.de"
13
+ gem.homepage = "https://github.com/janlelis/ruby_engine"
14
+
15
+ gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ['lib']
19
+
20
+ gem.add_development_dependency 'bundler', '~> 1.0'
21
+ gem.add_development_dependency 'rake', '~> 10.0'
22
+ gem.add_development_dependency 'rdoc', '~> 3.0'
23
+ gem.add_development_dependency 'rspec', '~> 2.4'
24
+ gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'RubyEngine' do
4
+ before :all do
5
+ RubyEngine.instance_variable_set(:@interpreter, "jruby")
6
+ end
7
+
8
+ it 'should display RUBY_ENGINE if called directly (to_s)' do
9
+ RubyEngine.to_s.should == 'jruby'
10
+ end
11
+
12
+ describe '.is?' do
13
+ it 'returns true if current ruby engine matches' do
14
+ RubyEngine.is?('jruby').should == true
15
+ end
16
+
17
+ it 'returns false if current ruby engine does not match' do
18
+ RubyEngine.is?('maglev').should == false
19
+ end
20
+
21
+ it 'also supports regex' do
22
+ RubyEngine.is?(/ruby/).should == true
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,2 @@
1
+ require 'rspec'
2
+ require 'ruby_engine'
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_engine
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan Lelis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.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: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubygems-tasks
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.2'
83
+ description: Gives you an RubyEngine class that simplifies checking for your Ruby
84
+ implementation.
85
+ email: mail@janlelis.de
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
+ - ChangeLog.rdoc
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - LICENSE.txt
97
+ - README.rdoc
98
+ - Rakefile
99
+ - lib/ruby_engine.rb
100
+ - lib/ruby_engine/version.rb
101
+ - ruby_engine.gemspec
102
+ - spec/ruby_engine_spec.rb
103
+ - spec/spec_helper.rb
104
+ homepage: https://github.com/janlelis/ruby_engine
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.2.1
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Adds the RubyEngine pseudo-constant.
128
+ test_files:
129
+ - spec/ruby_engine_spec.rb
130
+ - spec/spec_helper.rb