rubygems-tasks 0.1.0.pre2 → 0.1.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  doc/
2
2
  pkg/
3
+ data/projects/
data/ChangeLog.md CHANGED
@@ -1,4 +1,21 @@
1
1
  ### 0.1.0 / 2011-08-30
2
2
 
3
3
  * Initial release:
4
-
4
+ * Added {Gem::Tasks::Project}.
5
+ * Added {Gem::Tasks::Printing}.
6
+ * Added {Gem::Tasks::Task}.
7
+ * Added {Gem::Tasks::Build::Task}.
8
+ * Added {Gem::Tasks::Build::Gem}.
9
+ * Added {Gem::Tasks::Build::Tar}.
10
+ * Added {Gem::Tasks::Build::Zip}.
11
+ * Added {Gem::Tasks::SCM::Push}.
12
+ * Added {Gem::Tasks::SCM::Status}.
13
+ * Added {Gem::Tasks::SCM::Tag}.
14
+ * Added {Gem::Tasks::Sign::Task}.
15
+ * Added {Gem::Tasks::Sign::Checksum}.
16
+ * Added {Gem::Tasks::Sign::PGP}.
17
+ * Added {Gem::Tasks::Console}.
18
+ * Added {Gem::Tasks::Install}.
19
+ * Added {Gem::Tasks::Push}.
20
+ * Added {Gem::Tasks::Release}.
21
+ * Added {Gem::Tasks}.
data/README.md CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  ## Description
8
8
 
9
- rubygems-tasks provides simple Rake tasks for building, installing and releasing
10
- Ruby gems.
9
+ rubygems-tasks provides unobtrusive Rake tasks for building, installing and
10
+ releasing Ruby Gems.
11
11
 
12
12
  require 'rubygems/tasks'
13
13
  Gem::Tasks.new
data/Rakefile CHANGED
@@ -33,3 +33,47 @@ rescue LoadError => e
33
33
  abort 'Please run `gem install yard` to install YARD.'
34
34
  end
35
35
  end
36
+
37
+ require 'net/https'
38
+ require 'uri'
39
+
40
+ DOWNLOAD_URI = 'http://cloud.github.com/downloads/postmodern/rubygems-tasks/'
41
+ PROJECTS_DIR = File.join('data','projects')
42
+ PROJECTS = %w[rubygems-project rubygems-multi-project bundler-project]
43
+
44
+ directory PROJECTS_DIR
45
+
46
+ PROJECTS.each do |project|
47
+ project_file = "#{project}.tar.gz"
48
+ project_path = File.join(PROJECTS_DIR,project_file)
49
+ project_dir = File.join(PROJECTS_DIR,project)
50
+
51
+ file project_path => PROJECTS_DIR do
52
+ Net::HTTP.get_response(URI(DOWNLOAD_URI + project_file)) do |response|
53
+ size, total = 0, response.header['Content-Length'].to_i
54
+
55
+ puts ">>> Downloading to #{project_file} to #{project_path} ..."
56
+
57
+ File.open(project_path,"wb") do |file|
58
+ response.read_body do |chunk|
59
+ file.write(chunk)
60
+
61
+ size += chunk.size
62
+ printf "\r>>> [%d / %d] %d%% ...", size, total, ((size * 100) / total)
63
+ end
64
+ end
65
+
66
+ puts
67
+ end
68
+ end
69
+
70
+ task project_dir => project_path do
71
+ unless File.directory?(project_dir)
72
+ sh 'tar', 'xzf', project_path, '-C', PROJECTS_DIR
73
+ end
74
+ end
75
+
76
+ task 'data:projects' => project_dir
77
+ end
78
+
79
+ task :spec => 'data:projects'
data/gemspec.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  name: rubygems-tasks
2
- version: 0.1.0.pre2
3
- summary: Rake tasks for managing and releasing Ruby projects.
2
+ version: 0.1.0.pre3
3
+ summary: Rake tasks for managing and releasing Ruby Gems.
4
4
  description:
5
- Simple Rake tasks for managing and releasing Ruby projects.
5
+ Unobtrusive Rake tasks for managing and releasing Ruby Gems.
6
6
 
7
7
  authors: Postmodern
8
8
  email: postmodern.mod3@gmail.com
@@ -52,7 +52,7 @@ module Gem
52
52
  end
53
53
 
54
54
  desc "Spawns an Interactive Ruby Console"
55
- task :console => "console:#{@project.primary_gemspec_name}"
55
+ task :console => "console:#{@project.primary_gemspec}"
56
56
  end
57
57
 
58
58
  #
@@ -64,10 +64,8 @@ module Gem
64
64
  # @return [Array<String>]
65
65
  # The arguments for the console command.
66
66
  #
67
- def console(name=@project.primary_gemspec_name)
68
- unless (gemspec = @project.gemspecs[name.to_s])
69
- raise(ArgumentError,"unknown gemspec name: #{name}")
70
- end
67
+ def console(name=nil)
68
+ gemspec = @project.gemspec(name)
71
69
 
