scaffoldhub 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,8 +1,2 @@
1
1
  source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in code_buddy.gemspec
4
2
  gemspec
5
-
6
- #group :test, :cucumber do
7
- #gem 'rails'
8
- #end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scaffoldhub (0.0.3)
4
+ scaffoldhub (0.0.6)
5
5
  rails
6
6
 
7
7
  GEM
@@ -40,7 +40,7 @@ GEM
40
40
  erubis (2.6.6)
41
41
  abstract (>= 1.0.0)
42
42
  i18n (0.5.0)
43
- mail (2.2.15)
43
+ mail (2.2.19)
44
44
  activesupport (>= 2.3.6)
45
45
  i18n (>= 0.4.0)
46
46
  mime-types (~> 1.16)
@@ -78,7 +78,7 @@ GEM
78
78
  thor (0.14.6)
79
79
  treetop (1.4.9)
80
80
  polyglot (>= 0.3.1)
81
- tzinfo (0.3.25)
81
+ tzinfo (0.3.26)
82
82
 
83
83
  PLATFORMS
84
84
  ruby
data/bin/scaffoldhub ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'thor'
5
+ require 'scaffoldhub'
6
+
7
+ Scaffoldhub::Runner.start
@@ -16,13 +16,13 @@ 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('active_record', 'templates/model.rb')
19
+ model_template = find_template_file(:model)
20
20
  template model_template.src, File.join('app/models', class_path, "#{file_name}.rb") if model_template
21
21
  end
22
22
 
23
23
  def create_migration_file
24
24
  return unless options[:migration] && options[:parent].nil?
25
- migration_template = find_template_file('active_record', 'templates/migration.rb')
25
+ migration_template = find_template_file(:migration)
26
26
  migration_template migration_template.src, "db/migrate/create_#{table_name}.rb" if migration_template
27
27
  end
28
28
 
@@ -9,7 +9,7 @@ module Erb
9
9
  class_option :local, :default => false, :banner => "LOCAL SCAFFOLD", :type => :boolean, :desc => "Use a local scaffold, not scaffoldhub.org"
10
10
 
11
11
  def copy_view_files
12
- each_template_file(:erb) do |erb_template_file|
12
+ each_template_file(:view) do |erb_template_file|
13
13
  if is_layout_erb?(erb_template_file)
14
14
  copy_layout_file(erb_template_file)
15
15
  else
@@ -0,0 +1,37 @@
1
+ require 'rails/generators/erb/scaffold/scaffold_generator'
2
+ require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
3
+ require 'rails/generators/active_record/model/model_generator'
4
+
5
+ class NewScaffoldhubGenerator < Rails::Generators::NamedBase
6
+
7
+ def self.source_root
8
+ File.expand_path('../templates', __FILE__)
9
+ end
10
+
11
+ def copy_scaffold_spec
12
+ template 'scaffold_spec.rb.erb', "#{singular_name}_scaffold/scaffold_spec.rb"
13
+ end
14
+
15
+ def copy_scaffold_screenshot
16
+ copy_file 'screenshot.png', "#{singular_name}_scaffold/#{singular_name}_screenshot.png"
17
+ end
18
+
19
+ def copy_rails_erb_templates
20
+ %w[ _form.html.erb edit.html.erb index.html.erb new.html.erb show.html.erb ].each do |file_name|
21
+ copy_file File.join(Erb::Generators::ScaffoldGenerator.default_source_root, file_name),
22
+ "#{singular_name}_scaffold/templates/#{file_name}"
23
+ end
24
+ end
25
+
26
+ def copy_rails_model_template
27
+ copy_file File.join(ActiveRecord::Generators::ModelGenerator.default_source_root, 'model.rb'),
28
+ "#{singular_name}_scaffold/templates/model.rb"
29
+ copy_file File.join(ActiveRecord::Generators::ModelGenerator.default_source_root, 'migration.rb'),
30
+ "#{singular_name}_scaffold/templates/migration.rb"
31
+ end
32
+
33
+ def copy_rails_controller_template
34
+ copy_file File.join(Rails::Generators::ScaffoldControllerGenerator.default_source_root, 'controller.rb'),
35
+ "#{singular_name}_scaffold/templates/controller.rb"
36
+ end
37
+ end
@@ -0,0 +1,49 @@
1
+ Scaffoldhub::Specification.new do
2
+
3
+ # Github URL where you will post your scaffold - the speciied folder must contain this file
4
+ base_url 'https://github.com/your_name/your_repo'
5
+
6
+ # The name of your new scaffold: should be a single word
7
+ name '<%= singular_name %>'
8
+
9
+ # Metadata about this scaffold - this info is only used for display on scaffoldhub.org:
10
+ metadata do
11
+
12
+ # A short paragraph describing what this scaffold does
13
+ description 'The <%= singular_name %> scaffold.'
14
+
15
+ # 4x3 aspect ratio screen shot
16
+ screenshot 'screenshot.png'
17
+
18
+ # Tag(s) to help scaffoldhub.org users find your scaffold
19
+ tag 'jquery'
20
+ tag 'autocomplete'
21
+ end
22
+
23
+ # Optionally specify an example of a scaffold parameter
24
+ parameter_example 'FIELD_NAME'
25
+
26
+ # Optionally post a link to an article you write explaining how the scaffold works.
27
+ blog_post 'http://patshaughnessy.net/2011/3/13/view-mapper-for-rails-3-scaffoldhub'
28
+
29
+ # Define a model template - this ERB file will be used to generate a new
30
+ # model class with this path & filename: app/models/NAME.rb
31
+ model 'templates/model.rb'
32
+
33
+ # Define an ActiveRecord migration template - this ERB file will be used to generate a new
34
+ # migration class with this path & filename: db/migrate/TIMESTAMP_create_PLURAL_NAME.rb
35
+ migration 'templates/migration.rb'
36
+
37
+ # Define a controller template - this ERB file will be used to generate a new
38
+ # controller class with this path & filename: app/controllers/PLURAL_NAME.rb
39
+ controller 'templates/controller.rb'
40
+
41
+ # You can use "with_options" to specify the same source folder for a series of templates:
42
+ with_options :src => 'templates' do
43
+ view '_form.html.erb'
44
+ view 'new.html.erb'
45
+ view 'edit.html.erb'
46
+ view 'index.html.erb'
47
+ view 'show.html.erb'
48
+ end
49
+ end
@@ -12,9 +12,8 @@ module ScaffoldController
12
12
  class_option :local, :default => false, :banner => "LOCAL SCAFFOLD", :type => :boolean, :desc => "Use a local scaffold, not scaffoldhub.org"
