@@ -49,16 +49,16 @@ unless (project_found)
49
49
end
50
50
51
51
desc "upgrade PROJECT_NAME" , "upgrade ceedling for a project (not req'd if gem used)"
52
- method_option :docs , :type => :boolean , :default => false , :desc => "Add docs in project vendor directory"
53
- method_option :local , :type => :boolean , :default => false , :desc => "Create a copy of Ceedling in the project vendor directory"
54
- method_option :no_configs , :type => :boolean , :default => false , :desc => "Don't install starter configuration files"
55
- method_option :noconfigs , :type => :boolean , :default => false
56
-
57
- #deprecated:
58
- method_option :no_docs , :type => :boolean , :default => false
59
- method_option :nodocs , :type => :boolean , :default => false
60
52
def upgrade ( name , silent = false )
61
- copy_assets_and_create_structure ( name , silent , true , options || { :upgrade => true } )
53
+ as_local = true
54
+ begin
55
+ require "yaml"
56
+ as_local = ( YAML . load_file ( File . join ( name , "project.yml" ) ) [ :project ] [ :which_ceedling ] != 'gem' )
57
+ rescue
58
+ raise "ERROR: Could not find valid project file '#{ yaml_path } '"
59
+ end
60
+ found_docs = File . exists? ( File . join ( name , "docs" , "CeedlingPacket.md" ) )
61
+ copy_assets_and_create_structure ( name , silent , true , { :upgrade => true , :no_configs => true , :local => as_local , :docs => found_docs } )
62
62
end
63
63
64
64
no_commands do
@@ -90,26 +90,30 @@ unless (project_found)
90
90
FileUtils . touch ( File . join ( test_support_path , '.gitkeep' ) )
91
91
92
92
# If documentation requested, create a place to dump them and do so
93
+ doc_path = ""
93
94
if use_docs
94
- doc_path = File . join ( ceedling_path , 'docs' )
95
+ doc_path = use_gem ? File . join ( name , 'docs' ) : File . join ( ceedling_path , 'docs' )
95
96
FileUtils . mkdir_p doc_path
96
97
97
98
in_doc_path = lambda { |f | File . join ( doc_path , f ) }
98
99
99
- doc_files = [
100
- 'docs/CeedlingPacket.md' ,
101
- 'vendor/c_exception/docs/CException.md' ,
102
- 'vendor/cmock/docs/CMock_Summary.md' ,
103
- 'vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf' ,
104
- 'vendor/unity/docs/UnityAssertionsReference.md' ,
105
- 'vendor/unity/docs/UnityConfigurationGuide.md' ,
106
- 'vendor/unity/docs/UnityGettingStartedGuide.md' ,
107
- 'vendor/unity/docs/UnityHelperScriptsGuide.md' ,
108
- 'vendor/unity/docs/ThrowTheSwitchCodingStandard.md' ,
109
- ]
110
-
111
- doc_files . each do |f |
112
- copy_file ( f , in_doc_path . call ( File . basename ( f ) ) , :force => force )
100
+ # Add documentation from main projects to list
101
+ doc_files = { }
102
+ [ 'docs' , 'vendor/unity/docs' , 'vendor/cmock/docs' , 'vendor/cexception/docs' ] . each do |p |
103
+ Dir [ File . expand_path ( File . join ( here , p , '*.md' ) ) ] . each do |f |
104
+ doc_files [ File . basename ( f ) ] = f unless ( doc_files . include? f )
105
+ end
106
+ end
107
+
108
+ # Add documentation from plugins to list
109
+ Dir [ File . join ( here , 'plugins/**/README.md' ) ] . each do |plugin_path |
110
+ k = "plugin_" + plugin_path . split ( /\\ |\/ / ) [ -2 ] + ".md"
111
+ doc_files [ k ] = File . expand_path ( plugin_path )
112
+ end
113
+
114
+ # Copy all documentation
115
+ doc_files . each_pair do |k , v |
116
+ copy_file ( v , in_doc_path . call ( k ) , :force => force )
113
117
end
114
118
end
115
119
@@ -133,7 +137,6 @@ unless (project_found)
133
137
{ :src => 'vendor/cmock/config/' , :dst => 'vendor/cmock/config' } ,
134
138
{ :src => 'vendor/cmock/lib/' , :dst => 'vendor/cmock/lib' } ,
135
139
{ :src => 'vendor/cmock/src/' , :dst => 'vendor/cmock/src' } ,
136
- { :src => 'vendor/deep_merge/lib/' , :dst => 'vendor/deep_merge/lib' } ,
137
140
{ :src => 'vendor/diy/lib' , :dst => 'vendor/diy/lib' } ,
138
141
{ :src => 'vendor/unity/auto/' , :dst => 'vendor/unity/auto' } ,
139
142
{ :src => 'vendor/unity/src/' , :dst => 'vendor/unity/src' } ,
@@ -146,16 +149,24 @@ unless (project_found)
146
149
147
150
# We're copying in a configuration file if we haven't said not to
148
151
if ( use_configs )
149
- if use_gem
150
- copy_file ( File . join ( 'assets' , 'project_as_gem.yml' ) , File . join ( name , 'project.yml' ) , :force => force )
152
+ dst_yaml = File . join ( name , 'project.yml' )
153
+ src_yaml = if use_gem
154
+ File . join ( here , 'assets' , 'project_as_gem.yml' )
151
155
else
152
- copy_file ( File . join ( 'assets' , 'project_with_guts.yml' ) , File . join ( name , 'project.yml' ) , :force => force )
153
156
if is_windows?
154
157
copy_file ( File . join ( 'assets' , 'ceedling.cmd' ) , File . join ( name , 'ceedling.cmd' ) , :force => force )
155
158
else
156
159
copy_file ( File . join ( 'assets' , 'ceedling' ) , File . join ( name , 'ceedling' ) , :force => force )
157
160
File . chmod ( 0755 , File . join ( name , 'ceedling' ) )
158
161
end
162
+ File . join ( here , 'assets' , 'project_with_guts.yml' )
163
+ end
164
+
165
+ # Perform the actual clone of the config file, while updating the version
166
+ File . open ( dst_yaml , 'w' ) do |dst |
167
+ require File . expand_path ( File . join ( File . dirname ( __FILE__ ) , ".." , "lib" , "ceedling" , "version.rb" ) )
168
+ dst << File . read ( src_yaml ) . gsub ( ":ceedling_version: '?'" , ":ceedling_version: #{ Ceedling ::Version ::CEEDLING } " )
169
+ puts " create #{ dst_yaml } "
159
170
end
160
171
end
161
172
@@ -167,8 +178,8 @@ unless (project_found)
167
178
unless silent
168
179
puts "\n "
169
180
puts "Project '#{ name } ' #{ force ? "upgraded" : "created" } !"
170
- puts " - Tool documentation is located in vendor/ceedling/docs " if use_docs
171
- puts " - Execute 'ceedling help' to view available test & build tasks"
181
+ puts " - Tool documentation is located in #{ doc_path } " if use_docs
182
+ puts " - Execute 'ceedling help' from #{ name } to view available test & build tasks"
172
183
puts ''
173
184
end
174
185
end
@@ -206,10 +217,10 @@ unless (project_found)
206
217
207
218
desc "version" , "return the version of the tools installed"
208
219
def version ( )
209
- require ' ceedling/ version.rb'
210
- puts " Ceedling:: #{ Ceedling ::Version ::CEEDLING } "
211
- puts " CMock:: #{ Ceedling ::Version ::CMOCK } "
212
- puts " Unity:: #{ Ceedling ::Version ::UNITY } "
220
+ require File . expand_path ( File . join ( File . dirname ( __FILE__ ) , ".." , "lib" , " ceedling" , " version.rb" ) )
221
+ puts " Ceedling:: #{ Ceedling ::Version ::CEEDLING } "
222
+ puts " CMock:: #{ Ceedling ::Version ::CMOCK } "
223
+ puts " Unity:: #{ Ceedling ::Version ::UNITY } "
213
224
puts " CException:: #{ Ceedling ::Version ::CEXCEPTION } "
214
225
end
215
226
end
287
298
options [ :list_tasks ] = true
288
299
when /^-T$/
289
300
options [ :list_tasks ] = true
301
+ when /^--tasks$/
302
+ options [ :list_tasks ] = true
290
303
when /^project:(\w +)/
291
304
ENV [ 'CEEDLING_USER_PROJECT_FILE' ] = "#{ $1} .yml"
292
305
else
0 commit comments