72
70
  arguments = [@command]
73
71
 
@@ -60,14 +60,6 @@ module Gem
60
60
  # @return [String]
61
61
  # The gemspec name.
62
62
  #
63
- attr_reader :primary_gemspec_name
64
-
65
- #
66
- # The primary gemspec for the project.
67
- #
68
- # @return [Gem::Specification]
69
- # The primary gemspec.
70
- #
71
63
  attr_reader :primary_gemspec
72
64
 
73
65
  #
@@ -90,6 +82,12 @@ module Gem
90
82
  }]
91
83
  end
92
84
 
85
+ @primary_gemspec = if @gemspecs.has_key?(@name)
86
+ @name
87
+ else
88
+ @gemspecs.keys.sort.first
89
+ end
90
+
93
91
  @builds = {}
94
92
 
95
93
  @gemspecs.each do |name,gemspec|
@@ -98,41 +96,28 @@ module Gem
98
96
  end
99
97
  end
100
98
 
101
- @primary_gemspec_name, @primary_gemspec = if @gemspecs.has_key?(@name)
102
- [@name, @gemspecs[@name]]
103
- else
104
- @gemspecs.first
105
- end
106
-
107
99
  @bundler = File.file?(File.join(@root,'Gemfile'))
108
100
  end
109
101
 
110
102
  #
111
- # The primary build name for the project.
112
- #
113
- # @return [String]
114
- # The primary build name.
115
- #
116
- # @api semipublic
103
+ # Retrieves a gemspec for the project.
117
104
  #
118
- def primary_build
119
- if @builds.has_key?(@name)
120
- @name
121
- else
122
- @builds.keys.first
123
- end
124
- end
125
-
126
- #
127
- # The primary gemspec for the project.
105
+ # @param [String] name (@primary_gemspec)
106
+ # The gemspec name to retrieve.
128
107
  #
129
108
  # @return [Gem::Specification]
130
- # The primary gemspec.
109
+ # The requested gemspec.
131
110
  #
132
111
  # @api semipublic
133
112
  #
134
- def primary_gemspec
135
- @gemspecs[primary_build]
113
+ def gemspec(name=nil)
114
+ name ||= @primary_gemspec
115
+
116
+ unless @gemspecs.has_key?(name)
117
+ raise(ArgumentError,"unknown gemspec: #{name}")
118
+ end
119
+
120
+ return @gemspecs[name]
136
121
  end
137
122
 
138
123
  #
@@ -30,8 +30,9 @@ module Gem
30
30
  status = self.status
31
31
 
32
32
  unless status.strip.empty?
33
+ error "Project has uncommitted changes!"
33
34
  puts status
34
- fail "Project has uncommitted changes!"
35
+ abort
35
36
  end
36
37
  end
37
38
  end
@@ -45,7 +45,7 @@ module Gem
45
45
  tag = if args.name
46
46
  args.name
47
47
  else
48
- version_tag(@project.primary_gemspec.version)
48
+ version_tag(@project.gemspec.version)
49
49
  end
50
50
 
51
51
  status "Tagging #{tag} ..."
@@ -0,0 +1,159 @@
1
+ require 'spec_helper'
2
+ require 'rubygems/tasks/project'
3
+
4
+ describe Gem::Tasks::Project do
5
+ let(:rubygems_project) do
6
+ described_class.new(PROJECT_DIRS['rubygems-project'])
7
+ end
8
+
9
+ let(:rubygems_multi_project) do
10
+ described_class.new(PROJECT_DIRS['rubygems-multi-project'])
11
+ end
12
+
13
+ let(:bundler_project) do
14
+ described_class.new(PROJECT_DIRS['bundler-project'])
15
+ end
16
+
17
+ describe "directories" do
18
+ it "should map paths to #{described_class} instances" do
19
+ directory = PROJECT_DIRS['rubygems-project']
20
+ project = described_class.directories[directory]
21
+
22
+ project.root.should == directory
23
+ end
24
+ end
25
+
26
+ describe "#name" do
27
+ subject { rubygems_project }
28
+
29
+ it "should use the name of the directory" do
30
+ subject.name.should == 'rubygems-project'
31
+ end
32
+ end
33
+
34
+ describe "#scm" do
35
+ subject { bundler_project }
36
+
37
+ it "should detect the SCM used" do
38
+ subject.scm.should == :git
39
+ end
40
+ end
41
+
42
+ describe "#gemspecs" do
43
+ context "with single-gemspec project" do
44
+ subject { rubygems_project }
45
+
46
+ it "should load the single-gemspec" do
47
+ subject.gemspecs.values.map(&:name).should == %w[rubygems-project]
48
+ end
49
+ end
50
+
51
+ context "with multi-gemspec project" do
52
+ subject { rubygems_multi_project }
53
+
54
+ it "should load all gemspecs" do
55
+ subject.gemspecs.values.map(&:name).should =~ %w[
56
+ rubygems-project
57
+ rubygems-project-lite
58
+ ]
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "#primary_gemspec" do
64
+ context "with single-gemspec project" do
65
+ subject { rubygems_project }
66
+
67
+ it "should match the directory name to the gemspec" do
68
+ subject.primary_gemspec.should == subject.name
69
+ end
70
+ end
71
+
72
+ context "with multi-gemspec project" do
73
+ subject { rubygems_multi_project }
74
+
75
+ it "should pick the first gemspec" do
76
+ subject.primary_gemspec.should == 'rubygems-project'
77
+ end
78
+ end
79
+ end
80
+
81
+ describe "#gemspec" do
82
+ context "with single-gemspec project" do
83
+ subject { rubygems_project }
84
+
85
+ it "should default the directory name to the gemspec" do
86
+ subject.gemspec.name.should == subject.name
87
+ end
88
+
89
+ it "should raise an ArgumentError for unknown gemspec names" do
90
+ lambda { subject.gemspec('foo') }.should raise_error(ArgumentError)
91
+ end
92
+ end
93
+
94
+ context "with multi-gemspec project" do
95
+ subject { rubygems_multi_project }
96
+
97
+ it "should default the first gemspec" do
98
+ subject.gemspec.name.should == 'rubygems-project'
99
+ end
100
+
101
+ it "should allow accessing alternate gemspecs" do
102
+ alternate = 'rubygems-project-lite'
103
+
104
+ subject.gemspec(alternate).name.should == alternate
105
+ end
106
+ end
107
+ end
108
+
109
+ describe "#builds" do
110
+ subject { rubygems_multi_project }
111
+
112
+ it "should group builds by gemspec name" do
113
+ subject.builds.keys.should == subject.gemspecs.keys
114
+ end
115
+
116
+ it "should map a package format to a pkg/ path" do
117
+ packages = subject.builds['rubygems-project']
118
+
119
+ packages['tar.gz'].should == 'pkg/rubygems-project-1.2.3.tar.gz'
120
+ end
121
+
122
+ context "with single-gemspec project" do
123
+ subject { rubygems_project }
124
+
125
+ it "should only have a key for the single-gemspec" do
126
+ subject.builds.keys.should == %w[rubygems-project]
127
+ end
128
+ end
129
+
130
+ context "with multi-gemspec project" do
131
+ subject { rubygems_multi_project }
132
+
133
+ it "should have keys for each gemspec" do
134
+ subject.builds.keys.should =~ %w[
135
+ rubygems-project
136
+ rubygems-project-lite
137
+ ]
138
+ end
139
+ end
140
+ end
141
+
142
+ describe "#bundler?" do
143
+ context "with Bundler" do
144
+ subject { bundler_project }
145
+
146
+ it "should detect the 'Gemfile' file" do
147
+ subject.bundler?.should be_true
148
+ end
149
+ end
150
+
151
+ context "without Bundler" do
152
+ subject { rubygems_project }
153
+
154
+ it "should be false" do
155
+ subject.bundler?.should be_false
156
+ end
157
+ end
158
+ end
159
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,13 @@
1
1
  gem 'rspec', '~> 2.4'
2
2
  require 'rspec'
3
3
 
4
+ PROJECTS_DIR = File.join('data','projects')
5
+ PROJECT_DIRS = lambda { |name| File.join(PROJECTS_DIR,name) }
6
+
7
+ unless File.directory?(PROJECTS_DIR)
8
+ abort "Please run `rake data:projects` before running the specs!"
9
+ end
10
+
4
11
  RSpec.configure do |spec|
5
12
  spec.before(:suite) do
6
13
  # clear the $RUBYCONSOLE env variable
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre2
4
+ version: 0.1.0.pre3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-21 00:00:00.000000000 Z
12
+ date: 2012-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -43,7 +43,7 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0.7'
46
- description: Simple Rake tasks for managing and releasing Ruby projects.
46
+ description: Unobtrusive Rake tasks for managing and releasing Ruby Gems.
47
47
  email: postmodern.mod3@gmail.com
48
48
  executables: []
49
49
  extensions: []
@@ -83,6 +83,7 @@ files:
83
83
  - rubygems-tasks.gemspec
84
84
  - spec/console_spec.rb
85
85
  - spec/install_spec.rb
86
+ - spec/project_spec.rb
86
87
  - spec/push_spec.rb
87
88
  - spec/rake_context.rb
88
89
  - spec/scm/push_spec.rb
@@ -112,10 +113,11 @@ rubyforge_project:
112
113
  rubygems_version: 1.8.23
113
114
  signing_key:
114
115
  specification_version: 3
115
- summary: Rake tasks for managing and releasing Ruby projects.
116
+ summary: Rake tasks for managing and releasing Ruby Gems.
116
117
  test_files:
117
118
  - spec/console_spec.rb
118
119
  - spec/install_spec.rb
120
+ - spec/project_spec.rb
119
121
  - spec/push_spec.rb
120
122
  - spec/scm/push_spec.rb
121
123
  - spec/scm/tag_spec.rb