ruby_ext 0.4.7 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,12 +3,11 @@ $LOAD_PATH << lib_dir unless $LOAD_PATH.include? lib_dir
3
3
 
4
4
  require 'rake_ext'
5
5
 
6
- gem_spec(
6
+ project(
7
7
  :name => "ruby_ext",
8
- :version => "0.4.7",
8
+ :version => "0.4.9",
9
9
  :summary => "Ruby language extensions",
10
10
 
11
11
  :author => "Alexey Petrushin",
12
- :homepage => "http://github.com/alexeypetrushin/ruby_ext",
13
- :dependencies => %w(facets)
12
+ :homepage => "http://github.com/alexeypetrushin/ruby_ext"
14
13
  )
@@ -0,0 +1,86 @@
1
+ #
2
+ # parse_dependencies_for
3
+ #
4
+ def parse_project_gemfile
5
+ required_gems = []
6
+ gem_file = "#{project_dir}/lib/#{project[:name]}/gems.rb"
7
+ if File.exist? gem_file
8
+ puts "Parsing gemfile #{gem_file}"
9
+
10
+ code = File.open(gem_file){|f| f.read}
11
+
12
+ stub_class = Class.new
13
+ stub_class.send(:define_method, :gem){|*args| required_gems << args}
14
+ stub = stub_class.new
15
+ stub.instance_eval code, __FILE__, __LINE__
16
+ end
17
+ required_gems
18
+ end
19
+
20
+
21
+ #
22
+ # Install gems
23
+ #
24
+ namespace :gem do
25
+ desc "Install gem required by project"
26
+ task :install do
27
+ gems = parse_project_gemfile
28
+ gems.each do |name, version|
29
+ puts "Installing gem #{name} #{version}"
30
+ %x(gem install #{name} #{"-v #{version}" if version})
31
+ end
32
+ end
33
+ end
34
+
35
+
36
+ #
37
+ # Gem Spec, for sample look at Rakefile
38
+ #
39
+ require 'rake/clean'
40
+ require 'rake/gempackagetask'
41
+ require 'tmpdir'
42
+
43
+ namespace :gem do
44
+ spec = Gem::Specification.new do |s|
45
+ gems = parse_project_gemfile
46
+ gems.each{|name_version| s.add_dependency *name_version}
47
+
48
+ options = project.clone
49
+
50
+ s.platform = options.delete(:platform) || Gem::Platform::RUBY
51
+ s.has_rdoc = options.delete(:has_rdoc) == nil ? false : true
52
+ s.require_path = options.delete(:lib) || "lib"
53
+ s.files = options.delete(:files) || (%w{Rakefile readme.md} + Dir.glob("{lib,spec}/**/*"))
54
+
55
+ # s.name = options[:name)
56
+ # s.author = options[:author)
57
+ # s.homepage = options[:homepage)
58
+
59
+ options.each{|k, v| s.send "#{k}=", v}
60
+ end
61
+
62
+ package_dir = Dir.tmpdir
63
+ Rake::GemPackageTask.new(spec) do |p|
64
+ p.need_tar = true if RUBY_PLATFORM !~ /mswin/
65
+ p.need_zip = true
66
+ p.package_dir = package_dir
67
+ end
68
+
69
+ task :push do
70
+ gem_file = Dir.glob("#{package_dir}/#{project[:name]}*.gem").first
71
+ system "gem push #{gem_file}"
72
+ end
73
+
74
+ task :clean do
75
+ system "rm -r #{package_dir}"
76
+ end
77
+
78
+ desc "List all gems required by project"
79
+ task :list do
80
+ puts "Gems required for #{project[:name]}:"
81
+ puts parse_project_gemfile
82
+ end
83
+
84
+ desc "Build and publish project as gem"
85
+ task :release => [:gem, :push, :clean]
86
+ end
data/lib/rake_ext.rb CHANGED
@@ -2,7 +2,45 @@ require 'rake'
2
2
  require 'fileutils'
3
3
 
4
4
  #
5
- # Rake extensions
5
+ # Spec
6
+ #
7
+ begin
8
+ require 'rspec/core/rake_task'
9
+ task :default => :spec
10
+
11
+ RSpec::Core::RakeTask.new('spec') do |t|
12
+ t.pattern = "spec/**/[^_]*_spec.rb"
13
+ end
14
+
15
+ namespace :spec do
16
+
17
+ desc "Run RSpec code exapmples in isolated mode (every spec file in another Ruby process)"
18
+ task :isolated do
19
+ Dir.glob("spec/**/[^_]*_spec.rb").each do |spec_file|
20
+ Kernel.system "rspec #{spec_file}"
21
+ end
22
+ end
23
+ end
24
+ rescue LoadError
25
+ task :default do
26
+ puts "default rake task is :rspec but there's no rspec gem installed, install it first"
27
+ end
28
+ end
29
+
30
+ #
31
+ # project_dir
32
+ #
33
+ PROJECT_DIR = (
34
+ caller.find{|line| line =~ /\/Rakefile\:/} ||
35
+ raise("You can include the '' file only in Rakefile!")
36
+ ).sub(/\/Rakefile\:.*/, '')
37
+ def project_dir
38
+ PROJECT_DIR
39
+ end
40
+
41
+
42
+ #
43
+ # before & after task
6
44
  #
7
45
  def before task_name, &block
8
46
  @task_counter ||= {}
@@ -21,53 +59,16 @@ end
21
59
 
22
60
 
23
61
  #
24
- # Spec
62
+ # project
25
63
  #
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}/**/*"))
64
+ def project options = nil
65
+ if options
66
+ @options = {}
67
+ options.each{|k, v| @options[k.to_sym] = v}
48
68
 
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}"
69
+ @options[:name] || raise("project name not defined")
70
+
71
+ require 'rake_ext/project'
70
72
  end
