File: Rakefile

package info (click to toggle)
ruby-binding-of-caller 0.7.2%2Bdebian1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 176 kB
  • ctags: 65
  • sloc: ruby: 308; ansic: 173; makefile: 9
file content (134 lines) | stat: -rwxr-xr-x 3,205 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
dlext = RbConfig::CONFIG['DLEXT']
direc = File.dirname(__FILE__)

$:.unshift 'lib'

require 'rake/clean'
require 'rubygems/package_task'

require "binding_of_caller/version"

CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
              "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*#*", "**/*#*.*",
              "ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake", "**/*.rbc")

def mri_2?
  defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" &&
    RUBY_VERSION =~ /^2/
end

def apply_spec_defaults(s)
  s.name = "binding_of_caller"
  s.summary = "Retrieve the binding of a method's caller. Can also retrieve bindings even further up the stack."
  s.version = BindingOfCaller::VERSION
  s.date = Time.now.strftime '%Y-%m-%d'
  s.author = "John Mair (banisterfiend)"
  s.email = 'jrmair@gmail.com'
  s.description = s.summary
  s.require_path = 'lib'
  s.add_dependency 'debug_inspector', '>= 0.0.1'
  s.add_development_dependency 'bacon'
  s.add_development_dependency 'rake'
  s.homepage = "http://github.com/banister/binding_of_caller"
  s.has_rdoc = 'yard'
  s.files = `git ls-files`.split("\n")
  s.test_files = `git ls-files -- test/*`.split("\n")
end

desc "Show version"
task :version do
  puts "BindingOfCaller version: #{BindingOfCaller::VERSION}"
end

desc "run tests"
task :default => [:test]

desc "Run tests"
task :test do
  unless defined?(Rubinius)
    Rake::Task['compile'].execute
  end

  $stdout.puts("\033[33m")
  sh "bacon -Itest -rubygems -a -q"
  $stdout.puts("\033[0m")

  unless defined?(Rubinius)
    Rake::Task['cleanup'].execute
  end
end

task :pry do
  puts "loading binding_of_caller into pry"
  sh "pry -r ./lib/binding_of_caller"
end

desc "generate gemspec"
task :gemspec => "ruby:gemspec"

namespace :ruby do
  spec = Gem::Specification.new do |s|
    apply_spec_defaults(s)
    s.platform = Gem::Platform::RUBY
    s.extensions = ["ext/binding_of_caller/extconf.rb"]
  end

  Gem::PackageTask.new(spec) do |pkg|
    pkg.need_zip = false
    pkg.need_tar = false
  end

  desc  "Generate gemspec file"
  task :gemspec do
    File.open("#{spec.name}.gemspec", "w") do |f|
      f << spec.to_ruby
    end
  end
end

desc "build the binaries"
task :compile => :cleanup do
  if !mri_2?  
    chdir "./ext/binding_of_caller/" do
      sh "ruby extconf.rb"
      sh "make"
      sh "cp *.#{dlext} ../../lib/"
    end
  end
end

desc 'cleanup the extensions'
task :cleanup do
  if !mri_2?
    sh 'rm -rf lib/binding_of_caller.so'
    chdir "./ext/binding_of_caller/" do
      sh 'make clean' 
    end
  end
end

desc "reinstall gem"
task :reinstall => :gems do
  sh "gem uninstall binding_of_caller" rescue nil
  sh "gem install #{direc}/pkg/binding_of_caller-#{BindingOfCaller::VERSION}.gem"
end

task :install => :reinstall

desc "build all platform gems at once"
task :gems => [:clean, :rmgems, "ruby:gem"]

task :gem => [:gems]

desc "remove all platform gems"
task :rmgems => ["ruby:clobber_package"]

desc "build and push latest gems"
task :pushgems => :gems do
  chdir("./pkg") do
    Dir["*.gem"].each do |gemfile|
      sh "gem push #{gemfile}"
    end
  end
end