ruby_ext 0.4.24 → 0.4.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/rake_ext/project.rb +78 -82
  2. data/lib/rake_ext.rb +18 -22
  3. metadata +18 -29
@@ -1,66 +1,29 @@
1
+ # fixing known YAML problem with gems
1
2
  require 'yaml'
2
3
  require 'psych'
3
4
  YAML::ENGINE.yamler = 'syck'
4
5
 
5
- #
6
- # parse_dependencies_for
7
- #
8
- def parse_project_gemfile
9
- required_gems, required_fake_gems = [], []
10
- gem_file = "#{project_dir}/lib/#{project[:name]}/gems.rb"
11
-
12
- if File.exist? gem_file
13
- # puts "Parsing gemfile #{gem_file}"
14
-
15
- code = File.open(gem_file){|f| f.read}
16
-
17
- stub_class = Class.new
18
- stub_class.send(:define_method, :gem){|*args| required_gems << args}
19
- stub_class.send(:define_method, :fake_gem){|*args| required_fake_gems << args}
20
- stub = stub_class.new
21
- stub.instance_eval code, __FILE__, __LINE__
22
- end
23
-
24
- return required_gems, required_fake_gems
25
- end
26
-
27
6
 
28
7
  #
29
- # Install gems
8
+ # Helper for releasing gem, add following code to Your Rakefile:
30
9
  #
