origen_app_generators 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/config/commands.rb +13 -25
  3. data/config/version.rb +2 -2
  4. data/lib/origen_app_generators.rb +22 -6
  5. data/lib/origen_app_generators/application.rb +21 -14
  6. data/lib/origen_app_generators/base.rb +18 -3
  7. data/lib/origen_app_generators/plugin.rb +17 -2
  8. data/lib/origen_app_generators/sub_block_parser.rb +81 -0
  9. data/lib/origen_app_generators/test_engineering/stand_alone_application.rb +232 -0
  10. data/lib/origen_app_generators/test_engineering/{generic_test_block.rb → test_block.rb} +2 -2
  11. data/lib/tasks/app_generators.rake +42 -3
  12. data/lib/tasks/boot.rb +1 -1
  13. data/templates/app_generators/application/Gemfile +6 -7
  14. data/templates/app_generators/application/Rakefile +0 -4
  15. data/templates/app_generators/application/config/application.rb +8 -11
  16. data/templates/app_generators/application/config/{environment.rb → boot.rb} +0 -0
  17. data/templates/app_generators/application/config/commands.rb +11 -13
  18. data/templates/app_generators/application/origen_core_session +2 -0
  19. data/templates/app_generators/plugin/Gemfile +9 -0
  20. data/templates/app_generators/plugin/Rakefile +9 -0
  21. data/templates/app_generators/plugin/config/boot.rb +17 -0
  22. data/templates/app_generators/test_engineering/stand_alone_application/Gemfile +14 -0
  23. data/templates/app_generators/test_engineering/stand_alone_application/environment/j750.rb +1 -0
  24. data/templates/app_generators/test_engineering/stand_alone_application/environment/jlink.rb +1 -0
  25. data/templates/app_generators/test_engineering/stand_alone_application/environment/uflex.rb +1 -0
  26. data/templates/app_generators/test_engineering/stand_alone_application/environment/v93k.rb +1 -0
  27. data/templates/app_generators/test_engineering/stand_alone_application/lib/ip_block.rb +23 -0
  28. data/templates/app_generators/test_engineering/stand_alone_application/lib/ip_block_controller.rb +5 -0
  29. data/templates/app_generators/test_engineering/stand_alone_application/lib/top_level.rb +33 -0
  30. data/templates/app_generators/test_engineering/stand_alone_application/lib/top_level_controller.rb +21 -0
  31. data/templates/app_generators/test_engineering/stand_alone_application/pattern/example.rb +4 -0
  32. data/templates/app_generators/test_engineering/stand_alone_application/target/top_level.rb +8 -0
  33. data/templates/app_generators/test_engineering/{generic_test_block → test_block}/lib/interface.rb +0 -0
  34. data/templates/app_generators/test_engineering/{generic_test_block → test_block}/program/prb1.rb +0 -0
  35. data/templates/app_generators/test_engineering/{generic_test_block → test_block}/target/j750.rb +0 -0
  36. data/templates/app_generators/test_engineering/{generic_test_block → test_block}/target/ultraflex.rb +0 -0
  37. data/templates/app_generators/test_engineering/{generic_test_block → test_block}/target/v93k.rb +0 -0
  38. data/templates/web/origen_app_generators/test_engineering/generic_stand_alone_application.md.erb +9 -0
  39. metadata +28 -41
  40. data/templates/app_generators/application/config/users.rb +0 -29
  41. data/templates/app_generators/application/templates/web/archive.md.erb +0 -11
  42. data/templates/app_generators/application/templates/web/contact.md.erb +0 -36
  43. data/templates/app_generators/application/templates/web/docs/environment/definitions.md.erb +0 -17
  44. data/templates/app_generators/application/templates/web/docs/environment/installation.md.erb +0 -22
  45. data/templates/app_generators/application/templates/web/docs/environment/introduction.md.erb +0 -5
  46. data/templates/app_generators/application/templates/web/index.md.erb +0 -12
  47. data/templates/app_generators/application/templates/web/layouts/_basic.html.erb +0 -14
  48. data/templates/app_generators/application/templates/web/layouts/_doc.html.erb +0 -35
  49. data/templates/app_generators/application/templates/web/partials/_navbar.html.erb +0 -23
  50. data/templates/app_generators/application/templates/web/references.md.erb +0 -39
  51. data/templates/app_generators/application/templates/web/release_notes.md.erb +0 -5
  52. data/templates/app_generators/plugin/config/development.rb +0 -12
  53. data/templates/app_generators/plugin/templates/web/index.md.erb +0 -60
  54. data/templates/app_generators/plugin/templates/web/partials/_navbar.html.erb +0 -22
  55. data/templates/web/_history.md +0 -166
  56. data/templates/web/archive.md.erb +0 -11
  57. data/templates/web/contact.md.erb +0 -36
  58. data/templates/web/docs/developers/creating.md.erb +0 -290
  59. data/templates/web/docs/environment/installation.md.erb +0 -12
  60. data/templates/web/docs/environment/introduction.md.erb +0 -10
  61. data/templates/web/example.md.erb +0 -73
  62. data/templates/web/index.md.erb +0 -48
  63. data/templates/web/layouts/_basic.html.erb +0 -18
  64. data/templates/web/layouts/_doc.html.erb +0 -37
  65. data/templates/web/origen_app_generators/application.md.erb +0 -116
  66. data/templates/web/origen_app_generators/plugin.md.erb +0 -29
  67. data/templates/web/origen_app_generators/test_engineering/generic_test_block.md.erb +0 -16
  68. data/templates/web/partials/_navbar.html.erb +0 -22
  69. data/templates/web/release_notes.md.erb +0 -5
@@ -1,11 +0,0 @@
1
- % render "layouts/basic.html", tab: :archive, yammer_comments: false do
2
-
3
- # Archive
4
-
5
- Documentation from previous releases is available via the links below:
6
-
7
- % Origen.app.versions.reverse_each do |version|
8
- * [<%= version %>](<%= Origen.app.config.web_domain %>/<%= version.gsub(".", "_") %>)
9
- % end
10
-
11
- % end
@@ -1,36 +0,0 @@
1
- % render "layouts/basic.html", tab: :contact, yammer_comments: false do
2
-
3
- # Contact Us
4
-
5
- The following engineers can be contacted about this application:
6
-
7
- % Origen.app.developers.each do |user|
8
- * [<%= user.name %>](http://freeshare.freescale.net:2222/my/Person.aspx?accountname=fsl\<%= user.r_number %>)
9
- % end
10
-
11
- %# An example of how to write a contact page:
12
- %#Please use PDM For any bug reports or change/feature requests:
13
- %#
14
- %#* [C90TFS_NVM_tester on PDM](http://designpdm.freescale.net/Agile/PLMServlet?fromPCClient=true&module=PartFamilyHandler&requestUrl=module%3DPartFamilyHandler%26opcode%3DdisplayObject%26classid%3D2000004409%26objid%3D17718323%26tabid%3D2%26)
15
- %#
16
- %#For test related issues you can contact:
17
- %#
18
- %#* [Stephen McGinty](http://freeshare.freescale.net:2222/my/Person.aspx?accountname=fsl\r49409)
19
- %#* [Thao Huynh](http://freeshare.freescale.net:2222/my/Person.aspx?accountname=fsl%5CR6AANF)
20
- %#
21
- %#For product/yield issues contact:
22
- %#
23
- %#* [Andrew Hardell](http://freeshare.freescale.net:2222/my/Person.aspx?accountname=fsl%5CR12635)
24
- %#* [Eddie Lepore](http://freeshare.freescale.net:2222/my/Person.aspx?accountname=fsl%5CB06626)
25
- %#
26
- %#The manager of this project is:
27
- %#
28
- %#* [Wendy Malloch](http://freeshare.freescale.net:2222/my/Person.aspx?accountname=fsl%5CTTZ231)
29
- %#
30
- %#
31
- %#Finally if you are not sure who to contact, or if your question may have device/reliability
32
- %#implications, then you can use the Split Gate Flash Test and Reliability mailing list:
33
- %#
34
- %#* [Email SGFTANDR](mailto:SGFTANDR@freescale.com)
35
-
36
- % end
@@ -1,290 +0,0 @@
1
- % render "../../layouts/doc.html" do
2
-
3
- This document outlines the process for creating a new application generator.
4
-
5
- ### Background
6
-
7
- This plugin uses a code generator API from Origen core which itself leans heavily on a 3rd party gem library called
8
- Thor. This gem is used quite widely in the Ruby community for this kind of thing, not least by the code generators
9
- provided by the Ruby on Rails platform.
10
-
11
- The code generator API allows the user to do things like:
12
-
13
- * Run code to collect user input
14
- * Compile templates to produce dynamic output based on the user's responses
15
- * Copy files verbatim
16
- * Create directories and symlinks
17
- * Delete and inject lines into existing files
18
-
19
- Each application type that can be generated by this plugin is an example of a code generator.
20
-
21
- The code new application generators are organized into the following hierarchy:
22
-
23
- ~~~text
24
- OrigenAppGenerators::Base
25
- |
26
- -> OrigenAppGenerators::Application
27
- |
28
- -> OrigenAppGenerators::Plugin
29
- ~~~
30
-
31
- **All additional generators within this application must be a subclass of either <code>OrigenAppGenerators::Application</code>
32
- or <code>OrigenAppGenerators::Plugin</code> depending on whether the end application is intended to be a plugin or not.**
33
-
34
- The new application generators should all perform the following functions:
35
-
36
- * Prompt the user with some questions to get the new application name and so on
37
- * Create the new application files by either copying or compiling source files and creating
38
- symlinks or directories as required
39
- * Make any final modifications to the resulting files
40
- * Display any information that the user should know about their new application
41
-
42
- #### Generator Execution
43
-
44
- When a generator is executed any methods defined in it will be called in the order that they are
45
- defined.
46
- Any methods that are marked as <code>protected</code> will not be called.
47
-
48
- For example when the following generator is executed:
49
-
50
- ~~~ruby
51
- module OrigenAppGenerators
52
- class MyAppGenerator < Application
53
- def say_hello
54
- puts "Hello"
55
- end
56
-
57
- def call_a_helper
58
- puts "About to call"
59
- a_helper_method
60
- puts "Returned from call"
61
- end
62
-
63
- protected
64
-
65
- def a_helper_method
66
- puts "Helper method called!"
67
- end
68
-
69
- def this_does_nothing
70
- puts "Another method called!"
71
- end
72
- end
73
- end
74
- ~~~
75
-
76
- Then you would see this:
77
-
78
- ~~~text
79
- Hello
80
- About to call
81
- Helper method called!
82
- Returned from call
83
- ~~~
84
-
85
- Note that any methods defined by the parent class will get called first. In this application the
86
- parent <code>Application</code> and <code>Plugin</code> classes implement a method to get the user
87
- input that will be common to all applications.
88
-
89
- You can disable this behavior if required by re-defining the relevant methods within the child generator class.
90
-
91
- #### Source Files
92
-
93
- All template or static source files for the generators live in <code>templates/app_generators/</code> and from
94
- there in sub folders based on the name of the particular generator.
95
-
96
- All path references to source files made in your generator should be relative to its source file folder, and in
97
- practice what this means is that if you want to refer to the source file of what will become
98
- <code>Origen.root/config/application.rb</code> then you just refer to <code>config/application.rb</code>.
99
-
100
- When looking for a particular source file the generator will search in the various source directories
101
- belonging to your generator's parent classes.
102
- For example let's say you make a test engineering generator that has the following class hierarchy:
103
-
104
- ~~~text
105
- OrigenAppGenerators::Base
106
- |
107
- -> OrigenAppGenerators::Application
108
- |
109
- -> OrigenAppGenerators::Plugin
110
- |
111
- -> OrigenAppGenerators::TestEngineering::TestBlock
112
- ~~~
113
-
114
- Then the following source paths will be searched in this order:
115
-
116
- ~~~text
117
- templates/app_generators/test_engineering/test_block
118
- templates/app_generators/plugin
119
- templates/app_generators/application
120
- ~~~
121
-
122
- This means that if you create a file called <code>config/application.rb</code> within
123
- <code>templates/app_generators/test_engineering/test_block</code> then this will override the corresponding
124
- file from the plugin sources and which would itself override the same file from the application sources.
125
-
126
- However see the warning in [The Filelist](<%= path "docs/developers/creating#The_Filelist" %>) section below before doing this!
127
-
128
- ### Creating a New Generator
129
-
130
- A rake task is provided to create a new generator, run it as follows:
131
-
132
- ~~~text
133
- rake new
134
- ~~~
135
-
136
- ### Lean Environment
137
-
138
- When the generator is run by a user to generate a new application, it will not run within the scope of an
139
- Origen application.
140
- This means that any references to <code>Origen.app</code> within the generator code are meaningless and will
141
- result in an error.
142
-
143
- Furthermore because there is no application there is also no associated gem bundle, so the generator must
144
- be able to run within the lean Ruby environment that is used to boot Origen. In practice what this means is
145
- that you can use any gems that Origen itself relies on (these will be installed in the base Ruby installation),
146
- but you cannot use any others.
147
-
148
- The rake tasks provided for testing your new generator will run it within the lean environment, so if it
149
- works there you can be confident that it will also run in production.
150
-
151
- ### The Filelist
152
-
153
- Each generator should return the list of files to be created in the new application via its
154
- <code>filelist</code> method.
155
- If you don't make any changes to this then it will simply inherit the list of files defined
156
- by the generator's parent class.
157
-
158
- The filelist is also used to define any directories or symlinks that should be created.
159
- The generator class created by the <code>rake new</code> task contains a commented example of how to add or
160
- remove the various elements from the filelist.
161
-
162
- Some application generators may not make any changes to the filelist and will simply augment
163
- the basic application/plugin shell by adding additional code to some of the existing files.
164
-
165
- This can be done by either overriding the source file by defining it in the generator's own
166
- source directory, or by [post-modifying](<%= path "docs/developers/creating#Post_Generation_Modifications" %>)
167
- the files after the filelist has been rendered.
168
-
169
- <div class="alert">
170
- <strong>Warning!</strong> While it is tempting (and easier) to simply copy a source file and then
171
- edit it as required for your target application, this will make your generator harder to maintain as it
172
- will not automatically pick up changes and improvements to the master templates that will occur over time.
173
- Therefore it is always preferable to post-modify the file to delete sections or to modify or add additional code
174
- whenever possible.
175
- </div>
176
-
177
- **Note that developers should not add logic to the application/plugin master source files to
178
- implement generator specific output. This approach is not scalable as in the future this plugin
179
- is expected to support many different application types.**
180
-
181
- Instead individual generators must either completely override or post-modify the master files
182
- as appropriate.
183
-
184
- #### Templates
185
-
186
- All files in the file list will be compiled unless explicitly marked with <code>copy: true</code>
187
- or if the destination file name ends in <code>.erb</code>.
188
-
189
- ERB markup can be used the same way as in regular Origen templates with the following exceptions:
190
-
191
- Whole line Ruby is not enabled (a limitation imposed by Thor), therefore instead of this:
192
-
193
- ~~~eruby
194
- <%= "%" %> if x_is_true
195
- Include something
196
- <%= "%" %> end
197
- ~~~
198
-
199
- You must do:
200
-
201
- ~~~eruby
202
- <%= "<" + "% if x_is_true -%" + ">" %>
203
- Include something
204
- <%= "<" + "% end -%" + ">" %>
205
- ~~~
206
-
207
- Access to variables collected by your generator at runtime is done by assigning them to instance
208
- variables (instead of the options hash used by the Origen compiler).
209
-
210
- So for example if you have your user input a product name, then you should assign that to an
211
- instance variable:
212
-
213
- ~~~ruby
214
- @product_name = get_product_name
215
- ~~~
216
-
217
- Then in the template:
218
-
219
- ~~~eruby
220
- The product name is <%= "<" + "%= @product_name %" + ">" %>
221
- ~~~
222
-
223
- By convention templates in this plugin do not end in <code>.erb</code> and this is reserved
224
- for files that would become <code>.erb</code> files in the end application.
225
-
226
- ### Post Generation Modifications
227
-
228
- It is better to customize any files that are common to all applications
229
- by post modification rather than by completely overriding the entire file.
230
-
231
- To do this you have access to the Thor Action methods described here:
232
- [Thor Action API](http://www.rubydoc.info/github/wycats/thor/Thor/Actions)
233
-
234
- You can see some examples of these being used in the <code>enable</code> method in
235
- <code>lib/app_generators/new.rb</code> where they are used to add the new generator details
236
- to <code>lib/origen_app_generators.rb</code>.
237
-
238
- As a quick example say you wanted to add a method to <code>config/application.rb</code>, this
239
- could be achieved by injecting it at the end of the class like this:
240
-
241
- ~~~ruby
242
- # Always ensure the filelist has been rendered first
243
- def generate_files
244
- build_filelist
245
- end
246
-
247
- # Add a custom domain method to config/application.rb
248
- def add_method_to_application
249
- # Define a regular expression to define a point in the file where you want to inject, in this
250
- # case the 'end' of the class definition (the only 'end' that occurs at the beginning of a line)
251
- end_of_class = /^end/
252
- # Define the code snippet
253
- code = <<-END
254
- def some_domain_specific_method
255
- do_something
256
- end
257
- END
258
- # Now inject it
259
- inject_into_file "config/application.rb", code, before: end_of_class
260
- end
261
- ~~~
262
-
263
- ### Documentation
264
-
265
- The rake task will create a documentation file for your new generator in
266
- <code>templates/web/origen_app_generators/</code> and this should be used to document
267
- any information about the new application shell that your target audience might find useful.
268
-
269
- This page will be automatically linked to from the [OrigenAppGenerators Homepage](<%= path "/" %>)
270
- when it is next released.
271
-
272
- ### Testing the Generator
273
-
274
- Rake tasks are provided to test your new generator, to run the <code>origen new</code> command as
275
- it would appear to your audience run <code>rake test</code>.
276
-
277
- Alternatively to skip the first section that selects the required generator you can run
278
- <code>rake 'run[TestEngineering::TestBlock]'</code>, substituting the class name for that of
279
- your new generator.
280
-
281
- In both cases the new application will be built in <code>tmp/</code> and you can cd into
282
- that and run it to see if everything works.
283
-
284
- ### Releasing the Generator
285
-
286
- To release the generator simply release a new production version of this plugin, the
287
- <code>origen new</code> command will automatically check for and run the latest production version
288
- of it every time it is invoked.
289
-
290
- % end
@@ -1,12 +0,0 @@
1
- % render "layouts/doc.html" do
2
-
3
- Execute the following commands to create a development workspace:
4
-
5
- ~~~
6
- mkdir <%= Origen.app.name %>
7
- cd <%= Origen.app.name %>
8
- dssc setvault <%= Origen.config.vault %> .
9
- dssc pop -rec -uni -force -get -ver <%= Origen.app.version %> .
10
- ~~~
11
-
12
- % end
@@ -1,10 +0,0 @@
1
- % render "layouts/doc.html" do
2
-
3
- This documentation is primarily aimed at engineers who want to either create a new shell generator
4
- or to maintain or modify an existing one.
5
-
6
- All of the user facing documentation is contained on the [Home page](<%= path "/" %>) and
7
- which includes links to any shell specific information that has been provided by the
8
- shell authors.
9
-
10
- % end
@@ -1,73 +0,0 @@
1
- % render "layouts/basic.html" do
2
-
3
- %# HTML tags can be embedded in mark down files if you want to do specific custom
4
- %# formatting like this, but in most cases that is not required.
5
- <h1><%= Origen.config.name %> <span style="font-size: 14px">(<%= Origen.app.version %>)</span></h1>
6
-
7
- Welcome to your application's documentation...
8
-
9
- Here are some pointers to get you started with writing Origen documents:
10
-
11
- ### Markdown
12
-
13
- Most of your documents (such as this one you are reading) will be written in Markdown. This
14
- allows you to create good looking and well formatted web-based documents easily and without
15
- having to know anything about HTML.
16
-
17
- Origen uses the Kramdown library to process the Markdown, this has a good quick reference
18
- guide on the Markdown syntax here: [Markdown Quick Reference](http://kramdown.rubyforge.org/quickref.html)
19
-
20
- ### Links
21
-
22
- Links can be added to your documents easily, like this one for example:
23
-
24
- * [Freescale](http://www.freescale.com)
25
-
26
- For linking to other pages within your own documents it is recommended that you use the
27
- 'path' helper to generate the url. By doing this Origen should generate links that work
28
- correctly for both serving documents locally when developing and when deploying to a remote
29
- web server. Here is an example:
30
-
31
- * [Docs](<%= path "/docs/environment/introduction" %>)
32
-
33
- ### Code Examples
34
-
35
- In the course of writing documentation you will probably want to show code examples
36
- from time to time. Generic code snippets can be easily formatted with a mono-spaced
37
- font like this:
38
-
39
- ~~~
40
- origen t debug
41
- origen g list/production.list
42
- ~~~
43
-
44
- If you are showing examples of Ruby then they can be easily syntax-highlighted for
45
- better presentation:
46
-
47
- ~~~ruby
48
- # Cool, this is easy
49
- def some_ruby
50
- @blah = Blah.new
51
- end
52
- ~~~
53
-
54
- Origen uses the Coderay library for syntax highlighting and therefore should in theory
55
- be able to highlight all languages listed here: [CodeRay Syntax Highlighting](http://coderay.rubychan.de/)
56
-
57
- ### Custom HTML
58
-
59
- You may occasionally wish to have low level control of your documentation's HTML, this
60
- can be done by simply embedding the HTML directly alongside the Markdown.
61
-
62
- Origen already uses the [Twitter Bootstrap](http://twitter.github.io/bootstrap/index.html)
63
- framework to generate these documents, so you already have full access to the features
64
- provided by that framework.
65
-
66
- For example here is how to insert a [Bootstrap alert](http://twitter.github.io/bootstrap/components.html#alerts):
67
-
68
- <div class="alert">
69
- <button type="button" class="close" data-dismiss="alert">&times;</button>
70
- <strong>Warning!</strong> This example was just copied directly from the bootstrap documentation!
71
- </div>
72
-
73
- % end
@@ -1,48 +0,0 @@
1
- % render "layouts/basic.html" do
2
-
3
- %# HTML tags can be embedded in mark down files if you want to do specific custom
4
- %# formatting like this, but in most cases that is not required.
5
- <h1><%= Origen.app.namespace %> <span style="font-size: 14px">(<%= Origen.app.version %>)</span></h1>
6
-
7
- ### Introduction
8
-
9
- This plugin is used by Origen Core to generate new application shells via the <code>origen new</code>
10
- command.
11
-
12
- As well as providing generic plugin and application shells many customized builds for a particular
13
- engineering domain, function, or business group are available to.
14
-
15
- ### How to Use
16
-
17
- Run the <code>origen new</code> command outside of an application workspace, this will automatically
18
- run the latest production release of this plugin to generate the new application:
19
-
20
- ~~~text
21
- origen new my_app_name
22
- ~~~
23
-
24
- If you want to use a pre-release or older version of the generator a version can be specified
25
- like this:
26
-
27
- ~~~text
28
- origen new my_app_name --version 0.1.0
29
- ~~~
30
-
31
- ### Available Application Shells
32
-
33
- The following application shells are currently available, click the links to see any specific
34
- information that the shell author has provided:
35
-
36
- * [Generic Application](<%= path "origen_app_generators/application" %>)
37
- * [Generic Plugin](<%= path "origen_app_generators/plugin" %>)
38
-
39
- % OrigenAppGenerators::AVAILABLE.reverse_each do |domain, generators|
40
- #### <%= domain %>
41
-
42
- % generators.reverse_each do |generator|
43
- * [<%= generator.desc %>](<%= path generator.to_s.underscore %>)
44
- % end
45
-
46
- % end
47
-
48
- % end