ruby_ext 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +10 -60
- data/lib/rake_ext.rb +73 -0
- data/lib/rspec_ext.rb +43 -0
- data/lib/ruby_ext/extra_blank_slate.rb +2 -1
- data/lib/ruby_ext/synchronize.rb +4 -2
- data/lib/rubyopt.rb +7 -0
- data/spec/helper.rb +1 -2
- metadata +7 -6
- data/lib/spec_ext.rb +0 -10
- data/spec/spec.opts +0 -2
data/Rakefile
CHANGED
@@ -1,64 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
current_dir = File.expand_path(File.dirname(__FILE__))
|
4
|
-
Dir.chdir current_dir
|
1
|
+
lib_dir = File.expand_path(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH << lib_dir unless $LOAD_PATH.include? lib_dir
|
5
3
|
|
4
|
+
require 'rake_ext'
|
6
5
|
|
7
|
-
|
8
|
-
# Specs
|
9
|
-
#
|
10
|
-
require 'spec/rake/spectask'
|
11
|
-
|
12
|
-
task :default => :spec
|
13
|
-
|
14
|
-
Spec::Rake::SpecTask.new('spec') do |t|
|
15
|
-
t.spec_files = FileList["spec/**/*_spec.rb"].select{|f| f !~ /\/_/}
|
16
|
-
t.libs = ["#{current_dir}/lib"]
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
#
|
21
|
-
# Gem
|
22
|
-
#
|
23
|
-
require 'rake/clean'
|
24
|
-
require 'rake/gempackagetask'
|
25
|
-
|
26
|
-
gem_options = {
|
6
|
+
gem_spec(
|
27
7
|
:name => "ruby_ext",
|
28
|
-
:version => "0.4.
|
29
|
-
:summary => "Ruby language extensions",
|
30
|
-
:dependencies => %w(facets)
|
31
|
-
}
|
8
|
+
:version => "0.4.7",
|
9
|
+
:summary => "Ruby language extensions",
|
32
10
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
s.author = "Alexey Petrushin"
|
38
|
-
s.homepage = "http://github.com/alexeypetrushin/#{gem_options[:name]}"
|
39
|
-
s.require_path = "lib"
|
40
|
-
s.files = (%w{Rakefile readme.md} + Dir.glob("{lib,spec}/**/*"))
|
41
|
-
|
42
|
-
s.platform = Gem::Platform::RUBY
|
43
|
-
s.has_rdoc = true
|
44
|
-
end
|
45
|
-
|
46
|
-
package_dir = "#{current_dir}/build"
|
47
|
-
Rake::GemPackageTask.new(spec) do |p|
|
48
|
-
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
49
|
-
p.need_zip = true
|
50
|
-
p.package_dir = package_dir
|
51
|
-
end
|
52
|
-
|
53
|
-
task :push do
|
54
|
-
# dir = Dir.chdir package_dir do
|
55
|
-
gem_file = Dir.glob("#{package_dir}/#{gem_options[:name]}*.gem").first
|
56
|
-
system "gem push #{gem_file}"
|
57
|
-
# end
|
58
|
-
end
|
59
|
-
|
60
|
-
task :clean do
|
61
|
-
system "rm -r #{package_dir}"
|
62
|
-
end
|
63
|
-
|
64
|
-
task :release => [:gem, :push, :clean]
|
11
|
+
:author => "Alexey Petrushin",
|
12
|
+
:homepage => "http://github.com/alexeypetrushin/ruby_ext",
|
13
|
+
:dependencies => %w(facets)
|
14
|
+
)
|
data/lib/rake_ext.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
#
|
5
|
+
# Rake extensions
|
6
|
+
#
|
7
|
+
def before task_name, &block
|
8
|
+
@task_counter ||= {}
|
9
|
+
counter = (@task_counter[task_name] ||= 0)
|
10
|
+
before_task_name = "#{task_name}_before_#{counter}"
|
11
|
+
|
12
|
+
task before_task_name, &block
|
13
|
+
task task_name => before_task_name
|
14
|
+
|
15
|
+
@task_counter[task_name] += 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def after task_name, &block
|
19
|
+
task task_name, &block
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
#
|
24
|
+
# Spec
|
25
|
+
#
|
26
|
+
require 'rspec/core/rake_task'
|
27
|
+
task :default => :spec
|
28
|
+
|
29
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
30
|
+
t.pattern = "spec/**/[^_]*_spec.rb"
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
#
|
35
|
+
# Gem Spec, for sample look at Rakefile
|
36
|
+
#
|
37
|
+
def gem_spec options
|
38
|
+
require 'rake/clean'
|
39
|
+
require 'rake/gempackagetask'
|
40
|
+
require 'tmpdir'
|
41
|
+
|
42
|
+
spec = Gem::Specification.new do |s|
|
43
|
+
(options.delete(:dependencies) || []).each{|d| s.add_dependency d}
|
44
|
+
s.platform = options.delete(:platform) || Gem::Platform::RUBY
|
45
|
+
s.has_rdoc = options.delete(:has_rdoc) == nil ? false : true
|
46
|
+
s.require_path = options.delete(:lib) || "lib"
|
47
|
+
s.files = options.delete(:files) || (%w{Rakefile readme.md} + Dir.glob("{lib,spec}/**/*"))
|
48
|
+
|
49
|
+
# s.name = options[:name)
|
50
|
+
# s.author = options[:author)
|
51
|
+
# s.homepage = options[:homepage)
|
52
|
+
|
53
|
+
options.each{|k, v| s.send "#{k}=", v}
|
54
|
+
end
|
55
|
+
|
56
|
+
package_dir = Dir.tmpdir
|
57
|
+
Rake::GemPackageTask.new(spec) do |p|
|
58
|
+
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
59
|
+
p.need_zip = true
|
60
|
+
p.package_dir = package_dir
|
61
|
+
end
|
62
|
+
|
63
|
+
task :push do
|
64
|
+
gem_file = Dir.glob("#{package_dir}/#{options[:name]}*.gem").first
|
65
|
+
system "gem push #{gem_file}"
|
66
|
+
end
|
67
|
+
|
68
|
+
task :clean do
|
69
|
+
system "rm -r #{package_dir}"
|
70
|
+
end
|
71
|
+
|
72
|
+
task :release => [:gem, :push, :clean]
|
73
|
+
end
|
data/lib/rspec_ext.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
RSpec.configure do |c|
|
5
|
+
c.filter_run :focus => true
|
6
|
+
c.run_all_when_everything_filtered = true
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec::Core::ExampleGroup.class_eval do
|
10
|
+
def remove_constants *args
|
11
|
+
args = args.first if args.size == 1 and args.first.is_a?(Array)
|
12
|
+
args.each{|c| Object.send :remove_const, c if Object.const_defined? c}
|
13
|
+
end
|
14
|
+
|
15
|
+
def prepare_spec_data spec_file_name
|
16
|
+
dir = File.expand_path(spec_file_name.sub(/\.rb$/, ''))
|
17
|
+
original_data_dir = dir + "_data"
|
18
|
+
|
19
|
+
FileUtils.rm_r dir if File.exist? dir
|
20
|
+
FileUtils.cp_r original_data_dir, dir
|
21
|
+
|
22
|
+
dir
|
23
|
+
end
|
24
|
+
|
25
|
+
def clean_spec_data spec_file_name
|
26
|
+
dir = spec_file_name.sub(/\.rb$/, '')
|
27
|
+
FileUtils.rm_r dir if File.exist? dir
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class String
|
32
|
+
# unless "".respond_to? :dirname
|
33
|
+
def dirname
|
34
|
+
File.expand_path(File.dirname(self))
|
35
|
+
end
|
36
|
+
# end
|
37
|
+
|
38
|
+
unless "".respond_to? :parent_dirname
|
39
|
+
def parent_dirname
|
40
|
+
File.expand_path(File.dirname(self) + "/..")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/ruby_ext/synchronize.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'monitor'
|
2
2
|
|
3
3
|
class Module
|
4
|
-
def synchronize_method *methods
|
5
|
-
methods.each do |method|
|
4
|
+
def synchronize_method *methods
|
5
|
+
methods.each do |method|
|
6
|
+
raise "Can't synchronize system method #{method}" if method.to_s =~ /^__/
|
7
|
+
|
6
8
|
als = "sync_#{escape_method(method)}"
|
7
9
|
|
8
10
|
raise "Can't synchronize the '#{method}' twice!" if instance_methods.include?(als)
|
data/lib/rubyopt.rb
ADDED
data/spec/helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 7
|
10
|
+
version: 0.4.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alexey Petrushin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-13 00:00:00 +04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -43,6 +43,8 @@ extra_rdoc_files: []
|
|
43
43
|
files:
|
44
44
|
- Rakefile
|
45
45
|
- readme.md
|
46
|
+
- lib/rake_ext.rb
|
47
|
+
- lib/rspec_ext.rb
|
46
48
|
- lib/ruby_ext/array.rb
|
47
49
|
- lib/ruby_ext/basic_object.rb
|
48
50
|
- lib/ruby_ext/class.rb
|
@@ -69,7 +71,7 @@ files:
|
|
69
71
|
- lib/ruby_ext/synchronize.rb
|
70
72
|
- lib/ruby_ext/tuple.rb
|
71
73
|
- lib/ruby_ext.rb
|
72
|
-
- lib/
|
74
|
+
- lib/rubyopt.rb
|
73
75
|
- spec/_prototype_inheritance_spec.rb
|
74
76
|
- spec/array_spec.rb
|
75
77
|
- spec/declarative_cache_spec.rb
|
@@ -87,7 +89,6 @@ files:
|
|
87
89
|
- spec/open_object_spec.rb
|
88
90
|
- spec/prepare_arguments_spec.rb
|
89
91
|
- spec/should_spec.rb
|
90
|
-
- spec/spec.opts
|
91
92
|
- spec/synchronize_spec.rb
|
92
93
|
has_rdoc: true
|
93
94
|
homepage: http://github.com/alexeypetrushin/ruby_ext
|
data/lib/spec_ext.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'spec'
|
2
|
-
|
3
|
-
Spec::Example::ExampleGroup.class_eval do
|
4
|
-
def remove_constants *args
|
5
|
-
args = args.first if args.size == 1 and args.first.is_a?(Array)
|
6
|
-
# args.each{|c| raise "Invalid constant name '#{c}'!" unless c =~ /^[a-z_][a-z_0-9]*$/i}
|
7
|
-
# args = args.first if args.first.is_a?(Array)
|
8
|
-
args.each{|c| Object.send :remove_const, c if Object.const_defined? c}
|
9
|
-
end
|
10
|
-
end
|
data/spec/spec.opts
DELETED