31
- namespace :gem do
32
- desc "Install gem required by project"
33
- task :install do
34
- gems, fake_gems = parse_project_gemfile
35
- gems.each do |name, version|
36
- puts "Installing gem #{name} #{version}"
37
- %x(gem install #{name}#{" -v #{version}" if version} --ignore-dependencies)
38
- end
39
- end
40
-
41
- desc "List all gems required by project"
42
- task :list do
43
- puts "Gems required for #{project[:official_name]}:"
44
- gems, fake_gems = parse_project_gemfile
45
- puts(gems + fake_gems)
46
- end
47
-
48
- desc "Install all gem required by project (including fake gems)"
49
- task :install_all do
50
- gems, fake_gems = parse_project_gemfile
51
- (gems + fake_gems).each do |name, version|
52
- puts "Installing gem #{name} #{version}"
53
- %x(gem install #{name} #{"-v #{version}" if version})
54
- end
55
- end
56
- end
57
-
10
+ # project(
11
+ # name: "fake_gem",
12
+ # gem: true,
13
+ # summary: "Makes any directory looks like Ruby Gem",
14
+ #
15
+ # bin: 'bin',
16
+ # executables: ['fake_gem'],
17
+ # dirs: %w(bin),
58
18
  #
59
- # Gem Spec, for sample look at Rakefile
19
+ # author: "Alexey Petrushin",
20
+ # homepage: "http://github.com/alexeypetrushin/fake_gem"
21
+ # )
22
+ #
23
+ # use "rake gem" to release gem
60
24
  #
61
- require 'rake/clean'
62
- require 'rake/gempackagetask'
63
- require 'tmpdir'
25
+
26
+ require 'rubygems/specification'
64
27
 
65
28
  class GemHelper
66
29
  class << self
@@ -73,8 +36,27 @@ class GemHelper
73
36
  return '0.0.1'
74
37
  end
75
38
 
76
- def prepare_gem_metadata
77
- spec = Gem::Specification.new do |s|
39
+ def parse_project_gemfile
40
+ required_gems, required_fake_gems = [], []
41
+ gem_file = "#{project_dir}/lib/#{project[:name]}/gems.rb"
42
+
43
+ if File.exist? gem_file
44
+ # puts "Parsing gemfile #{gem_file}"
45
+
46
+ code = File.open(gem_file){|f| f.read}
47
+
48
+ stub_class = Class.new
49
+ stub_class.send(:define_method, :gem){|*args| required_gems << args}
50
+ stub_class.send(:define_method, :fake_gem){|*args| required_fake_gems << args}
51
+ stub = stub_class.new
52
+ stub.instance_eval code, __FILE__, __LINE__
53
+ end
54
+
55
+ return required_gems, required_fake_gems
56
+ end
57
+
58
+ def gemspec
59
+ Gem::Specification.new do |s|
78
60
  gems, fake_gems = parse_project_gemfile
79
61
  gems = gems + fake_gems
80
62
 
@@ -99,41 +81,55 @@ class GemHelper
99
81
 
100
82
  s.version = options.delete(:version) || GemHelper.next_version(name)
101
83
 
102
- # s.name = options[:name)
103
- # s.author = options[:author)
104
- # s.homepage = options[:homepage)
105
-
106
84
  options.each{|k, v| s.send "#{k}=", v}
107
85
  end
108
-
109
- Rake::GemPackageTask.new(spec) do |p|
110
- p.need_tar = true if RUBY_PLATFORM !~ /mswin/
111
- p.need_zip = true
112
- p.package_dir = package_dir
113
- end
114
- end
115
-
116
- def package_dir
117
- Dir.tmpdir + "/#{project[:official_name]}_tmp"
118
86
  end
119
87
  end
120
88
  end
121
89
 
122
90
  namespace :gem do
123
- task :ensure_gem do
124
- GemHelper.prepare_gem_metadata
91
+ desc "Build and release gem"
92
+ task :release do
93
+ puts ' configuring'
94
+ gemspec = GemHelper.gemspec
95
+ gemspec_file = "#{gemspec.name}.gemspec"
96
+ File.open(gemspec_file, 'w'){|f| f.write gemspec.to_ruby}
97
+
98
+ puts ' building'
99
+ %x(gem build #{gemspec_file})
100
+
101
+ puts ' pushing'
102
+ gem_file = Dir.glob("#{gemspec.name}*.gem").first
103
+ %x"gem push #{gem_file}"
104
+
105
+ puts ' cleaning'
106
+ [gemspec_file, gem_file].each{|f| File.delete f if File.exist? f}
107
+
108
+ puts " #{gemspec.name} #{gemspec.version} successfully released"
125
109
  end
126
110
 
127
- task push: :ensure_gem do
128
- gem_file = Dir.glob("#{GemHelper.package_dir}/#{project[:official_name]}*.gem").first
129
- system "gem push #{gem_file}"
130
- end
131
-
132
- task clean: :ensure_gem do
133
- GemHelper.prepare_gem_metadata
134
- system "rm -r #{GemHelper.package_dir}"
111
+ desc "Install gem required by project"
112
+ task :install do
113
+ gems, fake_gems = parse_project_gemfile
114
+ gems.each do |name, version|
115
+ puts "Installing gem #{name} #{version}"
116
+ %x(gem install #{name}#{" -v #{version}" if version}) # --ignore-dependencies)
117
+ end
118
+ end
119
+
120
+ desc "List all gems required by project"
121
+ task :list do
122
+ puts "Gems required for #{project[:official_name]}:"
123
+ gems, fake_gems = parse_project_gemfile
124
+ puts(gems + fake_gems)
135
125
  end
136
126
 
137
- desc "Build and publish project as gem"
138
- task release: [:ensure_gem, :gem, :push, :clean]
127
+ desc "Install all gem required by project (including fake gems)"
128
+ task :install_all do
129
+ gems, fake_gems = parse_project_gemfile
130
+ (gems + fake_gems).each do |name, version|
131
+ puts "Installing gem #{name} #{version}"
132
+ %x(gem install #{name} #{"-v #{version}" if version})
133
+ end
134
+ end
139
135
  end
data/lib/rake_ext.rb CHANGED
@@ -4,16 +4,16 @@ require 'fileutils'
4
4
  #
5
5
  # Code Coverage
6
6
  #
7
- begin
8
- require 'class_loader/tasks'
9
- rescue LoadError
10
- end
11
- desc "Clean temporary files"
12
- task clean: 'class_loader:clean' do
13
- require 'fileutils'
14
- FileUtils.rm_r '../*/coverage' if File.exist? '../*/coverage'
15
- end
16
-
7
+ # begin
8
+ # require 'class_loader/tasks'
9
+ #
10
+ # desc "Clean code coverage temporary files"
11
+ # task clean: 'class_loader:clean' do
12
+ # require 'fileutils'
13
+ # FileUtils.rm_r '../*/coverage' if File.exist? '../*/coverage'
14
+ # end
15
+ # rescue LoadError
16
+ # end
17
17
 
18
18
  #
19
19
  # Spec
@@ -40,18 +40,6 @@ rescue LoadError
40
40
  end
41
41
  end
42
42
 
43
- #
44
- # project_dir
45
- #
46
- $_project_dir = (
47
- caller.find{|line| line =~ /\/Rakefile\:/} ||
48
- raise("You can include the 'rake_ext' only in Rakefile!")
49
- ).sub(/\/Rakefile\:.*/, '')
50
- def project_dir
51
- $_project_dir
52
- end
53
-
54
-
55
43
  #
56
44
  # before, after and remove task
57
45
  #
@@ -79,6 +67,14 @@ alias :delete_task :remove_task
79
67
  #
80
68
  # project
81
69
  #
70
+ $_project_dir = (
71
+ caller.find{|line| line =~ /\/Rakefile\:/} ||
72
+ raise("You can include the 'rake_ext' only in Rakefile!")
73
+ ).sub(/\/Rakefile\:.*/, '')
74
+ def project_dir
75
+ $_project_dir
76
+ end
77
+
82
78
  def project options = nil
83
79
  if options
84
80
  $_project = {}
metadata CHANGED
@@ -1,28 +1,22 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby_ext
3
- version: !ruby/object:Gem::Version
4
- version: 0.4.24
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.25
5
5
  prerelease:
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Alexey Petrushin
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-08-08 00:00:00 +04:00
14
- default_executable:
12
+ date: 2011-08-10 00:00:00.000000000Z
15
13
  dependencies: []
16
-
17
14
  description:
18
15
  email:
19
16
  executables: []
20
-
21
17
  extensions: []
22
-
23
18
  extra_rdoc_files: []
24
-
25
- files:
19
+ files:
26
20
  - Rakefile
27
21
  - readme.md
28
22
  - lib/rake_ext/project.rb
@@ -79,33 +73,28 @@ files:
79
73
  - spec/more/open_constructor_spec.rb
80
74
  - spec/more/spec_helper.rb
81
75
  - spec/more/synchronize_spec.rb
82
- has_rdoc: true
83
76
  homepage: http://github.com/alexeypetrushin/ruby_ext
84
77
  licenses: []
85
-
86
78
  post_install_message:
87
79
  rdoc_options: []
88
-
89
- require_paths:
80
+ require_paths:
90
81
  - lib
91
- required_ruby_version: !ruby/object:Gem::Requirement
82
+ required_ruby_version: !ruby/object:Gem::Requirement
92
83
  none: false
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: "0"
97
- required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
89
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: "0"
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
103
94
  requirements: []
104
-
105
95
  rubyforge_project:
106
- rubygems_version: 1.5.1
96
+ rubygems_version: 1.8.6
107
97
  signing_key:
108
98
  specification_version: 3
109
99
  summary: Ruby Extensions
110
100
  test_files: []
111
-