13
13
 
14
14
  def create_controller_files
15
- each_template_file(:controller) do |controller_template_file|
16
- template controller_template_file.src, File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
17
- end
15
+ controller_template_file = find_template_file(:controller)
16
+ template controller_template_file.src, File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb") if controller_template_file
18
17
  end
19
18
  end
20
19
  end
@@ -14,8 +14,11 @@ class ScaffoldhubGenerator < Rails::Generators::ScaffoldGenerator
14
14
  class_option :local, :default => false, :banner => "LOCAL SCAFFOLD", :type => :boolean, :desc => "Use a local scaffold, not scaffoldhub.org"
15
15
 
16
16
  def download_and_copy_other_files
17
- each_template_file(:other) do |other_template_file|
18
- template other_template_file.src, other_template_file.dest
17
+ each_template_file(:template) do |template_file|
18
+ template template_file.src, template_file.dest
19
+ end
20
+ each_template_file(:file) do |template_file|
21
+ copy_file template_file.src, template_file.dest
19
22
  end
20
23
  end
21
24
  end
data/lib/scaffoldhub.rb CHANGED
@@ -3,7 +3,9 @@ require 'scaffoldhub/specification'
3
3
  require 'scaffoldhub/scaffold_spec'
4
4
  require 'scaffoldhub/template_file'
5
5
  require 'scaffoldhub/helper'
6
+ require 'scaffoldhub/runner'
6
7
 
7
8
  module Scaffoldhub
8
- VERSION = '0.0.4'
9
+ VERSION = '0.0.6'
10
+ SCAFFOLD_HUB_SERVER = 'scaffoldhub.org'
9
11
  end
@@ -25,9 +25,9 @@ module Scaffoldhub
25
25
  end
26
26
  end
27
27
 
28
- def find_template_file(type, name)
28
+ def find_template_file(type)
29
29
  begin
30
- template_file = scaffold_spec.find_file(type, name)
30
+ template_file = scaffold_spec.find_file(type)
31
31
  template_file.download! unless template_file.nil?
32
32
  rescue Errno::ENOENT => e
33
33
  say_status :error, e.message, :red
@@ -10,33 +10,19 @@ module Scaffoldhub
10
10
 
11
11
  class RemoteFile
12
12
 
13
- def initialize(status_proc)
13
+ attr_accessor :url
14
+
15
+ def initialize(url = nil, status_proc = nil)
14
16
  @status_proc = status_proc
17
+ @url = url
15
18
  end
16
19
 
17
- def remote_file_contents!
18
- begin
19
- uri = URI.parse(url)
20
- @status_proc.call(url)
21
- if uri.port == 443
22
- https = Net::HTTP.new(uri.host, uri.port)
23
- https.use_ssl = true
24
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
25
- https.start do |https|
26
- response_body(https.get(uri.path))
27
- end
28
- else
29
- Net::HTTP.start(uri.host, uri.port) do |http|
30
- response_body(http.get(uri.path))
31
- end
32
- end
33
- rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Errno::ECONNREFUSED,
34
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
35
- raise NetworkErrorException.new(url)
36
- end
20
+ def exists?
21
+ http_request.code.to_i == 200
37
22
  end
38
23
 
39
- def response_body(resp)
24
+ def remote_file_contents!
25
+ resp = http_request
40
26
  if resp.code.to_i == 200
41
27
  resp.body
42
28
  elsif resp.code.to_i == 404
@@ -46,5 +32,23 @@ module Scaffoldhub
46
32
  end
47
33
  end
48
34
 
35
+ def http_request
36
+ begin
37
+ @status_proc.call(url) if @status_proc
38
+ uri = URI.parse(url)
39
+ http = Net::HTTP.new(uri.host, uri.port)
40
+ if uri.port == 443
41
+ http.use_ssl = true
42
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
43
+ end
44
+ http.start do |http|
45
+ http.get(uri.path)
46
+ end
47
+ rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Errno::ECONNREFUSED,
48
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
49
+ raise NetworkErrorException.new(url)
50
+ end
51
+ end
52
+
49
53
  end
50
54
  end
@@ -0,0 +1,90 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'yaml'
4
+ require 'thor'
5
+
6
+ module Scaffoldhub
7
+ class Runner < Thor
8
+ desc "push /path/to/scaffold_spec.rb", "Compile specified scaffold spec and push it to scaffoldhub.org"
9
+ def push(scaffold_spec)
10
+ if load_spec(scaffold_spec)
11
+ if Specification.valid?
12
+ post_spec(scaffold_spec)
13
+ else
14
+ say "Unable to post your new scaffold. Please resolve these errors:"
15
+ Specification.errors.each { |error| say error }
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def load_spec(scaffold_spec)
23
+ begin
24
+ require scaffold_spec
25
+ true
26
+ rescue Exception => e
27
+ say "There was an error parsing your scaffold spec file."
28
+ say e.message
29
+ say e.backtrace[0]
30
+ false
31
+ end
32
+ end
33
+
34
+ def post_spec(scaffold_spec)
35
+
36
+ begin
37
+ config = load_config
38
+ username = config[:username]
39
+ password = config[:password]
40
+ rescue
41
+ say "Please enter your scaffoldhub.org credentials..."
42
+ username = ask "Username: "
43
+ password = ask "Password: "
44
+ end
45
+
46
+ url = URI.parse("http://#{SCAFFOLD_HUB_SERVER}/admin/scaffolds")
47
+ req = Net::HTTP::Post.new(url.path)
48
+ req.basic_auth username, password
49
+ req.set_form_data({'scaffold' => Specification.to_yaml, 'spec_file_name' => File.basename(scaffold_spec) }, ';')
50
+ response = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
51
+ say response.body
52
+ save_config(username, password) unless response.body == 'Invalid username or password.'
53
+ end
54
+
55
+ def config_file
56
+ File.join(find_home, '.scaffoldhub')
57
+ end
58
+
59
+ def load_config
60
+ YAML::load(File.read(config_file))
61
+ end
62
+
63
+ def save_config(username, password)
64
+ File.open(config_file, 'w') {|f| f.write({ :username => username, :password => password }.to_yaml) }
65
+ end
66
+
67
+ # Ripped from rubygems
68
+ def find_home
69
+ unless RUBY_VERSION > '1.9' then
70
+ ['HOME', 'USERPROFILE'].each do |homekey|
71
+ return File.expand_path(ENV[homekey]) if ENV[homekey]
72
+ end
73
+
74
+ if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
75
+ return File.expand_path("#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}")
76
+ end
77
+ end
78
+
79
+ File.expand_path "~"
80
+ rescue
81
+ if File::ALT_SEPARATOR then
82
+ drive = ENV['HOMEDRIVE'] || ENV['SystemDrive']
83
+ File.join(drive.to_s, '/')
84
+ else
85
+ "/"
86
+ end
87
+ end
88
+
89
+ end
90
+ end
@@ -1,13 +1,11 @@
1
1
  module Scaffoldhub
