oboe 2.2.6 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/.gitignore +6 -1
  2. data/Appraisals +20 -0
  3. data/Gemfile +16 -20
  4. data/README.md +280 -10
  5. data/Rakefile +63 -7
  6. data/ext/oboe_metal/extconf.rb +2 -1
  7. data/ext/oboe_metal/tests/test.rb +4 -0
  8. data/gemfiles/rails2.3.gemfile +18 -0
  9. data/gemfiles/rails2.3.gemfile.lock +95 -0
  10. data/gemfiles/rails3.0.gemfile +18 -0
  11. data/gemfiles/rails3.0.gemfile.lock +142 -0
  12. data/gemfiles/rails3.1.gemfile +18 -0
  13. data/gemfiles/rails3.1.gemfile.lock +152 -0
  14. data/gemfiles/rails3.2.gemfile +18 -0
  15. data/gemfiles/rails3.2.gemfile.lock +150 -0
  16. data/init.rb +1 -1
  17. data/lib/joboe_metal.rb +52 -34
  18. data/lib/method_profiling.rb +1 -1
  19. data/lib/oboe.rb +6 -5
  20. data/lib/oboe/api.rb +1 -1
  21. data/lib/oboe/api/layerinit.rb +3 -0
  22. data/lib/oboe/api/logging.rb +1 -1
  23. data/lib/oboe/api/memcache.rb +2 -2
  24. data/lib/oboe/api/profiling.rb +6 -4
  25. data/lib/oboe/api/tracing.rb +1 -1
  26. data/lib/oboe/api/util.rb +1 -1
  27. data/lib/oboe/config.rb +29 -10
  28. data/lib/oboe/frameworks/rails.rb +6 -7
  29. data/lib/oboe/frameworks/rails/inst/action_controller.rb +1 -1
  30. data/lib/oboe/frameworks/rails/inst/action_view.rb +3 -3
  31. data/lib/oboe/frameworks/rails/inst/action_view_2x.rb +3 -3
  32. data/lib/oboe/frameworks/rails/inst/action_view_30.rb +3 -3
  33. data/lib/oboe/frameworks/rails/inst/active_record.rb +1 -1
  34. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +1 -1
  35. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +1 -1
  36. data/lib/oboe/frameworks/rails/inst/connection_adapters/oracle.rb +1 -1
  37. data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +1 -1
  38. data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +2 -2
  39. data/lib/oboe/inst/cassandra.rb +2 -2
  40. data/lib/oboe/inst/dalli.rb +8 -4
  41. data/lib/oboe/inst/http.rb +38 -34
  42. data/lib/oboe/inst/memcache.rb +12 -3
  43. data/lib/oboe/inst/memcached.rb +10 -5
  44. data/lib/oboe/inst/mongo.rb +19 -15
  45. data/lib/oboe/inst/moped.rb +120 -51
  46. data/lib/oboe/inst/rack.rb +14 -7
  47. data/lib/oboe/inst/resque.rb +2 -2
  48. data/lib/oboe/instrumentation.rb +3 -0
  49. data/lib/oboe/loading.rb +2 -6
  50. data/lib/oboe/logger.rb +3 -1
  51. data/lib/oboe/ruby.rb +3 -0
  52. data/lib/oboe/util.rb +2 -0
  53. data/lib/oboe/version.rb +5 -2
  54. data/lib/oboe_fu.rb +2 -0
  55. data/lib/oboe_metal.rb +23 -10
  56. data/lib/rails/generators/oboe/install_generator.rb +5 -3
  57. data/lib/rails/generators/oboe/templates/oboe_initializer.rb +24 -2
  58. data/oboe.gemspec +20 -14
  59. data/test/instrumentation/cassandra_test.rb +331 -0
  60. data/test/instrumentation/dalli_test.rb +157 -0
  61. data/test/instrumentation/http_test.rb +74 -0
  62. data/test/instrumentation/memcache_test.rb +251 -0
  63. data/test/instrumentation/memcached_test.rb +218 -0
  64. data/test/instrumentation/mongo_test.rb +406 -0
  65. data/test/instrumentation/moped_test.rb +468 -0
  66. data/test/instrumentation/rack_test.rb +55 -0
  67. data/test/instrumentation/resque_test.rb +62 -0
  68. data/test/minitest_helper.rb +113 -0
  69. data/test/support/config_test.rb +41 -0
  70. metadata +56 -35
  71. data/Gemfile.lock +0 -103
  72. data/Guardfile +0 -24
  73. data/install.rb +0 -1
  74. data/spec/instrumentation/cassandra_spec.rb +0 -18
  75. data/spec/instrumentation/dalli_spec.rb +0 -14
  76. data/spec/instrumentation/http_spec.rb +0 -14
  77. data/spec/instrumentation/memcache_spec.rb +0 -19
  78. data/spec/instrumentation/memcached_spec.rb +0 -22
  79. data/spec/instrumentation/mongo_spec.rb +0 -29
  80. data/spec/instrumentation/moped_spec.rb +0 -41
  81. data/spec/instrumentation/resque_spec.rb +0 -18
  82. data/spec/spec_helper.rb +0 -15
  83. data/spec/support/config_spec.rb +0 -27
  84. data/spec/support/oboe_spec.rb +0 -4
