public
Description: Modular ruby RPC library with blocking and evented API (using EventMachine)
Homepage:
Clone URL: git://github.com/oleganza/emrpc.git
Click here to lend your support to: emrpc and make a donation at www.pledgie.com !
commit  d9535c00689e7161552acff194b5a34a08158193
tree    08054aec153645c9aefb24097346194d9d15428b
parent  952dbc939218c164f32bc5bafebba616b5af2d38
emrpc / Rakefile
100644 157 lines (124 sloc) 4.063 kb
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
require "rake"
require "rake/clean"
require "rake/gempackagetask"
require "rake/rdoctask"
require "rake/testtask"
require "spec/rake/spectask"
require "fileutils"
 
 
##############################################################################
# Automated tests
##############################################################################
 
desc "Run specs"
task :spec => :'specs:spec'
task :specs => :'specs:spec'
 
namespace :specs do
  
  def spec_path
    path = ENV['SPECS_PATH'] || "spec"
    puts "Using #{path.inspect} path. (See SPECS_PATH environment variable.)"
    path
  end
  
  desc "Run specs"
  task :spec do
    system("spec #{spec_path} -c")
  end
  
  desc "Runs specs set by SPECS_PATH (default is 'spec') in a loop detecting random errors"
  task :loop do
    def run_spec_iteration(path = "spec", counter = 0)
      r = `spec #{path}`
      if r =~ /(\A|[.PFE])[FE]/ || r =~ /[FE]([.PFE]|\z)/
        puts r
        counter + 1
      else
        counter
      end
    end
    path = spec_path
    iters = (ENV['SPECS_ITERS'] || 10_000).to_i
    puts "#{iters} iterations. (See SPECS_ITERS environment variable.)"
    fs = 0
    iters.times do |i|
      puts "Iterations: #{i} Failures: #{fs}"
      fs = run_spec_iteration(path, fs)
    end
  end
end
 
 
##############################################################################
# Packaging & Installation
##############################################################################
 
def __DIR__
  File.dirname(__FILE__)
end
 
include FileUtils
 
require "lib/emrpc/version"
 
def sudo
  ENV['EMRPC_SUDO'] ||= "sudo"
  sudo = windows? ? "" : ENV['EMRPC_SUDO']
end
 
def windows?
  (PLATFORM =~ /win32|cygwin/) rescue nil
end
 
def install_home
  ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
end
 
CLEAN.include ["**/.*.sw?", "pkg", "lib/*.bundle", "*.gem", "doc/rdoc", ".config", "coverage", "cache"]
 
desc "Run the specs."
task :default => :specs
 
task :emrpc => [:clean, :rdoc, :package]
 
RUBY_FORGE_PROJECT = "emrpc"
PROJECT_URL = "http://oleganza.com/"
PROJECT_SUMMARY = "Efficient RPC library with evented and blocking APIs. In all ways better than DRb."
PROJECT_DESCRIPTION = PROJECT_SUMMARY
 
AUTHOR = "Oleg Andreev"
EMAIL = "oleganza@gmail.com"
 
GEM_NAME = "emrpc"
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
GEM_VERSION = EMRPC::VERSION + PKG_BUILD
 
RELEASE_NAME = "REL #{GEM_VERSION}"
 
require "extlib/tasks/release"
 
spec = Gem::Specification.new do |s|
  s.name = GEM_NAME
  s.version = GEM_VERSION
  s.platform = Gem::Platform::RUBY
  s.author = AUTHOR
  s.email = EMAIL
  s.homepage = PROJECT_URL
  s.summary = PROJECT_SUMMARY
  s.bindir = "bin"
  s.description = s.summary
  s.executables = %w( emrpc )
  s.require_path = "lib"
  s.files = %w( README Rakefile TODO MIT-LICENSE ) + Dir["{docs,bin,spec,lib,examples,script}/**/*"]
 
  # rdoc
  s.has_rdoc = true
  s.extra_rdoc_files = %w( README TODO MIT-LICENSE )
  #s.rdoc_options += RDOC_OPTS + ["--exclude", "^(app|uploads)"]
 
  # Dependencies
  s.add_dependency "eventmachine"
  s.add_dependency "rake"
  s.add_dependency "rspec"
  
  # See sources on github.com/oleganza
  s.add_dependency "gem_console"
  
  # Requirements
  s.requirements << "You need to install the json (or json_pure), yaml, rack gems to use related features."
  s.required_ruby_version = ">= 1.8.4"
end
 
Rake::GemPackageTask.new(spec) do |package|
  package.gem_spec = spec
end
 
desc "Generate *.gemspec file"
task :gemspec do
  gemspec = "spec = " + spec.to_ruby
  path = File.join(File.expand_path(File.dirname(__FILE__)), "emrpc.gemspec")
  puts %{Writing "#{path}"}
  File.open(path, "w") do |f|
    f.write(gemspec)
  end
end
 
desc "Run :package and install the resulting .gem"
task :install => :package do
  sh %{#{sudo} gem install #{install_home} --local pkg/#{GEM_NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
end
 
desc "Run :clean and uninstall the .gem"
task :uninstall => :clean do
  sh %{#{sudo} gem uninstall #{GEM_NAME}}
end