2
2
  class ScaffoldSpec < RemoteFile
3
3
 
4
- SCAFFOLD_HUB_SERVER = 'scaffoldhub.org'
5
-
6
- def initialize(url, local, status_proc)
7
- @scaffold = url
4
+ def initialize(scaffold, local, status_proc)
5
+ @scaffold = scaffold
8
6
  @local = local
9
7
  @status_proc = status_proc
10
- super(@status_proc)
8
+ super(url, @status_proc)
11
9
  end
12
10
 
13
11
  def download_and_parse!
@@ -19,23 +17,23 @@ module Scaffoldhub
19
17
  end
20
18
 
21
19
  def select_files(type)
22
- template_file_specs.select { |file_spec| file_spec[:type] == type.to_s }.collect do |file_spec|
20
+ template_file_specs.select { |file_spec| file_spec[:type].to_sym == type }.collect do |file_spec|
23
21
  TemplateFile.new file_spec[:src], file_spec[:dest], @local, base_url, @status_proc
24
22
  end
25
23
  end
26
24
 
27
- def find_file(type, name)
28
- file_spec = template_file_specs.detect { |file_spec| file_spec[:src] == name && file_spec[:type] == type.to_s }
25
+ def find_file(type)
26
+ file_spec = template_file_specs.detect { |file_spec| file_spec[:type].to_sym == type }
29
27
  unless file_spec.nil?
30
28
  TemplateFile.new file_spec[:src], file_spec[:dest], @local, base_url, @status_proc
31
29
  end
32
30
  end
33
31
 
34
32
  def parse_local
35
- if File.exists?(url)
36
- require url
33
+ if File.exists?(@scaffold)
34
+ eval(File.read(@scaffold))
37
35
  else
38
- raise Errno::ENOENT.new(url)
36
+ raise Errno::ENOENT.new(@scaffold)
39
37
  end
40
38
  end
41
39
 
@@ -67,5 +65,16 @@ module Scaffoldhub
67
65
  end
68
66
  end
69
67
 
68
+ def blog_post
69
+ if @local
70
+ Specification.blog_post
71
+ else
72
+ @spec[:blog_post]
73
+ end
74
+ end
75
+
76
+ def to_yaml
77
+ Specification.to_yaml if @local
78
+ end
70
79
  end
71
80
  end
@@ -1,48 +1,174 @@
1
1
  require 'yaml'
2
2
 