data/.gitignore CHANGED
@@ -1,4 +1,9 @@
1
1
  oboe*.gem
2
2
  *~
3
3
  *.swp
4
- lib/so_variants
4
+ lib/oboe_metal.so
5
+ ext/oboe_metal/Makefile
6
+ ext/oboe_metal/mkmf.log
7
+ ext/oboe_metal/oboe_metal.so
8
+ ext/oboe_metal/oboe_wrap.o
9
+ Gemfile.lock
@@ -0,0 +1,20 @@
1
+
2
+ appraise "rails2.3" do
3
+ gem "rails", "~> 2.3.18"
4
+ gem "oboe", :path => "../"
5
+ end
6
+
7
+ appraise "rails3.0" do
8
+ gem "rails", "~> 3.0.20"
9
+ gem "oboe", :path => "../"
10
+ end
11
+
12
+ appraise "rails3.1" do
13
+ gem "rails", "~> 3.1.12"
14
+ gem "oboe", :path => "../"
15
+ end
16
+
17
+ appraise "rails3.2" do
18
+ gem "rails", "~> 3.2.13"
19
+ gem "oboe", :path => "../"
20
+ end
data/Gemfile CHANGED
@@ -4,27 +4,23 @@ source 'https://rubygems.org'
4
4
  gemspec :name => 'oboe'
5
5
 
6
6
  gem 'rake'
7
+ gem 'appraisal'
7
8
 
8
- group :development do
9
- gem 'guard'
10
- gem 'guard-rspec'
11
-
12
- gem 'rb-inotify', :require => false
13
- gem 'rb-fsevent', :require => false
14
- gem 'rb-fchange', :require => false
9
+ group :development, :test do
10
+ gem 'minitest'
11
+ gem 'minitest-reporters'
12
+ gem 'debugger'
13
+ gem 'rack-test'
15
14
  end
16
15
 
17
- group :test do
18
- gem 'rspec'
19
-
20
- # Instrumented gems
21
- gem 'dalli'
22
- gem 'memcache-client'
23
- gem 'memcached' if (RUBY_VERSION =~ /^1./) == 0
24
- gem 'cassandra'
25
- gem 'mongo'
26
- gem 'bson_ext' # For Mongo, Yours Truly
27
- gem 'moped'
28
- gem 'resque'
29
- end
16
+ # Instrumented gems
17
+ gem 'dalli'
18
+ gem 'memcache-client'
19
+ gem 'memcached' if (RUBY_VERSION =~ /^1./) == 0
20
+ gem 'cassandra'
21
+ gem 'mongo'
22
+ gem 'bson_ext' # For Mongo, Yours Truly
23
+ gem 'moped'
24
+ gem 'resque'
25
+ gem 'rack-test'
30
26
 