71
-
72
- task :release => [:gem, :push, :clean]
73
+ @options || raise("project not defined!")
73
74
  end
@@ -0,0 +1 @@
1
+ gem 'facets', '2.9.0'
data/lib/ruby_ext.rb CHANGED
@@ -1,10 +1,12 @@
1
+ require 'ruby_ext/gems'
2
+
1
3
  core = [
2
4
  'facets/array/indexable', # Array first!, last!
3
5
  'facets/enumerable/every',
4
6
  'facets/enumerable/group_by',
5
7
  'facets/exception/detail', # pretty print
6
- 'facets/duplicable', # false.dup(), false.clone() and so on.
7
- 'facets/blank',
8
+ 'facets/object/dup', # false.dup(), false.clone() and so on.
9
+ 'facets/kernel/blank',
8
10
  'facets/numeric/round.rb', # round_at, round_to
9
11
  'facets/hash',
10
12
  'facets/string/interpolate',
data/spec/array_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/array"
3
3
 
4
4
  describe 'Array' do
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/declarative_cache"
3
3
 
4
4
  describe 'DeclarativeCache' do
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/deep_clone"
3
3
 
4
4
  describe 'deep_clone' do
data/spec/kernel_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/kernel"
3
3
 
4
4
  describe 'Kernel' do
data/spec/module_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/module"
3
3
  require 'ruby_ext/multiple_inheritance'
4
4
 
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/multiple_inheritance"
3
3
 
4
4
  describe "Multiple Inheritance" do
data/spec/must_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/array"
3
3
  require "ruby_ext/must"
4
4
 
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/observable2"
3
3
 
4
4
  describe "Observable" do
@@ -14,29 +14,29 @@ describe "Observable" do
14
14
  obs.notify_observers :update, 2
15
15
  end
16
16
 
17
- # it "Method without Parameters" do
18
- # mock = mock("Observer")
19
- # obs = AnObservable.new
20
- # obs.add_observer(mock, :method => :custom_update, :filter => lambda{|o| o == 2})
21
- # mock.should_receive(:custom_update).with(2)
22
- # obs.notify_observers 2
23
- # obs.notify_observers 4
24
- # end
25
- #
26
- # it "With Block" do
27
- # mock = mock("Observer")
28
- # mock.should_receive(:got)
29
- # obs = AnObservable.new
30
- # obs.add_observer{mock.got}
31
- # obs.notify_observers
32
- # end
33
- #
34
- # it "With Block and Filter" do
35
- # mock = mock("Observer")
36
- # obs = AnObservable.new
37
- # obs.add_observer(:filter => lambda{|o| o == 2}){|o| mock.got o}
38
- # mock.should_receive(:got).with(2)
39
- # obs.notify_observers 2
40
- # obs.notify_observers 4
41
- # end
17
+ # it "Method without Parameters" do
18
+ # mock = mock("Observer")
19
+ # obs = AnObservable.new
20
+ # obs.add_observer(mock, :method => :custom_update, :filter => lambda{|o| o == 2})
21
+ # mock.should_receive(:custom_update).with(2)
22
+ # obs.notify_observers 2
23
+ # obs.notify_observers 4
24
+ # end
25
+ #
26
+ # it "With Block" do
27
+ # mock = mock("Observer")
28
+ # mock.should_receive(:got)
29
+ # obs = AnObservable.new
30
+ # obs.add_observer{mock.got}
31
+ # obs.notify_observers
32
+ # end
33
+ #
34
+ # it "With Block and Filter" do
35
+ # mock = mock("Observer")
36
+ # obs = AnObservable.new
37
+ # obs.add_observer(:filter => lambda{|o| o == 2}){|o| mock.got o}
38
+ # mock.should_receive(:got).with(2)
39
+ # obs.notify_observers 2
40
+ # obs.notify_observers 4
41
+ # end
42
42
  end
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/open_constructor"
3
3
 
4
4
  describe 'OpenConstructor' do
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/array"
3
3
 
4
4
  describe 'OpenObject' do
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/prepare_arguments"
3
3
 
4
4
  describe "Prepare Arguments" do
data/spec/should_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/should"
3
3
 
4
4
  describe 'Assert' do
File without changes
@@ -1,4 +1,4 @@
1
- require "#{File.dirname __FILE__}/helper"
1
+ require "spec_helper"
2
2
  require "ruby_ext/synchronize"
3
3
 
4
4
  describe "Synchronize" do
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: 1
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 7
10
- version: 0.4.7
9
+ - 9
10
+ version: 0.4.9
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-13 00:00:00 +04:00
18
+ date: 2010-10-14 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -24,12 +24,14 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ">="
27
+ - - "="
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 43
30
30
  segments:
31
+ - 2
32
+ - 9
31
33
  - 0
32
- version: "0"
34
+ version: 2.9.0
33
35
  type: :runtime
34
36
  version_requirements: *id001
35
37
  description:
@@ -43,6 +45,7 @@ extra_rdoc_files: []
43
45
  files:
44
46
  - Rakefile
45
47
  - readme.md
48
+ - lib/rake_ext/project.rb
46
49
  - lib/rake_ext.rb
47
50
  - lib/rspec_ext.rb
48
51
  - lib/ruby_ext/array.rb
@@ -52,6 +55,7 @@ files:
52
55
  - lib/ruby_ext/deep_clone.rb
53
56
  - lib/ruby_ext/extra_blank_slate.rb
54
57
  - lib/ruby_ext/file.rb
58
+ - lib/ruby_ext/gems.rb
55
59
  - lib/ruby_ext/hash.rb
56
60
  - lib/ruby_ext/kernel.rb
57
61
  - lib/ruby_ext/micelaneous.rb
@@ -76,7 +80,6 @@ files:
76
80
  - spec/array_spec.rb
77
81
  - spec/declarative_cache_spec.rb
78
82
  - spec/deep_clone_spec.rb
79
- - spec/helper.rb
80
83
  - spec/kernel_spec/another_class.rb
81
84
  - spec/kernel_spec/the_namespace/class_b.rb
82
85
  - spec/kernel_spec/TheNamespace/ClassA.rb
@@ -89,6 +92,7 @@ files:
89
92
  - spec/open_object_spec.rb
90
93
  - spec/prepare_arguments_spec.rb
91
94
  - spec/should_spec.rb
95
+ - spec/spec_helper.rb
92
96
  - spec/synchronize_spec.rb
93
97
  has_rdoc: true
94
98
  homepage: http://github.com/alexeypetrushin/ruby_ext