scaffoldhub 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scaffoldhub (0.1.1)
4
+ scaffoldhub (0.1.2)
5
5
  rails
6
6
 
7
7
  GEM
@@ -16,14 +16,16 @@ module ActiveRecord
16
16
  class_option :parent, :type => :string, :desc => "The parent class for the generated model"
17
17
 
18
18
  def create_model_file
19
- model_template = find_template_file(:model)
20
- template model_template.src, File.join('app/models', class_path, "#{file_name}.rb") if model_template
19
+ find_template_file(:model) do |model_template|
20
+ template model_template.src, File.join('app/models', class_path, "#{file_name}.rb")
21
+ end
21
22
  end
22
23
 
23
24
  def create_migration_file
24
25
  return unless options[:migration] && options[:parent].nil?
25
- migration_template = find_template_file(:migration)
26
- migration_template migration_template.src, "db/migrate/create_#{table_name}.rb" if migration_template
26
+ find_template_file(:migration) do |migration_template|
27
+ migration_template migration_template.src, "db/migrate/create_#{table_name}.rb"
28
+ end
27
29
  end
28
30
 
29
31
  end
@@ -18,8 +18,9 @@ module ScaffoldController
18
18
  class_option :local, :default => false, :banner => "LOCAL SCAFFOLD", :type => :boolean, :desc => "Use a local scaffold, not scaffoldhub.org"
19
19
 
20
20
  def create_controller_files
21
- controller_template_file = find_template_file(:controller)
22
- template controller_template_file.src, File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb") if controller_template_file
21
+ find_template_file(:controller) do |controller_template_file|
22
+ template controller_template_file.src, File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
23
+ end
23
24
  end
24
25
  end
25
26
  end
@@ -6,6 +6,6 @@ require 'scaffoldhub/helper'
6
6
  require 'scaffoldhub/runner'
7
7
 
8
8
  module Scaffoldhub
9
- VERSION = '0.1.1'
9
+ VERSION = '0.1.2'
10
10
  SCAFFOLD_HUB_SERVER = 'www.scaffoldhub.org'
11
11
  end
@@ -18,6 +18,7 @@ module Scaffoldhub
18
18
  begin
19
19
  scaffold_spec.select_files(type).each do |template_file|
20
20
  yield template_file.download!
21
+ template_file.close
21
22
  end
22
23
  rescue Errno::ENOENT => e
23
24
  say_status :error, e.message, :red
@@ -34,7 +35,10 @@ module Scaffoldhub
34
35
  def find_template_file(type)
35
36
  begin
36
37
  template_file = scaffold_spec.find_file(type)
37
- template_file.download! unless template_file.nil?
38
+ if template_file
39
+ yield template_file.download!
40
+ template_file.close
41
+ end
38
42
  rescue Errno::ENOENT => e
39
43
  say_status :error, e.message, :red
40
44
  raise e
@@ -14,10 +14,14 @@ module Scaffoldhub
14
14
  if @local
15
15
  File.join(@base_url, @src)
16
16
  else
17
- @local_path
17
+ @temp_file.path
18
18
  end
19
19
  end
20
20
 
21
+ def close
22
+ @temp_file.close if @temp_file
23
+ end
24
+
21
25
  def dest
22
26
  if @rename
23
27
  File.join(@dest, @rename)
@@ -30,8 +34,8 @@ module Scaffoldhub
30
34
  if @local
31
35
  raise Errno::ENOENT.new(src) unless File.exists?(src)
32
36
  else
33
- @local_path = Tempfile.new(File.basename(@src)).path
34
- open(@local_path, "wb") do |file|
37
+ @temp_file = Tempfile.new(File.basename(@src))
38
+ File.open(@temp_file.path, "wb") do |file|
35
39
  file.write(remote_file_contents!)
36
40
  end
37
41
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scaffoldhub
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pat Shaughnessy
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-09 00:00:00 -04:00
18
+ date: 2011-06-11 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency