fml 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/fml.gemspec +5 -5
  2. data/tasks/github-gem.rake +52 -58
  3. metadata +16 -8
@@ -2,8 +2,8 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "fml"
5
- s.version = "0.2.4"
6
- s.date = "2010-11-25"
5
+ s.version = "0.2.5"
6
+ s.date = "2011-04-12"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.0") if s.respond_to? :required_rubygems_version=
9
9
 
@@ -24,16 +24,16 @@ Gem::Specification.new do |s|
24
24
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
25
25
  s.add_runtime_dependency(%q<nokogiri>)
26
26
  s.add_runtime_dependency(%q<rubyzip>)
27
- s.add_runtime_dependency(%q<roxml>)
27
+ s.add_runtime_dependency(%q<roxml>, ["3.1.5"])
28
28
  else
29
29
  s.add_dependency(%q<nokogiri>)
30
30
  s.add_dependency(%q<rubyzip>)
31
- s.add_dependency(%q<roxml>)
31
+ s.add_dependency(%q<roxml>, ["3.1.5"])
32
32
  end
33
33
  else
34
34
  s.add_dependency(%q<nokogiri>)
35
35
  s.add_dependency(%q<rubyzip>)
36
- s.add_dependency(%q<roxml>)
36
+ s.add_dependency(%q<roxml>, ["3.1.5"])
37
37
  end
38
38
  end
39
39
 
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'rake/tasklib'
4
4
  require 'date'
5
- require 'git'
5
+ require 'set'
6
6
 
7
7
  module GithubGem
8
8
 
@@ -13,8 +13,8 @@ module GithubGem
13
13
 
14
14
  # Detects the main include file of this project using heuristics
15
15
  def self.detect_main_include
16
- if detect_gemspec_file =~ /^(\.*)\.gemspec$/ && File.exist?("lib/#{$1}.rb")
17
- "lib/#{$1}.rb"
16
+ if File.exist?(File.expand_path("../lib/#{File.basename(detect_gemspec_file, '.gemspec').gsub(/-/, '/')}.rb", detect_gemspec_file))
17
+ "lib/#{File.basename(detect_gemspec_file, '.gemspec').gsub(/-/, '/')}.rb"
18
18
  elsif FileList['lib/*.rb'].length == 1
19
19
  FileList['lib/*.rb'].first
20
20
  else
@@ -24,7 +24,7 @@ module GithubGem
24
24
 
25
25
  class RakeTasks
26
26
 
27
- attr_reader :gemspec, :modified_files, :git
27
+ attr_reader :gemspec, :modified_files
28
28
  attr_accessor :gemspec_file, :task_namespace, :main_include, :root_dir, :spec_pattern, :test_pattern, :remote, :remote_branch, :local_branch
29
29
 
30
30
  # Initializes the settings, yields itself for configuration
@@ -33,7 +33,7 @@ module GithubGem
33
33
  @gemspec_file = GithubGem.detect_gemspec_file
34
34
  @task_namespace = task_namespace
35
35
  @main_include = GithubGem.detect_main_include
36
- @modified_files = []
36
+ @modified_files = Set.new
37
37
  @root_dir = Dir.pwd
38
38
  @test_pattern = 'test/**/*_test.rb'
39
39
  @spec_pattern = 'spec/**/*_spec.rb'
@@ -43,13 +43,16 @@ module GithubGem
43
43
 
44
44
  yield(self) if block_given?
45
45
 
46
- @git = Git.open(@root_dir)
47
46
  load_gemspec!
48
47
  define_tasks!
49
48
  end
50
49
 
51
50
  protected
52
51
 
52
+ def git
53
+ @git ||= ENV['GIT'] || 'git'
54
+ end
55
+
53
56
  # Define Unit test tasks
54
57
  def define_test_tasks!
55
58
  require 'rake/testtask'
@@ -68,23 +71,23 @@ module GithubGem
68
71
 
69
72
  # Defines RSpec tasks
70
73
  def define_rspec_tasks!
71
- require 'spec/rake/spectask'
74
+ require 'rspec/core/rake_task'
72
75
 
73
76
  namespace(:spec) do
74
77
  desc "Verify all RSpec examples for #{gemspec.name}"
75
- Spec::Rake::SpecTask.new(:basic) do |t|
76
- t.spec_files = FileList[spec_pattern]
78
+ RSpec::Core::RakeTask.new(:basic) do |t|
79
+ t.pattern = spec_pattern
77
80
  end
78
81
 
79
82
  desc "Verify all RSpec examples for #{gemspec.name} and output specdoc"
80
- Spec::Rake::SpecTask.new(:specdoc) do |t|
81
- t.spec_files = FileList[spec_pattern]
82
- t.spec_opts << '--format' << 'specdoc' << '--color'
83
+ RSpec::Core::RakeTask.new(:specdoc) do |t|
84
+ t.pattern = spec_pattern
85
+ t.rspec_opts = ['--format', 'documentation', '--color']
83
86
  end
84
87
 
85
88
  desc "Run RCov on specs for #{gemspec.name}"