3
+ def mattr_accessor(*syms)
4
+ syms.each do |sym|
5
+ class_eval(<<-EOS, __FILE__, __LINE__)
6
+ @@#{sym} = nil
7
+
8
+ def self.#{sym}
9
+ @@#{sym}
10
+ end
11
+
12
+ def self.#{sym}=(obj)
13
+ @@#{sym} = obj
14
+ end
15
+ EOS
16
+ end
17
+ end
18
+
19
+ def define_dsl_attributes(*syms)
20
+ syms.each do |sym|
21
+ class_eval(<<-EOS, __FILE__, __LINE__)
22
+ def #{sym}(val)
23
+ self.class.#{sym} = val
24
+ end
25
+ EOS
26
+ end
27
+ end
28
+
29
+ def define_dsl_file_keyword(*syms)
30
+ syms.each do |sym|
31
+ class_eval(<<-EOS, __FILE__, __LINE__)
32
+ def #{sym}(src, options = {})
33
+ file(src, options, :#{sym})
34
+ end
35
+ EOS
36
+ end
37
+ end
38
+
3
39
  module Scaffoldhub
4
40
  class Specification
5
41
 
42
+ mattr_accessor :name, :description, :base_url, :blog_post, :screenshot, :parameter_example
43
+ define_dsl_attributes :name, :description, :base_url, :blog_post, :screenshot, :parameter_example
44
+
45
+ mattr_accessor :files, :errors, :tags
6
46
  @@files = []
7
- @@base_url = nil
47
+ @@errors = []
48
+ @@tags = []
49
+
50
+ define_dsl_file_keyword :model, :migration, :controller, :view, :layout
8
51
 
9
52
  class << self
10
- def files
11
- @@files
53
+
54
+ def add_file(src, dest, type)
55
+ @@files << { :type => type, :src => src, :dest => dest }
12
56
  end
13
57
 
14
- def files=(files)
15
- @@files = files
58
+ def add_tag(keyword)
59
+ @@tags << keyword
16
60
  end
17
61
 
18
- def add_file(type, src, dest)
19
- @@files << { :type => type, :src => src, :dest => dest }
62
+ def to_yaml
63
+ {
64
+ :name => name,
65
+ :description => description,
66
+ :base_url => adjusted_base_url,
67
+ :blog_post => blog_post,
68
+ :files => files,
69
+ :screenshot => screenshot,
70
+ :tags => tags,
71
+ :parameter_example => parameter_example
72
+ }.to_yaml
20
73
  end
21
74
 
22
- def base_url
23
- @@base_url
75
+ def adjusted_base_url
76
+ if base_url =~ /github.com\/(\w+\/\w+)\/(tree|blob)\/(.*)$/
77
+ "https://github.com/#{$1}/raw/#{$3}"
78
+ elsif base_url =~ /github.com\/(\w+\/\w+)\/?$/
79
+ "https://github.com/#{$1}/raw/master"
80
+ else
81
+ base_url
82
+ end
24
83
  end
25
84
 
26
- def base_url=(url)
27
- @@base_url = url
85
+ def valid?
86
+ has_name? && has_description? && has_base_url? && has_screenshot? && all_template_files_exist?
28
87
  end
29
88
 
30
- def to_yaml
31
- { :base_url => base_url, :files => files }.to_yaml
89
+ def has_name?
90
+ has_string_value?(:name)
91
+ end
92
+
93
+ def has_description?
94
+ has_string_value?(:description)
95
+ end
96
+
97
+ def has_base_url?
98
+ has_string_value?(:base_url)
99
+ end
100
+
101
+ def has_string_value?(value)
102
+ val = send(value)
103
+ valid = (val && val != '')
104
+ errors.push("Error: missing scaffold #{value}.") unless valid
105
+ valid
106
+ end
107
+
108
+ def has_screenshot?
109
+ has_string_value?(:screenshot) && remote_file_exists?(File.join(adjusted_base_url, screenshot))
110
+ end
111
+
112
+ def all_template_files_exist?
113
+ files.all? { |file| remote_file_exists?(File.join(adjusted_base_url, file[:src])) }
114
+ end
115
+
116
+ def remote_file_exists?(url)
117
+ valid = RemoteFile.new(url).exists?
118
+ errors.push("Error: unable to access remote URL #{url}") unless valid
119
+ valid
32
120
  end
33
121
  end
34
122
 
35
- def initialize
36
- yield self
123
+ def initialize(&block)
124
+ @context_stack = []
125
+ @context_options = {}
126
+ instance_eval(&block) if block_given?
37
127
  end
38
128
 
39
- def method_missing(name, *args, &blk)
40
- if name.to_s =~ /(.*)_file/ && args[0].is_a?(Hash)
41
- self.class.add_file($1, args[0][:src], args[0][:dest])
42
- elsif name == :base_url
43
- self.class.base_url = args[0]
129
+ def with_options(options, &block)
130
+ @context_stack.push(@context_options)
131
+ @context_options = options_relative_to_parent(@context_options, options)
132
+ yield if block_given?
133
+ @context_options = @context_stack.pop
134
+ end
135
+
136
+ def metadata
137
+ yield if block_given?
138
+ end
139
+
140
+ def file(src, options = {}, type = :file)
141
+ self.class.add_file(
142
+ join_with_parent(@context_options[:src], src),
143
+ join_with_parent(@context_options[:dest], options[:dest]),
144
+ type
145
+ )
146
+ end
147
+
148
+ def template(src, options = {})
149
+ raise ':dest option is required for templates' unless options[:dest]
150
+ file(src, options, :template)
151
+ end
152
+
153
+ def tag(keyword)
154
+ self.class.add_tag(keyword)
155
+ end
156
+
157
+ protected
158
+
159
+ def join_with_parent(parent_value, new_value)
160
+ if parent_value && new_value
161
+ File.join(parent_value, new_value)
162
+ else
163
+ parent_value || new_value
44
164
  end
45
165
  end
46
166
 
167
+ def options_relative_to_parent(parent_options, options)
168
+ {
169
+ :src => join_with_parent(parent_options[:src], options[:src]),
170
+ :dest => join_with_parent(parent_options[:dest], options[:dest])
171
+ }
172
+ end
47
173
  end
48
174
  end
@@ -6,7 +6,7 @@ module Scaffoldhub
6
6
  @dest = dest || ''
7
7
  @local = local
8
8
  @base_url = base_url
9
- super(status_proc)
9
+ super(url, status_proc)
10
10
  end
11
11
 
12
12
  def src
@@ -0,0 +1 @@
1
+ TEMPLATE
@@ -0,0 +1,85 @@
1
+ Scaffoldhub::Specification.new do
2
+
3
+ # Github URL where you will post your scaffold - the speciied folder must contain this file
4
+ base_url 'https://github.com/your_name/your_repo'
5
+
6
+ # The name of your new scaffold: should be a single word
7
+ name 'test_scaffold'
8
+
9
+ # Metadata about this scaffold - this info is only used for display on scaffoldhub.org:
10
+ metadata do
11
+
12
+ # A short paragraph describing what this scaffold does
13
+ description 'The test_scaffold scaffold.'
14
+
15
+ # 4x3 aspect ratio screen shot
16
+ screenshot 'screenshot.png'
17
+
18
+ # Tag(s) to help scaffoldhub.org users find your scaffold
19
+ tag 'jquery'
20
+ tag 'autocomplete'
21
+ end
22
+
23
+ # Optionally specify an example of a scaffold parameter
24
+ parameter_example 'FIELD_NAME'
25
+
26
+ # Optionally post a link to an article you write explaining how the scaffold works.
27
+ blog_post 'http://patshaughnessy.net/2011/3/13/view-mapper-for-rails-3-scaffoldhub'
28
+
29
+ # Define a model template - this ERB file will be used to generate a new
30
+ # model class with this path & filename: app/models/NAME.rb
31
+ model 'templates/model.rb'
32
+
33
+ # Define a controller template - this ERB file will be used to generate a new
34
+ # controller class with this path & filename: app/controllers/PLURAL_NAME.rb
35
+ controller 'templates/controller.rb'
36
+
37
+ # Define a view template - this ERB file will be used to generate a new
38
+ # view file with this path & filename: app/views/PLURAL_NAME/view_file_name.rb
39
+ view 'templates/_form.html.erb'
40
+
41
+ # Define a view layout template - this ERB file will be used to generate a new
42
+ # view layout file with this path & filename: app/views/layouts/PLURAL_NAME.rb
43
+ layout 'templates/layout.erb'
44
+
45
+ # You can use "with_options" to specify the same source folder for a series of templates:
46
+ with_options :src => 'templates' do
47
+ view 'new.html.erb'
48
+ view 'edit.html.erb'
49
+ view 'index.html.erb'
50
+ view 'show.html.erb'
51
+ end
52
+
53
+ # Specify some other code file that should be generated from an ERB template; use
54
+ # the :dest option is required to indicate where the generated file should go
55
+ template 'templates/other_code_file.erb', :dest => 'lib/other_code_file.rb'
56
+
57
+ # Specify some other file that should be simply copied into the target app somwhere
58
+ # the :dest option is required to indicate where the generated file should go
59
+ file 'templates/jquery/jquery-1.4.4.min.js', :dest => 'public/javascripts'
60
+
61
+ # You can use with_options recursively - both the :src and :dest options values
62
+ # will be constructed relative to the parent with_option values.
63
+ with_options :src => 'templates/jquery', :dest => 'public/javascripts' do
64
+ file 'jquery-ui-1.8.10.custom.min.js'
65
+ with_options :src => 'ui-lightness', :dest => 'ui-lightness' do
66
+ file 'jquery-ui-1.8.10.custom.css'
67
+ with_options :src => 'images', :dest => 'images' do
68
+ file 'ui-bg_diagonals-thick_18_b81900_40x40.png'
69
+ file 'ui-bg_diagonals-thick_20_666666_40x40.png'
70
+ file 'ui-bg_flat_10_000000_40x100.png'
71
+ file 'ui-bg_glass_100_f6f6f6_1x400.png'
72
+ file 'ui-bg_glass_100_fdf5ce_1x400.png'
73
+ file 'ui-bg_glass_65_ffffff_1x400.png'
74
+ file 'ui-bg_gloss-wave_35_f6a828_500x100.png'
75
+ file 'ui-bg_highlight-soft_100_eeeeee_1x100.png'
76
+ file 'ui-bg_highlight-soft_75_ffe45c_1x100.png'
77
+ file 'ui-icons_222222_256x240.png'
78
+ file 'ui-icons_228ef1_256x240.png'
79
+ file 'ui-icons_ef8c08_256x240.png'
80
+ file 'ui-icons_ffd27a_256x240.png'
81
+ end
82
+ file 'images/ui-icons_ffffff_256x240.png', :dest => 'images'
83
+ end
84
+ end
85
+ end
@@ -1,21 +1,20 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- module Net
4
- class HTTP
3
+ class MockHTTP
5
4
 
6
- def self.set_mock_http(mock_http)
7
- @mock_http = mock_http
8
- end
5
+ def self.set_mock_http(mock_http)
6
+ @mock_http = mock_http
7
+ end
9
8
 
10
- def self.start(host, port)
11
- yield @mock_http
12
- end
9
+ def start
10
+ yield self
13
11
  end
14
12
  end
15
13
 
16
14
  describe Scaffoldhub::RemoteFile do
17
15
 
18
16
  FAKE_SCAFFOLDHUB_URL = 'http://fake.scaffoldhub.org:1234/scaffolds/autocomplete/spec'
17
+ FAKE_GITHUB_URL = 'https://fake.github.com/patshaughnessy/scaffolds'
19
18
 
20
19
  describe '#remote_file_contents' do
21
20
 
@@ -23,14 +22,13 @@ describe Scaffoldhub::RemoteFile do
23
22
  subject do
24
23
  @status_proc = mock
25
24
  @status_proc.expects(:call).with(FAKE_SCAFFOLDHUB_URL)
26
- Scaffoldhub::RemoteFile.new(@status_proc)
25
+ Scaffoldhub::RemoteFile.new(FAKE_SCAFFOLDHUB_URL, @status_proc)
27
26
  end
28
- before do
29
- subject.stubs(:url).returns(FAKE_SCAFFOLDHUB_URL)
30
- end
31
-
32
27
  it 'should call the status proc with the url' do
33
- Net::HTTP.stubs(:start)
28
+ Net::HTTP.stubs(:new).returns(http = mock)
29
+ http.stubs(:start).returns(response = mock)
30
+ response.stubs(:code).returns(200)
31
+ response.stubs(:body).returns('')
34
32
  subject.remote_file_contents!
35
33
  end
36
34
  end
@@ -39,44 +37,53 @@ describe Scaffoldhub::RemoteFile do
39
37
 
40
38
  subject do
41
39
  (status_proc = mock).stubs(:call).with(FAKE_SCAFFOLDHUB_URL)
42
- Scaffoldhub::RemoteFile.new(status_proc)
43
- end
44
- before do
45
- subject.stubs(:url).returns(FAKE_SCAFFOLDHUB_URL)
40
+ Scaffoldhub::RemoteFile.new(FAKE_SCAFFOLDHUB_URL, status_proc)
46
41
  end
47
42
 
48
43
  it 'should call Net::HTTP with the proper host and port' do
49
- Net::HTTP.expects(:start).with('fake.scaffoldhub.org', 1234)
44
+ Net::HTTP.expects(:new).with('fake.scaffoldhub.org', 1234).returns(http = mock)
45
+ http.stubs(:start).returns(response = mock)
46
+ response.stubs(:code).returns(200)
47
+ response.stubs(:body).returns('')
50
48
  subject.remote_file_contents!
51
49
  end
52
50
 
53
51
  it 'should call GET on the url path and return the response body' do
54
- mock_http = mock
55
- mock_http.expects(:get).with('/scaffolds/autocomplete/spec').returns(mock_response = mock)
56
- mock_response.stubs(:code).returns(200)
57
- mock_response.stubs(:body).returns('RESPONSE')
58
- Net::HTTP.set_mock_http(mock_http)
52
+ Net::HTTP.stubs(:new).returns(mock_http = MockHTTP.new)
53
+ mock_http.expects(:get).with('/scaffolds/autocomplete/spec').returns(response = mock)
54
+ response.stubs(:code).returns(200)
55
+ response.stubs(:body).returns('RESPONSE')
59
56
  subject.remote_file_contents!.should == 'RESPONSE'
60
57
  end
61
58
 
62
59
  it 'should throw a NotFoundException on 404' do
63
- mock_http = mock
64
- mock_http.expects(:get).with('/scaffolds/autocomplete/spec').returns(mock_response = mock)
65
- mock_response.stubs(:code).returns(404)
66
- Net::HTTP.set_mock_http(mock_http)
60
+ Net::HTTP.stubs(:new).returns(mock_http = MockHTTP.new)
61
+ mock_http.expects(:get).returns(response = mock)
62
+ response.stubs(:code).returns(404)
67
63
  lambda { subject.remote_file_contents! }.should raise_error(Scaffoldhub::NotFoundException)
68
64
  end
69
65
 
70
66
  it 'should throw a NetworkErrorException on some other error' do
71
- mock_http = mock
72
- mock_http.expects(:get).with('/scaffolds/autocomplete/spec').raises(Errno::ECONNREFUSED)
73
- Net::HTTP.set_mock_http(mock_http)
67
+ Net::HTTP.stubs(:new).returns(mock_http = MockHTTP.new)
68
+ mock_http.expects(:get).raises(Errno::ECONNREFUSED)
74
69
  lambda { subject.remote_file_contents! }.should raise_error(Scaffoldhub::NetworkErrorException)
75
70
  end
76
71
  end
77
72
 
78
73
  describe 'Net:HTTP SSL calls' do
79
- #TBD
74
+ subject do
75
+ (status_proc = mock).stubs(:call).with(FAKE_GITHUB_URL)
76
+ Scaffoldhub::RemoteFile.new(FAKE_GITHUB_URL, status_proc)
77
+ end
78
+ it 'should call Net::HTTP with the proper SSL options' do
79
+ Net::HTTP.expects(:new).with('fake.github.com', 443).returns(http = mock)
80
+ http.expects(:use_ssl=).with(true)
81
+ http.expects(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE)
82
+ http.stubs(:start).returns(response = mock)
83
+ response.stubs(:code).returns(200)
84
+ response.stubs(:body).returns('')
85
+ subject.remote_file_contents!
86
+ end
80
87
  end
81
88
 
82
89
  end
@@ -1,5 +1,13 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
+ def find_spec(scaffold_spec, type, src)
4
+ find_spec_in_array(scaffold_spec.template_file_specs, type, src)
5
+ end
6
+
7
+ def find_spec_in_array(array, type, src)
8
+ array.detect { |spec| spec[:type] == type && spec[:src] == src }
9
+ end
10
+
3
11
  describe Scaffoldhub::ScaffoldSpec do
4
12
 
5
13
  before do
@@ -12,41 +20,94 @@ describe Scaffoldhub::ScaffoldSpec do
12
20
  describe 'parsing local scaffold spec' do
13
21
 
14
22
  subject do
15
- test_spec_path = File.join(File.dirname(__FILE__), 'fixtures', 'test_scaffoldspec.rb')
16
- Scaffoldhub::ScaffoldSpec.new(test_spec_path, true, @status_proc)
23
+ test_spec_path = File.join(File.dirname(__FILE__), 'fixtures', 'test_scaffold.rb')
24
+ scaffold = Scaffoldhub::ScaffoldSpec.new(test_spec_path, true, @status_proc)
25
+ scaffold.download_and_parse!
26
+ scaffold
17
27
  end
18
28
 
19
- before do
20
- Scaffoldhub::Specification.files = []
21
- Scaffoldhub::Specification.base_url = nil
29
+ it 'should set the base_url to the scaffold specs folder' do
30
+ subject.base_url.should == File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
22
31
  end
23
32
 
24
- it 'should require a local scaffold spec and parse the file list' do
25
- subject.download_and_parse!
26
- subject.template_file_specs.should == [
27
- { :type => 'erb', :src => 'templates/index3.html.erb', :dest => '' },
28
- { :type => 'controller', :src => 'templates/index2.html.erb', :dest => '' },
29
- { :type => 'other', :src => 'templates/index.html.erb', :dest => 'app/views/welcome' }
30
- ]
31
- subject.base_url.should == File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
33
+ it 'should parse the blog_post' do
34
+ subject.blog_post.should == 'http://patshaughnessy.net/2011/3/13/view-mapper-for-rails-3-scaffoldhub'
35
+ end
36
+
37
+ it 'should parse the model file' do
38
+ model_spec = subject.template_file_specs.detect { |spec| spec[:type] == :model }
39
+ find_spec(subject, :model, 'templates/model.rb').should_not be_nil
40
+ end
41
+
42
+ it 'should parse the controller file' do
43
+ find_spec(subject, :controller, 'templates/controller.rb').should_not be_nil
44
+ end
45
+
46
+ it 'should parse a view file' do
47
+ find_spec(subject, :view, 'templates/_form.html.erb').should_not be_nil
48
+ end
49
+
50
+ it 'should parse a layout file' do
51
+ find_spec(subject, :layout, 'templates/layout.erb').should_not be_nil
52
+ end
53
+
54
+ it 'should parse with_options and use :src as a folder for the given file' do
55
+ find_spec(subject, :view, 'templates/new.html.erb').should_not be_nil
56
+ find_spec(subject, :view, 'templates/edit.html.erb').should_not be_nil
57
+ find_spec(subject, :view, 'templates/index.html.erb').should_not be_nil
58
+ find_spec(subject, :view, 'templates/show.html.erb').should_not be_nil
59
+ end
60
+
61
+ it 'should parse a vanilla template file with a dest attribute' do
62
+ template_spec = find_spec(subject, :template, 'templates/other_code_file.erb')
63
+ template_spec.should_not be_nil
64
+ template_spec[:dest].should == 'lib/other_code_file.rb'
65
+ end
66
+
67
+ it 'should parse a normal file with a dest attribute' do
68
+ template_spec = find_spec(subject, :file, 'templates/jquery/jquery-1.4.4.min.js')
69
+ file_spec = subject.template_file_specs.detect { |spec| spec[:type] == :file }
70
+ file_spec.should_not be_nil
71
+ file_spec[:dest].should == 'public/javascripts'
72
+ end
73
+
74
+ it 'should recursively parse with_options' do
75
+ template_spec1 = find_spec(subject, :file, 'templates/jquery/jquery-ui-1.8.10.custom.min.js')
76
+ template_spec1.should_not be_nil
77
+ template_spec1[:dest].should == 'public/javascripts'
78
+ template_spec2 = find_spec(subject, :file, 'templates/jquery/ui-lightness/jquery-ui-1.8.10.custom.css')
79
+ template_spec2.should_not be_nil
80
+ template_spec2[:dest].should == 'public/javascripts/ui-lightness'
81
+ template_spec3 = find_spec(subject, :file, 'templates/jquery/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png')
82
+ template_spec3.should_not be_nil
83
+ template_spec3[:dest].should == 'public/javascripts/ui-lightness/images'
84
+ template_spec4 = find_spec(subject, :file, 'templates/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png')
85
+ template_spec4.should_not be_nil
86
+ template_spec4[:dest].should == 'public/javascripts/ui-lightness/images'
32
87
  end
33
88
  end
34
89
 
90
+
35
91
  describe 'parsing remote scaffold spec' do
36
92
 
93
+ before do
94
+ Scaffoldhub::Specification.files = []
95
+ Scaffoldhub::Specification.base_url = nil
96
+ end
97
+
37
98
  TEST_YAML = <<YAML
38
99
  ---
39
100
  :base_url: http://github.com/patshaughnessy/scaffolds/default
40
101
  :files:
41
102
  - :src: templates/index3.html.erb
42
103
  :dest:
43
- :type: erb
104
+ :type: view
44
105
  - :src: templates/index2.html.erb
45
106
  :dest:
46
107
  :type: controller
47
108
  - :src: templates/index.html.erb
48
109
  :dest: app/views/welcome
49
- :type: other
110
+ :type: file
50
111
  YAML
51
112
 
52
113
  subject do
@@ -59,18 +120,66 @@ YAML
59
120
  subject.expects(:remote_file_contents!).returns(TEST_YAML)
60
121
  end
61
122
 
62
- it 'should require a local scaffold spec' do
123
+ it 'should parse a remote yaml scaffold' do
63
124
  subject.download_and_parse!
64
125
  subject.template_file_specs.should == [
65
- { :type => 'erb', :src => 'templates/index3.html.erb', :dest => nil },
126
+ { :type => 'view', :src => 'templates/index3.html.erb', :dest => nil },
66
127
  { :type => 'controller', :src => 'templates/index2.html.erb', :dest => nil },
67
- { :type => 'other', :src => 'templates/index.html.erb', :dest => 'app/views/welcome' }
128
+ { :type => 'file', :src => 'templates/index.html.erb', :dest => 'app/views/welcome' }
68
129
  ]
69
130
  subject.base_url.should == 'http://github.com/patshaughnessy/scaffolds/default'
70
131
  end
71
132
  end
72
133
  end
73
134
 
135
+ describe 'generating yaml' do
136
+
137
+ subject do
138
+ test_spec_path = File.join(File.dirname(__FILE__), 'fixtures', 'test_scaffold.rb')
139
+ scaffold = Scaffoldhub::ScaffoldSpec.new(test_spec_path, true, @status_proc)
140
+ scaffold.download_and_parse!
141
+ scaffold
142
+ end
143
+
144
+ it 'should generate yaml from a scaffold spec' do
145
+ yaml = subject.to_yaml
146
+ parsed_yaml = YAML::load(yaml)
147
+ parsed_yaml[:base_url].should == 'https://github.com/your_name/your_repo/raw/master'
148
+ parsed_yaml[:blog_post].should == 'http://patshaughnessy.net/2011/3/13/view-mapper-for-rails-3-scaffoldhub'
149
+ parsed_yaml[:name].should == 'test_scaffold'
150
+ parsed_yaml[:description].should == 'The test_scaffold scaffold.'
151
+ parsed_yaml[:parameter_example].should == 'FIELD_NAME'
152
+ model_spec = find_spec_in_array(parsed_yaml[:files], :model, 'templates/model.rb')
153
+ model_spec.should_not be_nil
154
+ some_file_spec = find_spec_in_array(parsed_yaml[:files], :file, 'templates/jquery/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png')
155
+ some_file_spec.should_not be_nil
156
+ end
157
+
158
+ describe '#adjusted_base_url' do
159
+
160
+ it 'should use the raw github url when a repo root is specified' do
161
+ Scaffoldhub::Specification.base_url = 'https://github.com/your_name/your_repo'
162
+ Scaffoldhub::Specification.adjusted_base_url.should == 'https://github.com/your_name/your_repo/raw/master'
163
+ end
164
+
165
+ it 'should use the raw github url when a repo root is specified with a trailing slash' do
166
+ Scaffoldhub::Specification.base_url = 'https://github.com/your_name/your_repo/'
167
+ Scaffoldhub::Specification.adjusted_base_url.should == 'https://github.com/your_name/your_repo/raw/master'
168
+ end
169
+
170
+ it 'should use the raw github url when a blob url is specified' do
171
+ Scaffoldhub::Specification.base_url = 'https://github.com/patshaughnessy/scaffolds/blob/master/autocomplete/scaffold_spec.rb'
172
+ Scaffoldhub::Specification.adjusted_base_url.should == 'https://github.com/patshaughnessy/scaffolds/raw/master/autocomplete/scaffold_spec.rb'
173
+ end
174
+
175
+ it 'should use the raw github url when a tree url is specified' do
176
+ Scaffoldhub::Specification.base_url = 'https://github.com/patshaughnessy/scaffolds/tree/master/autocomplete/scaffold_spec.rb'
177
+ Scaffoldhub::Specification.adjusted_base_url.should == 'https://github.com/patshaughnessy/scaffolds/raw/master/autocomplete/scaffold_spec.rb'
178
+ end
179
+
180
+ end
181
+ end
182
+
74
183
  describe '#select_files' do
75
184
 
76
185
  subject do
@@ -79,10 +188,10 @@ YAML
79
188
 
80
189
  before do
81
190
  subject.stubs(:template_file_specs).returns([
82
- { :type => 'type1', :src => 'some_src', :dest => 'some_dest' },
83
- { :type => 'type1', :src => 'some_src2', :dest => 'some_dest' },
84
- { :type => 'type1', :src => 'some_src3', :dest => 'some_dest' },
85
- { :type => 'type2', :src => 'some_src4', :dest => 'some_dest' }
191
+ { :type => :type1, :src => 'some_src', :dest => 'some_dest' },
192
+ { :type => :type1, :src => 'some_src2', :dest => 'some_dest' },
193
+ { :type => :type1, :src => 'some_src3', :dest => 'some_dest' },
194
+ { :type => :type2, :src => 'some_src4', :dest => 'some_dest' }
86
195
  ])
87
196
  end
88
197
 
@@ -90,7 +199,7 @@ YAML
90
199
  Scaffoldhub::TemplateFile.expects(:new).returns(mock1 = mock)
91
200
  Scaffoldhub::TemplateFile.expects(:new).returns(mock2 = mock)
92
201
  Scaffoldhub::TemplateFile.expects(:new).returns(mock3 = mock)
93
- files = subject.select_files('type1')
202
+ files = subject.select_files(:type1)
94
203
  files.include?(mock1).should be_true
95
204
  files.include?(mock2).should be_true
96
205
  files.include?(mock3).should be_true
@@ -105,27 +214,20 @@ YAML
105
214
 
106
215
  before do
107
216
  subject.stubs(:template_file_specs).returns([
108
- { :type => 'type1', :src => 'some_src', :dest => 'some_dest' },
109
- { :type => 'type1', :src => 'some_src2', :dest => 'some_dest' },
110
- { :type => 'type1', :src => 'some_src3', :dest => 'some_dest' },
111
- { :type => 'type2', :src => 'some_src4', :dest => 'some_dest' }
217
+ { :type => :type1, :src => 'some_src', :dest => 'some_dest' },
218
+ { :type => :type2, :src => 'some_src2', :dest => 'some_dest' }
112
219
  ])
113
220
  subject.stubs(:base_url).returns('base')
114
221
  end
115
222
 
116
223
  it 'should find the file with the given type and src' do
117
- Scaffoldhub::TemplateFile.expects(:new).with('some_src2', 'some_dest', true, 'base', @status_proc).returns(mock1 = mock)
118
- subject.find_file('type1', 'some_src2').should == mock1
119
- end
120
-
121
- it 'should return nil if the name is not found' do
122
- Scaffoldhub::TemplateFile.expects(:new).never
123
- subject.find_file('type1', 'some_src5').should be_nil
224
+ Scaffoldhub::TemplateFile.expects(:new).with('some_src', 'some_dest', true, 'base', @status_proc).returns(mock1 = mock)
225
+ subject.find_file(:type1).should == mock1
124
226
  end
125
227
 
126
228
  it 'should return nil if the type is not found' do
127
229
  Scaffoldhub::TemplateFile.expects(:new).never
128
- subject.find_file('type3', 'some_src2').should be_nil
230
+ subject.find_file(:type3).should be_nil
129
231
  end
130
232
  end
131
233
  end
@@ -19,11 +19,11 @@ describe Scaffoldhub::TemplateFile do
19
19
 
20
20
  describe 'remote template file' do
21
21
 
22
- FAKE_GITHUB_URL = 'http://github.com/patshaughnessy/scaffolds/default'
22
+ FAKE_TEMPLATE_FILE_URL = 'http://github.com/patshaughnessy/scaffolds/default'
23
23
 
24
- subject { Scaffoldhub::TemplateFile.new('templates/index.html', 'public', false, FAKE_GITHUB_URL, @status_proc) }
24
+ subject { Scaffoldhub::TemplateFile.new('templates/index.html', 'public', false, FAKE_TEMPLATE_FILE_URL, @status_proc) }
25
25
 
26
- its(:url) { should == FAKE_GITHUB_URL + '/templates/index.html' }
26
+ its(:url) { should == FAKE_TEMPLATE_FILE_URL + '/templates/index.html' }
27
27
  its(:dest) { should == File.join('public', 'index.html') }
28
28
 
29
29
  describe '#download!' do
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: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 6
10
+ version: 0.0.6
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-03-24 00:00:00 -04:00
18
+ date: 2011-04-29 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -83,8 +83,8 @@ dependencies:
83
83
  description: Run Rails scaffold generator with customized templates downloaded from scaffoldhub.org
84
84
  email:
85
85
  - pat@patshaughnessy.net
86
- executables: []
87
-
86
+ executables:
87
+ - scaffoldhub
88
88
  extensions: []
89
89
 
90
90
  extra_rdoc_files: []
@@ -95,24 +95,29 @@ files:
95
95
  - Gemfile.lock
96
96
  - README.rdoc
97
97
  - Rakefile
98
+ - bin/scaffoldhub
98
99
  - lib/generators/active_record/scaffoldhub_generator.rb
99
100
  - lib/generators/erb/scaffoldhub_generator.rb
101
+ - lib/generators/new_scaffoldhub/new_scaffoldhub_generator.rb
102
+ - lib/generators/new_scaffoldhub/templates/scaffold_spec.rb.erb
103
+ - lib/generators/new_scaffoldhub/templates/screenshot.png
100
104
  - lib/generators/scaffold_controller/scaffoldhub_generator.rb
101
105
  - lib/generators/scaffoldhub/scaffoldhub_generator.rb
102
106
  - lib/scaffoldhub.rb
103
107
  - lib/scaffoldhub/helper.rb
104
108
  - lib/scaffoldhub/remote_file.rb
109
+ - lib/scaffoldhub/runner.rb
105
110
  - lib/scaffoldhub/scaffold_spec.rb
106
111
  - lib/scaffoldhub/specification.rb
107
112
  - lib/scaffoldhub/template_file.rb
108
113
  - scaffoldhub.gemspec
109
- - spec/fixtures/test_scaffoldspec.rb
114
+ - spec/fixtures/local_template_file.txt
115
+ - spec/fixtures/test_scaffold.rb
110
116
  - spec/helper_spec.rb
111
117
  - spec/remote_file_spec.rb
112
118
  - spec/scaffold_spec_spec.rb
113
119
  - spec/spec_helper.rb
114
120
  - spec/template_file_spec.rb
115
- - util/spec_to_yaml.rb
116
121
  has_rdoc: true
117
122
  homepage: http://scaffoldhub.org
118
123
  licenses: []
@@ -148,7 +153,8 @@ signing_key:
148
153
  specification_version: 3
149
154
  summary: Generate customized Rails scaffolding from scaffoldhub.org
150
155
  test_files:
151
- - spec/fixtures/test_scaffoldspec.rb
156
+ - spec/fixtures/local_template_file.txt
157
+ - spec/fixtures/test_scaffold.rb
152
158
  - spec/helper_spec.rb
153
159
  - spec/remote_file_spec.rb
154
160
  - spec/scaffold_spec_spec.rb
@@ -1,21 +0,0 @@
1
- Scaffoldhub::Specification.new do |s|
2
- s.base_url 'http://github.com/patshaughnessy/scaffolds/default'
3
- s.erb_file :src => 'templates/index3.html.erb', :dest => ''
4
- s.controller_file :src => 'templates/index2.html.erb', :dest => ''
5
- s.other_file :src => 'templates/index.html.erb', :dest => 'app/views/welcome'
6
- end
7
-
8
- # Yaml hash of scaffold options
9
- #
10
- #---
11
- #:base_url: http://github.com/patshaughnessy/scaffolds/default
12
- #:files:
13
- #- :src: templates/index.html.erb
14
- # :dest: app/views/welcome
15
- # :type: other
16
- #- :src: templates/index2.html.erb
17
- # :dest:
18
- # :type: controller
19
- #- :src: templates/index3.html.erb
20
- # :dest:
21
- # :type: erb
data/util/spec_to_yaml.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'yaml'
2
- require '../lib/scaffoldhub/specification'
3
- require ARGV[0]
4
-
5
- open('scaffold_spec.yaml', 'wb') do |file|
6
- file.write(Scaffoldhub::Specification.to_yaml)
7
- end