scaffoldhub 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/generators/new_scaffold/templates/scaffold_spec.rb.erb +3 -0
- data/lib/generators/scaffoldhub/scaffoldhub_generator.rb +6 -0
- data/lib/scaffoldhub.rb +1 -1
- data/lib/scaffoldhub/helper.rb +17 -0
- data/lib/scaffoldhub/scaffold_spec.rb +8 -0
- data/lib/scaffoldhub/specification.rb +7 -1
- data/spec/fixtures/test_scaffold.rb +7 -8
- data/spec/scaffold_spec_spec.rb +42 -25
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -58,4 +58,7 @@ Scaffoldhub::Specification.new do
|
|
58
58
|
# Copy any file without running an ERB transformation
|
59
59
|
# file 'xyz.html', :dest => 'path/to/xyz.html'
|
60
60
|
|
61
|
+
# Add a gem to the Gemfile
|
62
|
+
# gem 'some_gem', '1.0'
|
63
|
+
# gem "some_other_gem", :group => :test, :git => "git://github.com/rails/rails"
|
61
64
|
end
|
data/lib/scaffoldhub.rb
CHANGED
data/lib/scaffoldhub/helper.rb
CHANGED
@@ -41,6 +41,23 @@ module Scaffoldhub
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def each_gem
|
45
|
+
begin
|
46
|
+
gems = scaffold_spec.gems.each do |gem|
|
47
|
+
yield gem
|
48
|
+
end
|
49
|
+
rescue Errno::ENOENT => e
|
50
|
+
say_status :error, e.message, :red
|
51
|
+
nil
|
52
|
+
rescue Scaffoldhub::NotFoundException => e
|
53
|
+
say_status :error, "HTTP 404 not found error for #{e.message}", :red
|
54
|
+
nil
|
55
|
+
rescue Scaffoldhub::NetworkErrorException => e
|
56
|
+
say_status :error, "HTTP error connecting to #{e.message}", :red
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
44
61
|
def scaffold_spec
|
45
62
|
Helper.scaffold_spec ||= download_scaffold_spec!
|
46
63
|
end
|
@@ -42,10 +42,11 @@ module Scaffoldhub
|
|
42
42
|
mattr_accessor :name, :description, :base_url, :blog_post, :screenshot, :parameter_example
|
43
43
|
define_dsl_attributes :name, :description, :base_url, :blog_post, :screenshot, :parameter_example
|
44
44
|
|
45
|
-
mattr_accessor :files, :errors, :tags
|
45
|
+
mattr_accessor :files, :errors, :tags, :gems
|
46
46
|
@@files = []
|
47
47
|
@@errors = []
|
48
48
|
@@tags = []
|
49
|
+
@@gems = []
|
49
50
|
|
50
51
|
define_dsl_file_keyword :model, :migration, :controller, :view, :layout
|
51
52
|
|
@@ -65,6 +66,7 @@ module Scaffoldhub
|
|
65
66
|
:description => description,
|
66
67
|
:base_url => adjusted_base_url,
|
67
68
|
:blog_post => blog_post,
|
69
|
+
:gems => gems,
|
68
70
|
:files => files,
|
69
71
|
:screenshot => screenshot,
|
70
72
|
:tags => tags,
|
@@ -155,6 +157,10 @@ module Scaffoldhub
|
|
155
157
|
self.class.add_tag(keyword)
|
156
158
|
end
|
157
159
|
|
160
|
+
def gem(*args)
|
161
|
+
@@gems << args
|
162
|
+
end
|
163
|
+
|
158
164
|
protected
|
159
165
|
|
160
166
|
def join_with_parent(parent_value, new_value)
|
@@ -18,13 +18,13 @@ Scaffoldhub::Specification.new do
|
|
18
18
|
# Tag(s) to help scaffoldhub.org users find your scaffold
|
19
19
|
tag 'jquery'
|
20
20
|
tag 'autocomplete'
|
21
|
-
end
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
# Optionally specify an example of a scaffold parameter
|
23
|
+
parameter_example 'FIELD_NAME'
|
25
24
|
|
26
|
-
|
27
|
-
|
25
|
+
# Optionally post a link to an article you write explaining how the scaffold works.
|
26
|
+
blog_post 'http://patshaughnessy.net/2011/3/13/view-mapper-for-rails-3-scaffoldhub'
|
27
|
+
end
|
28
28
|
|
29
29
|
# Define a model template - this ERB file will be used to generate a new
|
30
30
|
# model class with this path & filename: app/models/NAME.rb
|
@@ -38,9 +38,8 @@ Scaffoldhub::Specification.new do
|
|
38
38
|
# view file with this path & filename: app/views/PLURAL_NAME/view_file_name.rb
|
39
39
|
view 'templates/_form.html.erb'
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
layout 'templates/layout.erb'
|
41
|
+
gem 'some_gem', '1.0'
|
42
|
+
gem "some_other_gem", :group => :test, :git => "git://github.com/rails/rails"
|
44
43
|
|
45
44
|
# You can use "with_options" to specify the same source folder for a series of templates:
|
46
45
|
with_options :src => 'templates' do
|
data/spec/scaffold_spec_spec.rb
CHANGED
@@ -13,6 +13,9 @@ describe Scaffoldhub::ScaffoldSpec do
|
|
13
13
|
before do
|
14
14
|
@status_proc = mock
|
15
15
|
@status_proc.stubs(:call)
|
16
|
+
Scaffoldhub::Specification.files = []
|
17
|
+
Scaffoldhub::Specification.gems = []
|
18
|
+
Scaffoldhub::Specification.base_url = nil
|
16
19
|
end
|
17
20
|
|
18
21
|
describe 'parsing scaffold spec' do
|
@@ -34,6 +37,13 @@ describe Scaffoldhub::ScaffoldSpec do
|
|
34
37
|
subject.blog_post.should == 'http://patshaughnessy.net/2011/3/13/view-mapper-for-rails-3-scaffoldhub'
|
35
38
|
end
|
36
39
|
|
40
|
+
it 'should parse all of the gems' do
|
41
|
+
subject.gems.should == [
|
42
|
+
[ 'some_gem', '1.0' ],
|
43
|
+
[ 'some_other_gem', { :group => :test, :git => 'git://github.com/rails/rails' } ]
|
44
|
+
]
|
45
|
+
end
|
46
|
+
|
37
47
|
it 'should parse the model file' do
|
38
48
|
model_spec = subject.template_file_specs.detect { |spec| spec[:type] == :model }
|
39
49
|
find_spec(subject, :model, 'templates/model.rb').should_not be_nil
|
@@ -47,10 +57,6 @@ describe Scaffoldhub::ScaffoldSpec do
|
|
47
57
|
find_spec(subject, :view, 'templates/_form.html.erb').should_not be_nil
|
48
58
|
end
|
49
59
|
|
50
|
-
it 'should parse a layout file' do
|
51
|
-
find_spec(subject, :layout, 'templates/layout.erb').should_not be_nil
|
52
|
-
end
|
53
|
-
|
54
60
|
it 'should parse with_options and use :src as a folder for the given file' do
|
55
61
|
find_spec(subject, :view, 'templates/new.html.erb').should_not be_nil
|
56
62
|
find_spec(subject, :view, 'templates/edit.html.erb').should_not be_nil
|
@@ -96,24 +102,29 @@ describe Scaffoldhub::ScaffoldSpec do
|
|
96
102
|
|
97
103
|
describe 'parsing remote scaffold spec' do
|
98
104
|
|
99
|
-
before do
|
100
|
-
Scaffoldhub::Specification.files = []
|
101
|
-
Scaffoldhub::Specification.base_url = nil
|
102
|
-
end
|
103
|
-
|
104
105
|
TEST_YAML = <<YAML
|
106
|
+
---
|
107
|
+
:base_url: http://github.com/patshaughnessy/scaffolds/default
|
108
|
+
:files:
|
109
|
+
- :src: templates/index3.html.erb
|
110
|
+
:dest:
|
111
|
+
:rename:
|
112
|
+
:type: view
|
113
|
+
- :src: templates/index2.html.erb
|
114
|
+
:dest:
|
115
|
+
:rename: new_file_name.rb
|
116
|
+
:type: controller
|
117
|
+
- :src: templates/index.html.erb
|
118
|
+
:dest: app/views/welcome
|
119
|
+
:rename:
|
120
|
+
:type: file
|
121
|
+
:gems: |
|
105
122
|
---
|
106
|
-
|
107
|
-
|
108
|
-
-
|
109
|
-
:
|
110
|
-
|
111
|
-
- :src: templates/index2.html.erb
|
112
|
-
:dest:
|
113
|
-
:type: controller
|
114
|
-
- :src: templates/index.html.erb
|
115
|
-
:dest: app/views/welcome
|
116
|
-
:type: file
|
123
|
+
- - some_gem
|
124
|
+
- "1.0"
|
125
|
+
- - some_other_gem
|
126
|
+
- :group: :test
|
127
|
+
:git: git://github.com/rails/rails
|
117
128
|
YAML
|
118
129
|
|
119
130
|
subject do
|
@@ -121,19 +132,21 @@ YAML
|
|
121
132
|
end
|
122
133
|
|
123
134
|
before do
|
124
|
-
Scaffoldhub::Specification.files = []
|
125
|
-
Scaffoldhub::Specification.base_url = nil
|
126
135
|
subject.expects(:remote_file_contents!).returns(TEST_YAML)
|
127
136
|
end
|
128
137
|
|
129
138
|
it 'should parse a remote yaml scaffold' do
|
130
139
|
subject.download_and_parse!
|
131
140
|
subject.template_file_specs.should == [
|
132
|
-
{ :type => 'view', :src => 'templates/index3.html.erb', :dest => nil },
|
133
|
-
{ :type => 'controller', :src => 'templates/index2.html.erb', :dest => nil },
|
134
|
-
{ :type => 'file', :src => 'templates/index.html.erb', :dest => 'app/views/welcome' }
|
141
|
+
{ :type => 'view', :src => 'templates/index3.html.erb', :dest => nil, :rename => nil },
|
142
|
+
{ :type => 'controller', :src => 'templates/index2.html.erb', :dest => nil, :rename => 'new_file_name.rb' },
|
143
|
+
{ :type => 'file', :src => 'templates/index.html.erb', :dest => 'app/views/welcome', :rename => nil }
|
135
144
|
]
|
136
145
|
subject.base_url.should == 'http://github.com/patshaughnessy/scaffolds/default'
|
146
|
+
subject.gems.should == [
|
147
|
+
[ 'some_gem', '1.0' ],
|
148
|
+
[ 'some_other_gem', { :group => :test, :git => 'git://github.com/rails/rails' } ]
|
149
|
+
]
|
137
150
|
end
|
138
151
|
end
|
139
152
|
end
|
@@ -154,6 +167,10 @@ YAML
|
|
154
167
|
parsed_yaml[:blog_post].should == 'http://patshaughnessy.net/2011/3/13/view-mapper-for-rails-3-scaffoldhub'
|
155
168
|
parsed_yaml[:name].should == 'test_scaffold'
|
156
169
|
parsed_yaml[:description].should == 'The test_scaffold scaffold.'
|
170
|
+
parsed_yaml[:gems].should == [
|
171
|
+
[ 'some_gem', '1.0' ],
|
172
|
+
[ 'some_other_gem', { :group => :test, :git => 'git://github.com/rails/rails' } ]
|
173
|
+
]
|
157
174
|
parsed_yaml[:parameter_example].should == 'FIELD_NAME'
|
158
175
|
model_spec = find_spec_in_array(parsed_yaml[:files], :model, 'templates/model.rb')
|
159
176
|
model_spec.should_not be_nil
|
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:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
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-05-
|
18
|
+
date: 2011-05-10 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|