86
- Spec::Rake::SpecTask.new(:rcov) do |t|
87
- t.spec_files = FileList[spec_pattern]
89
+ RSpec::Core::RakeTask.new(:rcov) do |t|
90
+ t.pattern = spec_pattern
88
91
  t.rcov = true
89
92
  t.rcov_opts = ['--exclude', '"spec/*,gems/*"', '--rails']
90
93
  end
@@ -165,7 +168,7 @@ module GithubGem
165
168
  # in the repository and the spec/test file pattern.
166
169
  def manifest_task
167
170
  # Load all the gem's files using "git ls-files"
168
- repository_files = git.ls_files.keys
171
+ repository_files = `#{git} ls-files`.split("\n")
169
172
  test_files = Dir[test_pattern] + Dir[spec_pattern]
170
173
 
171
174
  update_gemspec(:files, repository_files)
@@ -180,7 +183,7 @@ module GithubGem
180
183
  end
181
184
 
182
185
  def newest_version
183
- git.tags.map { |tag| tag.name.split('-').last }.compact.map { |v| Gem::Version.new(v) }.max || Gem::Version.new('0.0.0')
186
+ `#{git} tag`.split("\n").map { |tag| tag.split('-').last }.compact.map { |v| Gem::Version.new(v) }.max || Gem::Version.new('0.0.0')
184
187
  end
185
188
 
186
189
  def next_version(increment = nil)
@@ -217,72 +220,58 @@ module GithubGem
217
220
 
218
221
  def check_version_task
219
222
  raise "#{ENV['VERSION']} is not a valid version number!" if ENV['VERSION'] && !Gem::Version.correct?(ENV['VERSION'])
220
- proposed_version = Gem::Version.new(ENV['VERSION'] || gemspec.version)
223
+ proposed_version = Gem::Version.new((ENV['VERSION'] || gemspec.version).dup)
221
224
  raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version >= proposed_version
222
225
  end
223
226
 
224
227
  # Checks whether the current branch is not diverged from the remote branch
225
228
  def check_not_diverged_task
226
- raise "The current branch is diverged from the remote branch!" if git.log.between('HEAD', git.remote(remote).branch(remote_branch).gcommit).any?
229
+ raise "The current branch is diverged from the remote branch!" if `#{git} rev-list HEAD..#{remote}/#{remote_branch}`.split("\n").any?
227
230
  end
228
231
 
229
232
  # Checks whether the repository status ic clean
230
233
  def check_clean_status_task
231
- raise "The current working copy contains modifications" if git.status.changed.any?
234
+ raise "The current working copy contains modifications" if `#{git} ls-files -m`.split("\n").any?
232
235
  end
233
236
 
234
237
  # Checks whether the current branch is correct
235
238
  def check_current_branch_task
236
- raise "Currently not on #{local_branch} branch!" unless git.branch.name == local_branch.to_s
239
+ raise "Currently not on #{local_branch} branch!" unless `#{git} branch`.split("\n").detect { |b| /^\* / =~ b } == "* #{local_branch}"
237
240
  end
238
241
 
239
242
  # Fetches the latest updates from Github
240
243
  def fetch_origin_task
241
- git.fetch('origin')
244
+ sh git, 'fetch', remote
242
245
  end
243
246
 
244
247
  # Commits every file that has been changed by the release task.
245
248
  def commit_modified_files_task
246
- if modified_files.any?
247
- modified_files.each { |file| git.add(file) }
248
- git.commit("Released #{gemspec.name} gem version #{gemspec.version}")
249
+ really_modified = `#{git} ls-files -m #{modified_files.entries.join(' ')}`.split("\n")
250
+ if really_modified.any?
251
+ really_modified.each { |file| sh git, 'add', file }
252
+ sh git, 'commit', '-m', "Released #{gemspec.name} gem version #{gemspec.version}."
249
253
  end
250
254
  end
251
255
 
252
256
  # Adds a tag for the released version
253
257
  def tag_version_task
254
- git.add_tag("#{gemspec.name}-#{gemspec.version}")
258
+ sh git, 'tag', '-a', "#{gemspec.name}-#{gemspec.version}", '-m', "Released #{gemspec.name} gem version #{gemspec.version}."
255
259
  end
256
260
 
257
261
  # Pushes the changes and tag to github
258
262
  def github_release_task
259
- git.push(remote, remote_branch, true)
263
+ sh git, 'push', '--tags', remote, remote_branch
260
264
  end
261
265
 
262
- # # Checks whether Rubyforge is configured properly
263
- # def check_rubyforge_task
264
- # # Login no longer necessary when using rubyforge 2.0.0 gem
265
- # # raise "Could not login on rubyforge!" unless `rubyforge login 2>&1`.strip.empty?
266
- # output = `rubyforge names`.split("\n")
267
- # raise "Rubyforge group not found!" unless output.any? { |line| %r[^groups\s*\:.*\b#{Regexp.quote(gemspec.rubyforge_project)}\b.*] =~ line }
268
- # raise "Rubyforge package not found!" unless output.any? { |line| %r[^packages\s*\:.*\b#{Regexp.quote(gemspec.name)}\b.*] =~ line }
269
- # end
270
-
271
- # # Task to release the .gem file toRubyforge.
272
- # def rubyforge_release_task
273
- # sh 'rubyforge', 'add_release', gemspec.rubyforge_project, gemspec.name, gemspec.version.to_s, "pkg/#{gemspec.name}-#{gemspec.version}.gem"
274
- # end
275
-
276
266
  def gemcutter_release_task