data/README.md CHANGED
@@ -1,19 +1,289 @@
1
- ## oboe - TraceView Ruby Instrumentation
1
+ # Welcome to the TraceView Ruby Gem
2
+ ## AKA The oboe gem
2
3
 
3
- The oboe gem provides AppNeta [TraceView](http://www.appneta.com/application-performance-management/) instrumentation for Ruby and Ruby frameworks.
4
+ The oboe gem provides AppNeta [TraceView](http://www.appneta.com/application-performance-management/) instrumentation for Ruby.
4
5
 
5
- ## Installing
6
+ ![Ruby TraceView](https://s3.amazonaws.com/pglombardo/oboe-ruby-header.png)
6
7
 
7
- The oboe gem is [available on Rubygems](https://rubygems.org/gems/oboe). See the [Ruby Knowedge Base article](http://support.tv.appneta.com/kb/ruby/instrumenting-ruby-apps)
8
- for information on how to install.
8
+ It has the ability to report performance metrics on an array of libraries, databases and frameworks such as Rails, Mongo, Memcache, ActiveRecord, Cassandra, Rack, Resque [and more](https://support.tv.appneta.com/support/solutions/articles/86388-ruby-instrumentation-support-matrix).
9
9
 
10
- Release notes can be found in the CHANGELOG or also [here](http://support.tv.appneta.com/kb/ruby/ruby-instrumentation-release-notes)
10
+ It requires a [TraceView](http://www.appneta.com/products/traceview/) account to view metrics. Get yours, [it's free](http://www.appneta.com/products/traceview-free-account/).
11
11
 
12
- ## Supported Technologies
12
+ # Installation
13
13
 
14
- Check the [support matrix](https://github.com/tracelytics/oboe-ruby/wiki/Support-Matrix) for which versions of Ruby, Rails and technologies are supported.
14
+ The oboe gem is [available on Rubygems](https://rubygems.org/gems/oboe) and can be installed with:
15
15
 
16
- ## Tips
16
+ gem install oboe
17
17
 
18
- General tips using, installing and debugging the oboe gem can be found [here](https://github.com/tracelytics/oboe-ruby/wiki/Ruby-Oboe-Tips).
18
+ or added to your bundle Gemfile and running `bundle install`:
19
+
20
+ gem 'oboe'
21
+
22
+ # Running
23
+
24
+ ## Rails
25
+
26
+ No special steps are needed to instrument Ruby on Rails. Once part of the bundle, the oboe gem will automatically detect Rails and instrument on stack initialization.
27
+
28
+ _Note: You will still need to decide on your `tracing_mode` depending on whether you are running with an instrumented Apache or nginx in front of your Rails stack. See below for more details._
29
+
30
+ ### The Install Generator
31
+
32
+ The oboe gem provides a Rails generator used to seed an oboe initializer where you can configure and control `tracing_mode`, `sample_rate` and [other options](https://support.tv.appneta.com/support/solutions/articles/86392-configuring-the-ruby-instrumentation).
33
+
34
+ To run the install generator run:
35
+
36
+ bundle exec rails generate oboe:install
37
+
38
+ After the prompts, this will create an initializer: `config/initializers/oboe.rb`.
39
+
40
+ ## Sinatra/Padrino
41
+
42
+ You can instrument your Sinatra or Padrino application by adding the following code to your `config.ru` Rackup file (Padrino example).
43
+
44
+ require 'oboe'
45
+ require 'oboe/inst/rack'
46
+
47
+ # When traces should be initiated for incoming requests. Valid options are
48
+ # “always,” “through” (when the request is initiated with a tracing header
49
+ # from upstream) and “never”. You must set this directive to “always” in
50
+ # order to initiate tracing.
51
+ Oboe::Config[:tracing_mode] = 'through'
52
+
53
+ # You can remove the following line in production to allow for
54
+ # auto sampling or managing the sample rate through the TraceView portal.
55
+ # Oboe::Config[:sample_rate] = 1000000
56
+
57
+ # You may want to replace the Oboe.logger with your own
58
+ Oboe.logger = Padrino.logger
59
+
60
+ Oboe::Ruby.initialize
61
+ Padrino.use Oboe::Rack
62
+
63
+ _In a future release, much of this will be automated._
64
+
65
+ ## Custom Ruby Scripts & Applications
66
+
67
+ The oboe gem has the ability to instrument any arbitrary Ruby application or script as long as the gem is initialized with the manual methods:
68
+
69
+ require 'rubygems'
70
+ require 'bundler'
71
+
72
+ Bundler.require
73
+
74
+ require 'oboe'
75
+ Oboe::Ruby.initialize
76
+
77
+ From here, you can use the Tracing API to instrument areas of code (see below).
78
+
79
+ ## Other
80
+
81
+ You can send deploy notifications to TraceView and have the events show up on your dashboard. See: [Capistrano Deploy Notifications with tlog](https://support.tv.appneta.com/support/solutions/articles/86389-capistrano-deploy-notifications-with-tlog).
82
+
83
+ # Custom Tracing
84
+
85
+ ## The Tracing API
86
+
87
+ You can instrument any arbitrary block of code using the following pattern:
88
+
89
+ # layer_name will show up in the TraceView app dashboard
90
+ layer_name = 'subsystemX'
91
+
92
+ # report_kvs are a set of information Key/Value pairs that are sent to TraceView along with the performance metrics.
93
+ # These KV pairs can report on request, environment or client specific information.
94
+
95
+ report_kvs = {}
96
+ report_kvs[:mykey] = @client.id
97
+
98
+ Oboe::API.trace(layer_name, report_kvs) do
99
+ # the block of code to be traced
100
+ end
101
+
102
+ Find more details in the TraceView [documentation portal](https://support.tv.appneta.com/support/solutions/articles/86395-ruby-instrumentation-public-api).
103
+
104
+ ## Tracing Methods
105
+
106
+ By using class level declarations, it's possible to automatically have certain methods on that class instrumented and reported to your TraceView dashboard automatically.
107
+
108
+ The pattern for Method Profiling is as follows:
109
+
110
+ # 'profile_name' is similar to a layer name.
111
+ # It identifies this custom trace in your dashboard.
112
+ #
113
+ class Engine
114
+ include OboeMethodProfiling
115
+
116
+ def processor()
117
+ # body of method
118
+ end
119
+
120
+ # call syntax: profile_method <method>, <profile_name>
121
+ profile_method :processor, 'processor'
122
+ end
123
+
124
+ This example demonstrates method profiling of instance methods. Class methods are profiled slightly differently. See the TraceView [documentation portal](https://support.tv.appneta.com/support/solutions/articles/86395-ruby-instrumentation-public-api) for full details.
125
+
126
+ # Support
127
+
128
+ If you find a bug or would like to request an enhancement, feel free to file an issue. For all other support requests, see our [support portal](https://support.tv.appneta.com/) or on IRC @ #appneta on Freenode.
129
+
130
+ # Contributing
131
+
132
+ You are obviously a person of great sense and intelligence. We happily appreciate all contributions to the oboe gem whether it is documentation, a bug fix, new instrumentation for a library or framework or anything else we haven't thought of.
133
+
134
+ We welcome you to send us PRs. We also humbly request that any new instrumentation submissions have corresponding tests that accompany them. This way we don't break any of your additions when we (and others) make changes after the fact.
135
+
136
+ ## Developer Resources
137
+
138
+ We at AppNeta have made a large effort to expose as much technical information as possible to assist developers wishing to contribute to the oboe gem. Below are the three major sources for information and help for developers:
139
+
140
+ * The [TraceView blog](http://www.appneta.com/blog) has a constant stream of great technical articles. (See [A Gentle X-Trace Introduction](http://www.appneta.com/blog/x-trace-introduction/) for details on the basic methodology that TraceView uses to gather structured performance data across hosts and stacks.)
141
+
142
+ * The [TraceView Knowledge Base](https://support.tv.appneta.com) has a large collection of technical articles or, if needed, you can submit a support request directly to the team.
143
+
144
+ * You can also reach the TraceView team on our IRC channel #appneta on freenode.
145
+
146
+ If you have any questions or ideas, don't hesitate to contact us anytime.
147
+
148
+ ## Layout of the Gem
149
+
150
+ The oboe gem uses a standard gem layout. Here are the notable directories.
151
+
152
+ lib/oboe/inst # Auto load directory for various instrumented libraries
153
+ lib/oboe/frameworks # Framework instrumentation directory
154
+ lib/oboe/frameworks/rails # Files specific to Rails instrumentation
155
+ lib/rails # A Rails required directory for the Rails install generator
156
+ lib/api # The TraceView Tracing API: layers, logging, profiling and tracing
157
+ ext/oboe_metal # The Ruby c extension that links against the system liboboe library
158
+
159
+ ## Building the Gem
160
+
161
+ The oboe gem is built with the standard `gem build` command passing in the gemspec:
162
+
163
+ gem build oboe.gemspec
164
+
165
+ ## Writing Custom Instrumentation
166
+
167
+ Custom instrumentation for a library, database or other service can be authored fairly easily. Generally, instrumentation of a library is done by wrapping select operations of that library and timing their execution using the Oboe Tracing API which then reports the metrics to the users' TraceView dashboard.
168
+
169
+ Here, I'll use a stripped down version of the Dalli instrumentation (`lib/oboe/inst/dalli.rb`) as a quick example of how to instrument a client library (the dalli gem).
170
+
171
+ The Dalli gem nicely routes all memcache operations through a single `perform` operation. Wrapping this method allows us to capture all Dalli operations called by an application.
172
+
173
+ First, we define a module (Oboe::Inst::Dalli) and our own custom `perform_with_oboe` method that we will use as a wrapper around Dalli's `perform` method. We also declare an `included` method which automatically gets called when this module is included by another. See ['included' Ruby reference documentation](http://apidock.com/ruby/Module/included).
174
+
175
+ module Oboe
176
+ module Inst
177
+ module Dalli
178
+ include Oboe::API::Memcache
179
+
180
+ def self.included(cls)
181
+ cls.class_eval do
182
+ if ::Dalli::Client.private_method_defined? :perform
183
+ alias perform_without_oboe perform
184
+ alias perform perform_with_oboe
185
+ end
186
+ end
187
+ end
188
+
189
+ def perform_with_oboe(*all_args, &blk)
190
+ op, key, *args = *all_args
191
+
192
+ if Oboe.tracing?
193
+ opts = {}
194
+ opts[:KVOp] = op
195
+ opts[:KVKey] = key
196
+
197
+ Oboe::API.trace('memcache', opts || {}) do
198
+ result = perform_without_oboe(*all_args, &blk)
199
+ if op == :get and key.class == String
200
+ Oboe::API.log('memcache', 'info', { :KVHit => memcache_hit?(result) })
201
+ end
202
+ result
203
+ end
204
+ else
205
+ perform_without_oboe(*all_args, &blk)
206
+ end
207
+ end
208
+ end
209
+ end
210
+ end
211
+
212
+ Second, we tail onto the end of the instrumentation file a simple `::Dalli::Client.module_eval` call to tell the Dalli module to include our newly defined instrumentation module. Doing this will invoke our previously defined `included` method.
213
+
214
+ if defined?(Dalli) and Oboe::Config[:dalli][:enabled]
215
+ ::Dalli::Client.module_eval do
216
+ include Oboe::Inst::Dalli
217
+ end
218
+ end
219
+
220
+ Third, in our wrapper method, we capture the arguments passed in, collect the operation and key information into a local hash and then invoke the `Oboe::API.trace` method to time the execution of the original operation.
221
+
222
+ The `Oboe::API.trace` method calls Dalli's native operation and reports the timing metrics and your custom `report_kvs` up to TraceView servers to be shown on the user's dashboard.
223
+
224
+ That is a very quick example of a simple instrumentation implementation. If you have any questions, visit us on IRC in #appneta on Freenode.
225
+
226
+ Some other tips and guidelines:
227
+
228
+ * You can point your Gemfile directly at your cloned oboe source by using `gem 'oboe', :path => '/path/to/oboe-ruby'`
229
+
230
+ * If instrumenting a library, database or service, place your new instrumentation file into the `lib/oboe/inst/` directory. From there, the oboe gem will detect it and automatically load the instrumentation file.
231
+
232
+ * If instrumentating a new framework, place your instrumentation file in `lib/oboe/frameworks`. Refer to the Rails instrumentation for on ideas on how to load the oboe gem correctly in your framework.
233
+
234
+ * Review other existing instrumention similar to the one you wish to author. `lib/oboe/inst/` is a great place to start.
235
+
236
+ * Depending on the configured `:sample_rate`, not all requests will be traced. Use `Oboe.tracing?` to determine of this is a request that is being traced.
237
+
238
+ * Performance is paramount. Make sure that your wrapped methods don't slow down users applications.
239
+
240
+ * Include tests with your instrumentation. See `test/instrumentation/` for some examples of existing instrumentation tests.
241
+
242
+ ## Compiling the C extension
243
+
244
+ The oboe gem utilizes a C extension to interface with the system `liboboe.so` library. This system library is installed with the TraceView host packages (tracelyzer, liboboe0, liboboe-dev) and is used to report [host](http://www.appneta.com/blog/app-host-metrics/) and performance metrics from multiple sources (Ruby, Apache, Python etc.) back to TraceView servers.
245
+
246
+ C extensions are usually built on `gem install` but when working out of a local git repository, it's required that you manually build this C extension for the gem to function.
247
+
248
+ To make this simpler, we've included a few rake tasks to automate this process:
249
+
250
+ rake compile # Build the gem's c extension
251
+ rake distclean # Remove all built files and extensions
252
+ rake recompile # Rebuild the gem's c extension
253
+
254
+ Note: Make sure you have the development package `liboboe0-dev` installed before attempting to compile the C extension.
255
+
256
+ >$ dpkg -l | grep liboboe
257
+ ii liboboe-dev 1.1.1-precise1 Tracelytics common library -- development files
258
+ ii liboboe0 1.1.1-precise1 Tracelytics common library
259
+
260
+ See [Installing Base Packages on Debian and Ubuntu](https://support.tv.appneta.com/support/solutions/articles/86359-installing-base-packages-on-debian-and-ubuntu) in the Knowledge Base for details. Our hacker extraodinaire [Rob Salmond](https://github.com/rsalmond) from the support team have even gotten these packages to [run on Gentoo](http://www.appneta.com/blog/unsupported-doesnt-work/)!
261
+
262
+ To see the code related to the C extension, take a look at `ext/oboe_metal/extconf.rb` for details.
263
+
264
+ You can read more about Ruby gems with C extensions in the [Rubygems Guides](http://guides.rubygems.org/gems-with-extensions/).
265
+
266
+ ## Running the Tests
267
+
268
+ The tests bundled with the gem are implemented using [Minitest](https://github.com/seattlerb/minitest). The tests are currently used to validate the sanity of the traces generated and basic gem functionality.
269
+
270
+ After a bundle install, the tests can be run as:
271
+
272
+ bundle exec rake test
273
+
274
+ This will run a full end-to-end test suite that covers all supported libraries and databases. Note that this requires all of the supported software (Cassandra, Memcache, Mongo etc.) to be installed, configured and available.
275
+
276
+ Since this is overly burdonsome for casual users, you can run just the tests that you're interested in.
277
+
278
+ To run just the tests for the dalli gem trace validation:
279
+
280
+ bundle exec rake test TEST=test/instrumentation/dalli_test.rb
281
+
282
+ We humbly request that any submitted instrumention is delivered with corresponding test coverage.
283
+
284
+ # License
285
+
286
+ Copyright (c) 2013 Appneta
287
+
288
+ Released under the [AppNeta Open License](http://www.appneta.com/appneta-license), Version 1.0
19
289
 
data/Rakefile CHANGED
@@ -1,12 +1,68 @@
1
- require 'rake/testtask'
2
- require 'rspec/core/rake_task'
1
+ #!/usr/bin/env rake
3
2
 
4
- RSpec::Core::RakeTask.new('spec')
3
+ require 'rubygems'
4
+ require 'bundler/setup'
5
+ require 'rake/testtask'
6
+ require 'appraisal'
5
7
 
6
8
  Rake::TestTask.new do |t|
7
- t.libs << 'spec'
9
+ t.libs << "test"
10
+ t.test_files = FileList['test/**/*_test.rb']
11
+ t.verbose = true
12
+ end
13
+
14
+ task :default => :test
15
+
16
+ desc "Build the gem's c extension"
17
+ task :compile do
18
+ puts "== Building the c extension against Ruby #{RUBY_VERSION}"
19
+
20
+ pwd = Dir.pwd
21
+ ext_dir = File.expand_path('ext/oboe_metal')
22
+ lib_dir = File.expand_path('lib')
23
+ symlink = File.expand_path('lib/oboe_metal.so')
24
+ so_file = File.expand_path('ext/oboe_metal/oboe_metal.so')
25
+
26
+ Dir.chdir ext_dir
27
+ cmd = [ Gem.ruby, 'extconf.rb']
28
+ sh cmd.join(' ')
29
+ sh '/usr/bin/env make'
30
+ File.delete symlink if File.exist? symlink
31
+ File.symlink so_file, symlink
32
+
33
+ Dir.chdir pwd
34
+ puts "== Extension built and symlink'd to #{symlink}"
35
+ end
36
+
37
+ desc "Clean up extension build files"
38
+ task :clean do
39
+ pwd = Dir.pwd
40
+ ext_dir = File.expand_path('ext/oboe_metal')
41
+ lib_dir = File.expand_path('lib')
42
+ symlink = File.expand_path('lib/oboe_metal.so')
43
+ so_file = File.expand_path('ext/oboe_metal/oboe_metal.so')
44
+
45
+ Dir.chdir ext_dir
46
+ sh '/usr/bin/env make clean'
47
+
48
+ Dir.chdir pwd
8
49
  end
9
50
 
10
- desc "Run tests"
11
- task :default => :spec
12
- task :test => :spec
51
+ desc "Remove all built files and extensions"
52
+ task :distclean do
53
+ pwd = Dir.pwd
54
+ ext_dir = File.expand_path('ext/oboe_metal')
55
+ lib_dir = File.expand_path('lib')
56
+ symlink = File.expand_path('lib/oboe_metal.so')
57
+ so_file = File.expand_path('ext/oboe_metal/oboe_metal.so')
58
+
59
+ Dir.chdir ext_dir
60
+ File.delete symlink if File.exist? symlink
61
+ sh '/usr/bin/env make distclean'
62
+
63
+ Dir.chdir pwd
64
+ end
65
+
66
+ desc "Rebuild the gem's c extension"
67
+ task :recompile => [ :distclean, :compile ]
68
+