buff-platform 0.1.0

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
@@ -0,0 +1 @@
1
+ 1.9.3-p429
@@ -0,0 +1,7 @@
1
+ script: "bundle exec thor spec"
2
+ language: ruby
3
+ rvm:
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - jruby-19mode
@@ -0,0 +1,24 @@
1
+ # Contributing
2
+
3
+ ## Running tests
4
+
5
+ ### Install prerequisites
6
+
7
+ Install the latest version of [Bundler](http://gembundler.com)
8
+
9
+ $ gem install bundler
10
+
11
+ Clone the project
12
+
13
+ $ git clone git://github.com/RiotGames/buff-platform.git
14
+
15
+ and run:
16
+
17
+ $ cd buff-platform
18
+ $ bundle install
19
+
20
+ Bundler will install all gems and their dependencies required for testing and developing.
21
+
22
+ ### Running unit (RSpec) tests
23
+
24
+ $ bundle exec guard start
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,15 @@
1
+ notification :off
2
+
3
+ guard "spork" do
4
+ watch('Gemfile')
5
+ watch('spec/spec_helper.rb') { :rspec }
6
+ watch(%r{^spec/support/.+\.rb$}) { :rspec }
7
+ end
8
+
9
+ guard "rspec", cli: "--color --drb --format Fuubar", all_on_start: false, all_after_pass: false do
10
+ watch(%r{^spec/.+_spec\.rb$})
11
+
12
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
13
+ watch('spec/spec_helper.rb') { "spec" }
14
+ watch(%r{^spec/support/.+\.rb$}) { "spec" }
15
+ end
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ Copyright 2012-2013 Riot Games
2
+
3
+ Jamie Winsor (<reset@riotgames.com>)
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
@@ -0,0 +1,48 @@
1
+ # Buff::Platform
2
+ [![Gem Version](https://badge.fury.io/rb/buff-platform.png)](http://badge.fury.io/rb/buff-platform)
3
+ [![Build Status](https://travis-ci.org/RiotGames/buff-platform.png?branch=master)](https://travis-ci.org/RiotGames/buff-platform)
4
+
5
+ Buff up your code with a mixin for querying the platform running Ruby
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'buff-platform'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install buff-platform
20
+
21
+ ## Usage
22
+
23
+ Using it as a mixin
24
+
25
+ require 'buff/platform'
26
+
27
+ class PowerUp
28
+ include Buff::Platform
29
+ end
30
+
31
+ power_up = PowerUp.new
32
+ power_up.osx? #=> true
33
+ power_up.windows? #-> false
34
+ power_up.linux? #=> false
35
+
36
+ Using it as a module
37
+
38
+ require 'buff/platform'
39
+
40
+ Buff::Platform.osx? #=> true
41
+ Buff::Platform.windows? #=> false
42
+ Buff::Platform.linux? #=> false
43
+
44
+ # Authors and Contributors
45
+
46
+ * Jamie Winsor (<reset@riotgames.com>)
47
+
48
+ Thank you to all of our [Contributors](https://github.com/RiotGames/buff-platform/graphs/contributors), testers, and users.
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require 'bundler'
5
+ require 'bundler/setup'
6
+ require 'buff/platform/version'
7
+ require 'buff/ruby_engine'
8
+
9
+ class Default < Thor
10
+ extend Buff::RubyEngine
11
+
12
+ unless jruby?
13
+ require 'thor/rake_compat'
14
+
15
+ include Thor::RakeCompat
16
+ Bundler::GemHelper.install_tasks
17
+
18
+ desc "build", "Build buff-platform-#{Buff::Platform::VERSION}.gem into the pkg directory"
19
+ def build
20
+ Rake::Task["build"].execute
21
+ end
22
+
23
+ desc "install", "Build and install buff-platform-#{Buff::Platform::VERSION}.gem into system gems"
24
+ def install
25
+ Rake::Task["install"].execute
26
+ end
27
+
28
+ desc "release", "Create tag v#{Buff::Platform::VERSION} and build and push buff-platform-#{Buff::Platform::VERSION}.gem to Rubygems"
29
+ def release
30
+ Rake::Task["release"].execute
31
+ end
32
+ end
33
+
34
+ class Spec < Thor
35
+ namespace :spec
36
+ default_task :unit
37
+
38
+ desc "unit", "run the project's unit tests"
39
+ def unit
40
+ exec "rspec --color --format=documentation spec"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'buff/platform/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "buff-platform"
8
+ spec.version = Buff::Platform::VERSION
9
+ spec.authors = ["Jamie Winsor"]
10
+ spec.email = ["reset@riotgames.com"]
11
+ spec.description = %q{A mixin for querying the platform running Ruby}
12
+ spec.summary = %q{Buff up your code with a mixin for querying the platform running Ruby}
13
+ spec.homepage = "https://github.com/RiotGames/buff-platform"
14
+ spec.license = "Apache 2.0"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^spec/})
19
+ spec.require_paths = ["lib"]
20
+ spec.required_ruby_version = ">= 1.9.2"
21
+
22
+ spec.add_development_dependency "buff-ruby_engine"
23
+ spec.add_development_dependency "thor", "~> 0.18.0"
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "fuubar"
28
+ spec.add_development_dependency "guard"
29
+ spec.add_development_dependency "guard-rspec"
30
+ spec.add_development_dependency "guard-spork"
31
+ spec.add_development_dependency "spork"
32
+ end
@@ -0,0 +1 @@
1
+ require_relative 'buff/platform'
@@ -0,0 +1,24 @@
1
+ require 'rbconfig'
2
+
3
+ module Buff
4
+ module Platform
5
+ require_relative 'platform/version'
6
+
7
+ extend self
8
+
9
+ # @return [Boolean]
10
+ def windows?
11
+ (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) ? true : false
12
+ end
13
+
14
+ # @return [Boolean]
15
+ def osx?
16
+ (RbConfig::CONFIG['host_os'] =~ /darwin/) ? true : false
17
+ end
18
+
19
+ # @return [Boolean]
20
+ def linux?
21
+ (RbConfig::CONFIG['host_os'] =~ /linux/) ? true : false
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ require 'buff/platform'
2
+
3
+ module Kernel
4
+ include Buff::Platform
5
+ end
6
+
7
+ class Object
8
+ # Re-include since the Kernel module was altered
9
+ include Kernel
10
+ end
@@ -0,0 +1,5 @@
1
+ module Buff
2
+ module Platform
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buff::Platform do
4
+ describe "::windows?" do
5
+ subject { described_class.windows? }
6
+
7
+ context "when rb config host_os matches mswin" do
8
+ before { RbConfig::CONFIG.stub(:[]).with('host_os').and_return('mswin') }
9
+
10
+ it "should be true" do
11
+ expect(subject).to be_true
12
+ end
13
+ end
14
+
15
+ context "when rb config host_os matches mingw" do
16
+ before { RbConfig::CONFIG.stub(:[]).with('host_os').and_return('mingw') }
17
+
18
+ it "should be true" do
19
+ expect(subject).to be_true
20
+ end
21
+ end
22
+
23
+ context "when rb config host_os matches cygwin" do
24
+ before { RbConfig::CONFIG.stub(:[]).with('host_os').and_return('cygwin') }
25
+
26
+ it "should be true" do
27
+ expect(subject).to be_true
28
+ end
29
+ end
30
+
31
+ context "when rb config host_os does not match a windows flavor" do
32
+ before { RbConfig::CONFIG.stub(:[]).with('host_os').and_return('darwin11.3.0') }
33
+
34
+ it "should be true" do
35
+ expect(subject).to be_false
36
+ end
37
+ end
38
+ end
39
+
40
+ describe "::osx?" do
41
+ subject { described_class.osx? }
42
+
43
+ context "when rb config host_os matches darwin" do
44
+ before { RbConfig::CONFIG.stub(:[]).with('host_os').and_return('darwin') }
45
+
46
+ it "should be true" do
47
+ expect(subject).to be_true
48
+ end
49
+ end
50
+
51
+ context "when rb config host_os does not match darwin" do
52
+ before { RbConfig::CONFIG.stub(:[]).with('host_os').and_return('mingw') }
53
+
54
+ it "should be true" do
55
+ expect(subject).to be_false
56
+ end
57
+ end
58
+ end
59
+
60
+ describe "::linux?" do
61
+ subject { described_class.linux? }
62
+
63
+ context "when rb config host_os matches linux" do
64
+ before { RbConfig::CONFIG.stub(:[]).with('host_os').and_return('linux') }
65
+
66
+ it "should be true" do
67
+ expect(subject).to be_true
68
+ end
69
+ end
70
+
71
+ context "when rb config host_os does not match linux" do
72
+ before { RbConfig::CONFIG.stub(:[]).with('host_os').and_return('mingw') }
73
+
74
+ it "should be true" do
75
+ expect(subject).to be_false
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,27 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'rspec'
4
+ require 'buff/ruby_engine'
5
+
6
+ def setup_rspec
7
+ RSpec.configure do |config|
8
+ config.expect_with :rspec do |c|
9
+ c.syntax = :expect
10
+ end
11
+
12
+ config.mock_with :rspec
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.filter_run focus: true
15
+ config.run_all_when_everything_filtered = true
16
+ end
17
+ end
18
+
19
+ if Buff::RubyEngine.jruby?
20
+ require 'buff/platform'
21
+ setup_rspec
22
+ else
23
+ require 'spork'
24
+
25
+ Spork.prefork { setup_rspec }
26
+ Spork.each_run { require 'buff/platform' }
27
+ end
metadata ADDED
@@ -0,0 +1,227 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buff-platform
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jamie Winsor
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: buff-ruby_engine
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: thor
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.18.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.18.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: fuubar
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: guard
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: guard-rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: guard-spork
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: spork
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ description: A mixin for querying the platform running Ruby
175
+ email:
176
+ - reset@riotgames.com
177
+ executables: []
178
+ extensions: []
179
+ extra_rdoc_files: []
180
+ files:
181
+ - .gitignore
182
+ - .ruby-version
183
+ - .travis.yml
184
+ - CONTRIBUTING.md
185
+ - Gemfile
186
+ - Guardfile
187
+ - LICENSE
188
+ - README.md
189
+ - Thorfile
190
+ - buff-platform.gemspec
191
+ - lib/buff-platform.rb
192
+ - lib/buff/platform.rb
193
+ - lib/buff/platform/kernel_ext.rb
194
+ - lib/buff/platform/version.rb
195
+ - spec/buff/platform_spec.rb
196
+ - spec/spec_helper.rb
197
+ homepage: https://github.com/RiotGames/buff-platform
198
+ licenses:
199
+ - Apache 2.0
200
+ post_install_message:
201
+ rdoc_options: []
202
+ require_paths:
203
+ - lib
204
+ required_ruby_version: !ruby/object:Gem::Requirement
205
+ none: false
206
+ requirements:
207
+ - - ! '>='
208
+ - !ruby/object:Gem::Version
209
+ version: 1.9.2
210
+ required_rubygems_version: !ruby/object:Gem::Requirement
211
+ none: false
212
+ requirements:
213
+ - - ! '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ segments:
217
+ - 0
218
+ hash: -2719997882300292107
219
+ requirements: []
220
+ rubyforge_project:
221
+ rubygems_version: 1.8.23
222
+ signing_key:
223
+ specification_version: 3
224
+ summary: Buff up your code with a mixin for querying the platform running Ruby
225
+ test_files:
226
+ - spec/buff/platform_spec.rb
227
+ - spec/spec_helper.rb