scaffoldhub 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scaffoldhub (0.0.12)
4
+ scaffoldhub (0.0.13)
5
5
  rails
6
6
 
7
7
  GEM
@@ -34,7 +34,7 @@ GEM
34
34
  activemodel (= 3.0.7)
35
35
  activesupport (= 3.0.7)
36
36
  activesupport (3.0.7)
37
- arel (2.0.9)
37
+ arel (2.0.10)
38
38
  builder (2.1.2)
39
39
  diff-lcs (1.1.2)
40
40
  erubis (2.6.6)
@@ -48,7 +48,7 @@ GEM
48
48
  mime-types (1.16)
49
49
  mocha (0.9.12)
50
50
  polyglot (0.3.1)
51
- rack (1.2.2)
51
+ rack (1.2.3)
52
52
  rack-mount (0.6.14)
53
53
  rack (>= 1.0.0)
54
54
  rack-test (0.5.7)
@@ -27,4 +27,8 @@ class ScaffoldhubGenerator < Rails::Generators::ScaffoldGenerator
27
27
  gem(*args)
28
28
  end
29
29
  end
30
+
31
+ def display_post_install_message
32
+ say post_install_message
33
+ end
30
34
  end
@@ -1,6 +1,9 @@
1
1
  module Scaffoldhub
2
2
  module Helper
3
3
 
4
+ class ScaffoldParameterMissing < RuntimeError
5
+ end
6
+
4
7
  class << self
5
8
  def scaffold_spec
6
9
  @scaffold_spec
@@ -65,6 +68,10 @@ module Scaffoldhub
65
68
  def download_scaffold_spec!
66
69
  scaffold_spec = ScaffoldSpec.new(scaffold_name, options[:local], status_proc)
67
70
  scaffold_spec.download_and_parse!
71
+ if scaffold_spec.parameter_example && scaffold_parameter.nil?
72
+ say_status :error, parameter_missing_message(scaffold_spec.parameter_example), :red
73
+ raise ScaffoldParameterMissing
74
+ end
68
75
  scaffold_spec
69
76
  end
70
77
 
@@ -77,7 +84,14 @@ module Scaffoldhub
77
84
  end
78
85
 
79
86
  def replace_name_tokens(dest)
80
- dest.gsub(/PLURAL_NAME/, file_name.pluralize).gsub(/NAME/, file_name)
87
+ result = dest.gsub(/PLURAL_NAME/, file_name.pluralize).gsub(/NAME/, file_name)
88
+ result.gsub!(/SCAFFOLD_PARAMETER/, scaffold_parameter) unless scaffold_parameter.nil?
89
+ result
90
+ end
91
+
92
+ def post_install_message
93
+ message = scaffold_spec.post_install_message
94
+ replace_name_tokens(message) if message
81
95
  end
82
96
 
83
97
  def status_proc
@@ -90,5 +104,8 @@ module Scaffoldhub
90
104
  options[:scaffold].split(':')[index]
91
105
  end
92
106
 
107
+ def parameter_missing_message(example)
108
+ "Scaffold parameter missing; please specify the #{example} after the scaffold name like this: --scaffold #{scaffold_name}:#{example}"
109
+ end
93
110
  end
94
111
  end
@@ -81,6 +81,22 @@ module Scaffoldhub
81
81
  end
82
82
  end
83
83
 
84
+ def post_install_message
85
+ if @local
86
+ Specification.post_install_message
87
+ else
88
+ @spec[:post_install_message]
89
+ end
90
+ end
91
+
92
+ def parameter_example
93
+ if @local
94
+ Specification.parameter_example
95
+ else
96
+ @spec[:parameter_example]
97
+ end
98
+ end
99
+
84
100
  def to_yaml
85
101
  Specification.to_yaml if @local
86
102
  end
@@ -39,8 +39,8 @@ end
39
39
  module Scaffoldhub
40
40
  class Specification
41
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
42
+ mattr_accessor :name, :description, :base_url, :blog_post, :screenshot, :parameter_example, :post_install_message
43
+ define_dsl_attributes :name, :description, :base_url, :blog_post, :screenshot, :parameter_example, :post_install_message
44
44
 
45
45
  mattr_accessor :files, :errors, :tags, :gems
46
46
  @@files = []
@@ -70,7 +70,8 @@ module Scaffoldhub
70
70
  :files => files,
71
71
  :screenshot => screenshot,
72
72
  :tags => tags,
73
- :parameter_example => parameter_example
73
+ :parameter_example => parameter_example,
74
+ :post_install_message => post_install_message
74
75
  }.to_yaml
75
76
  end
76
77
 
data/lib/scaffoldhub.rb CHANGED
@@ -6,6 +6,6 @@ require 'scaffoldhub/helper'
6
6
  require 'scaffoldhub/runner'
7
7
 
8
8
  module Scaffoldhub
9
- VERSION = '0.0.12'
9
+ VERSION = '0.0.13'
10
10
  SCAFFOLD_HUB_SERVER = 'www.scaffoldhub.org'
11
11
  end
@@ -83,4 +83,6 @@ Scaffoldhub::Specification.new do
83
83
  file 'images/ui-icons_ffffff_256x240.png', :dest => 'images'
84
84
  end
85
85
  end
86
+
87
+ post_install_message 'Please do this, this and that.'
86
88
  end