277
- sh "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
267
+ sh "gem", 'push', "pkg/#{gemspec.name}-#{gemspec.version}.gem"
278
268
  end
279
269
 
280
270
  # Gem release task.
281
271
  # All work is done by the task's dependencies, so just display a release completed message.
282
272
  def release_task
283
273
  puts
284
- puts '------------------------------------------------------------'
285
- puts "Released #{gemspec.name} version #{gemspec.version}"
274
+ puts "Release successful."
286
275
  end
287
276
 
288
277
  private
@@ -342,30 +331,35 @@ module GithubGem
342
331
 
343
332
  # Reload the gemspec so the changes are incorporated
344
333
  load_gemspec!
334
+
335
+ # Also mark the Gemfile.lock file as changed because of the new version.
336
+ modified_files << 'Gemfile.lock' if File.exist?(File.join(root_dir, 'Gemfile.lock'))
345
337
  end
346
338
  end
347
339
 
348
340
  # Updates the tasks file using the latest file found on Github
349
341
  def update_tasks_task
350
- require 'net/http'
351
-
352
- server = 'github.com'
353
- path = '/wvanbergen/github-gem/raw/master/tasks/github-gem.rake'
342
+ require 'net/https'
343
+ require 'uri'
344
+
345
+ uri = URI.parse('https://github.com/wvanbergen/github-gem/raw/master/tasks/github-gem.rake')
346
+ http = Net::HTTP.new(uri.host, uri.port)
347
+ http.use_ssl = true
348
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
349
+ response = http.request(Net::HTTP::Get.new(uri.path))
354
350
 
355
- Net::HTTP.start(server) do |http|
356
- response = http.get(path)
351
+ if Net::HTTPSuccess === response
357
352
  open(__FILE__, "w") { |file| file.write(response.body) }
358
- end
359
-
360
- relative_file = File.expand_path(__FILE__).sub(%r[^#{git.dir.path}/], '')
361
- if git.status[relative_file] && git.status[relative_file].type == 'M'
362
- git.add(relative_file)
363
- git.commit("Updated to latest gem release management tasks.")
364
- puts "Updated to latest version of gem release management tasks."
353
+ relative_file = File.expand_path(__FILE__).sub(%r[^#{@root_dir}/], '')
354
+ if `#{git} ls-files -m #{relative_file}`.split("\n").any?
355
+ sh git, 'add', relative_file
356
+ sh git, 'commit', '-m', "Updated to latest gem release management tasks."
357
+ else
358
+ puts "Release managament tasks already are at the latest version."
359
+ end
365
360
  else
366
- puts "Release managament tasks already are at the latest version."
361
+ raise "Download failed with HTTP status #{response.code}!"
367
362
  end
368
363
  end
369
-
370
364
  end
371
365
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fml
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 29
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 4
9
- version: 0.2.4
9
+ - 5
10
+ version: 0.2.5
10
11
  platform: ruby
11
12
  authors:
12
13
  - Dusan Maliarik
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-11-25 00:00:00 +01:00
18
+ date: 2011-04-12 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 3
28
30
  segments:
29
31
  - 0
30
32
  version: "0"
@@ -38,6 +40,7 @@ dependencies:
38
40
  requirements:
39
41
  - - ">="
40
42
  - !ruby/object:Gem::Version
43
+ hash: 3
41
44
  segments:
42
45
  - 0
43
46
  version: "0"
@@ -49,11 +52,14 @@ dependencies:
49
52
  requirement: &id003 !ruby/object:Gem::Requirement
50
53
  none: false
51
54
  requirements:
52
- - - ">="
55
+ - - "="
53
56
  - !ruby/object:Gem::Version
57
+ hash: 9
54
58
  segments:
55
- - 0
56
- version: "0"
59
+ - 3
60
+ - 1
61
+ - 5
62
+ version: 3.1.5
57
63
  type: :runtime
58
64
  version_requirements: *id003
59
65
  description: Floor plan document toolkit
@@ -119,6 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
125
  requirements:
120
126
  - - ">="
121
127
  - !ruby/object:Gem::Version
128
+ hash: 3
122
129
  segments:
123
130
  - 0
124
131
  version: "0"
@@ -127,6 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
134
  requirements:
128
135
  - - ">="
129
136
  - !ruby/object:Gem::Version
137
+ hash: 27
130
138
  segments:
131
139
  - 1
132
140
  - 3
@@ -135,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
143
  requirements: []
136
144
 
137
145
  rubyforge_project:
138
- rubygems_version: 1.3.7
146
+ rubygems_version: 1.6.2
139
147
  signing_key:
140
148
  specification_version: 2
141
149
  summary: Floorplanner.com FML document toolkit