data/spec/helper_spec.rb CHANGED
@@ -33,6 +33,7 @@ describe Scaffoldhub::Helper do
33
33
  mock_spec = mock
34
34
  Scaffoldhub::ScaffoldSpec.stubs(:new).with('some_scaffold', true, status_proc).returns(mock_spec)
35
35
  mock_spec.stubs(:download_and_parse!)
36
+ mock_spec.stubs(:parameter_example)
36
37
  mock_template_file_array = [
37
38
  Scaffoldhub::TemplateFile.new('src1', 'dest1', nil, true, '/some/path', status_proc),
38
39
  Scaffoldhub::TemplateFile.new('src2', 'dest2', nil, true, '/some/path', status_proc),
@@ -69,6 +70,7 @@ describe Scaffoldhub::Helper do
69
70
  mock_spec = mock
70
71
  Scaffoldhub::ScaffoldSpec.stubs(:new).with('some_scaffold', false, status_proc).returns(mock_spec)
71
72
  mock_spec.stubs(:download_and_parse!)
73
+ mock_spec.stubs(:parameter_example)
72
74
  template1 = Scaffoldhub::TemplateFile.new('src1', 'dest1', nil, false, 'http://some.server/some/path', status_proc)
73
75
  template1.expects(:download!).returns(template1)
74
76
  template1.stubs(:src).returns('src1')
@@ -98,6 +100,7 @@ describe Scaffoldhub::Helper do
98
100
  Scaffoldhub::Helper.scaffold_spec = nil
99
101
  @mock_spec = mock
100
102
  @mock_spec.stubs(:download_and_parse!)
103
+ @mock_spec.stubs(:parameter_example)
101
104
  status_proc = mock
102
105
  Scaffoldhub::ScaffoldSpec.expects(:new).once.with('some_scaffold', false, status_proc).returns(@mock_spec)
103
106
  @gen = FakeGenerator.new(false)
@@ -140,6 +143,7 @@ describe Scaffoldhub::Helper do
140
143
  describe '#replace_name_tokens' do
141
144
  subject { FakeGenerator.new(false) }
142
145
  before do
146
+ subject.expects(:scaffold_parameter).twice.returns('some_field')
143
147
  subject.expects(:file_name).returns('person')
144
148
  subject.expects(:file_name).returns(name = mock)
145
149
  name.stubs(:pluralize).returns('people')
@@ -150,5 +154,8 @@ describe Scaffoldhub::Helper do
150
154
  it 'should replace the PLURAL_NAME token' do
151
155
  subject.replace_name_tokens('PLURAL_NAME.html.erb').should == 'people.html.erb'
152
156
  end
157
+ it 'should replace the SCAFFOLD_PARAMETER token' do
158
+ subject.replace_name_tokens('blah blah SCAFFOLD_PARAMETER blah blah blah').should == 'blah blah some_field blah blah blah'
159
+ end
153
160
  end
154
161
  end
@@ -37,6 +37,10 @@ describe Scaffoldhub::ScaffoldSpec do
37
37
  subject.blog_post.should == 'http://patshaughnessy.net/2011/3/13/view-mapper-for-rails-3-scaffoldhub'
38
38
  end
39
39
 
40
+ it 'should parse the post install message' do
41
+ subject.post_install_message.should == 'Please do this, this and that.'
42
+ end
43
+
40
44
  it 'should parse all of the gems' do
41
45
  subject.gems.should == [
42
46
  [ 'some_gem', '1.0' ],
@@ -105,6 +109,7 @@ describe Scaffoldhub::ScaffoldSpec do
105
109
  TEST_YAML = <<YAML
106
110
  ---
107
111
  :base_url: http://github.com/patshaughnessy/scaffolds/default
112
+ :post_install_message: Please do this, that and the other thing.
108
113
  :files:
109
114
  - :src: templates/index3.html.erb
110
115
  :dest:
@@ -143,6 +148,7 @@ YAML
143
148
  { :type => 'file', :src => 'templates/index.html.erb', :dest => 'app/views/welcome', :rename => nil }
144
149
  ]
145
150
  subject.base_url.should == 'http://github.com/patshaughnessy/scaffolds/default'
151
+ subject.post_install_message.should == 'Please do this, that and the other thing.'
146
152
  subject.gems.should == [
147
153
  [ 'some_gem', '1.0' ],
148
154
  [ 'some_other_gem', { :group => :test, :git => 'git://github.com/rails/rails' } ]
@@ -164,6 +170,7 @@ YAML
164
170
  yaml = subject.to_yaml
165
171
  parsed_yaml = YAML::load(yaml)
166
172
  parsed_yaml[:base_url].should == 'https://github.com/your_name/your_repo/raw/master'
173
+ parsed_yaml[:post_install_message].should == 'Please do this, this and that.'
167
174
  parsed_yaml[:blog_post].should == 'http://patshaughnessy.net/2011/3/13/view-mapper-for-rails-3-scaffoldhub'
168
175
  parsed_yaml[:name].should == 'test_scaffold'
169
176
  parsed_yaml[:description].should == 'The test_scaffold scaffold.'
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: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 12
10
- version: 0.0.12
9
+ - 13
10
+ version: 0.0.13
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-24 00:00:00 -04:00
18
+ date: 2011-05-27 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency