cbt 0.0.1

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/README.md ADDED
@@ -0,0 +1,221 @@
1
+ CBT - A Bundle of Corona SDK Build Tools
2
+ ==============================================
3
+
4
+ Concepts
5
+ ------------
6
+
7
+ You split your CoronaSDK based mobile app into many `component`s.
8
+
9
+ Each component contains one or more `.lua` module files, a series of `*_spec.lua`
10
+ unit-test files, a `main.lua` file used to run the unit-tests, and may also have
11
+ some asset files (pictures and audio files).
12
+
13
+ The default location to store components under `components/` folder, one
14
+ sub-folder corresponds for one component. You create/edit your `.lua` files
15
+ under the `components/` folder, and use
16
+
17
+ $ cbt
18
+
19
+ to copy those files along with other component files to `workspace` folder, where
20
+ you check the behavior of your component using Corona's simulator. Cbt command will
21
+ figure out which component you are working on from the current git branch name (we will
22
+ describe more options and commands later).
23
+
24
+ All your components are configured in `config/components.yml` file.
25
+
26
+ Every `.lua` file and asset file may have several platform-specific versions, include:
27
+
28
+ - iOS: for iphone and ipad build
29
+ - android: for android build
30
+ - mock: provide a **mock-up** module for other component's development
31
+ - debug: the default file that used for development and test
32
+
33
+ For example you may have `Timer.mock.lua`, `Timer.android.lua` ... Where `cbt` will
34
+ chose one of them to use. Also, there is a mechanism to include platform specific
35
+ code inside a file using Luobo syntax (we will reveal the details later).
36
+
37
+ Component Development
38
+ --------------------------
39
+
40
+ A **workspace** is a sub-folder under `workspaces`, like `workspace/component_platform`.
41
+
42
+ You use `cbt checkout` command to create and update a workspace.
43
+
44
+ For example,
45
+
46
+ $ cbt checkout --platform ios --require debug component_a
47
+
48
+ Will create (or update existing contents inside) `workspaces/component_a_ios`, the
49
+ `.lua` and asset files for component `components_a` are copied to the workspace using
50
+ their `ios` version, but files that `components_a` requires from other components
51
+ will be copied using their `debug` version.
52
+
53
+ The default value for the developing component and required components are `debug` and `mock`, so
54
+
55
+ $ cbt checkout component_a
56
+
57
+ means
58
+
59
+ $ cbt checkout --platform debug --require mock component_a
60
+
61
+ Work with Dev-flow Tool
62
+ ---------------------------
63
+
64
+ Create tasks with the component name in format like one of the follows
65
+
66
+ [++] component/component_name: xxxxxx
67
+ [++] comp/component_name: xxxxxx
68
+ [++] ct/component_name: xxxxxx
69
+
70
+ `cbt` commands will respect `component_name` as the current working component
71
+ so you do not need to specify it in the command line:
72
+
73
+ $ cbt checkout
74
+
75
+ under `ct/comp_a` branch will checkout `comp_a`. Also, `checkout` is the default
76
+ command for cbt tool, so the above command can be write as simple as:
77
+
78
+ $ cbt
79
+
80
+ (same as `cbt checkout --platform debug --require mock component_a` if you are
81
+ in a proper git branch).
82
+
83
+ **NOTE**: do not edit any file under `workspace` folder. Usually you should add
84
+ `workspace` in you `.gitignore` file.
85
+
86
+ Start A New Component
87
+ --------------------------
88
+
89
+ To begin a new component development, first you add an entry in `config/components.yml` like:
90
+
91
+ components:
92
+ component_name1:
93
+ lua_modules: [lua_file1, SomeClass<SuperClass]
94
+
95
+ This defined a component `component_name1` and two `.lua` module files inside the component.
96
+
97
+ If your component only have one module `.lua` file and has the same name as the component itself,
98
+ you can omit the `module` key in component definitions.
99
+
100
+ `SomeClass<SuperClass` means `SomeClass` will inherited from `SuperClass`.
101
+
102
+ Then you can:
103
+
104
+ $ cbt create component_name1
105
+
106
+ to create file skeleton for those `.lua` files under `components/component_name1`.
107
+
108
+ Then you:
109
+
110
+ $ cbt checkout component_name1
111
+
112
+ to create a folder under `workspaces/component_name1`, include the `debug` version of `lua_file1.lua` ...
113
+ and `mock` version of _ALL_ other files from other components.
114
+
115
+ $ cbt cleanup
116
+
117
+ or
118
+
119
+ $ cbt close
120
+
121
+ Will safely delete files and folders under workspace.
122
+
123
+ Platforms
124
+ --------------------
125
+
126
+ Each `.lua` module file and asset file may has several platform-specific versions of them.
127
+
128
+ The current supported platforms include `ios`, `android`, `mock` and `debug`. You name you file like:
129
+
130
+ comp.ios.lua
131
+ comp.mock.lua
132
+ ...
133
+
134
+ Debug is the default platform so you could use just `comp.lua`.
135
+
136
+ Asset files use the similar naming role, such as `slash.png`, `slash.mock.png`, `slash.ios.png` ...
137
+
138
+ The debug version `component.lua` is the _default_ version, will be used if other version is not available.
139
+ Ensure it exists otherwise `cbt` raise errors.
140
+
141
+ Usually you do not need a `component.debug.lua` (as `component.lua` is the debug version already),
142
+ but you can provide this file if you will edit `component.lua` for a while, but do not prevent others from
143
+ build a debug app use your stable version of `component.lua` file.
144
+
145
+ Luobo Converters
146
+ --------------------
147
+
148
+ The `mock` version of the component should be implement as quickly as possible, provide only
149
+ `mocking` functions of public APIs. This helps other component's development, as they can interact with
150
+ a quick version of _your_ component.
151
+
152
+ For `ios`, `android` and `debug` versions of your component, usually they are not so different so you
153
+ do not need to separate them to different files. An other way to provide platform-specific code is use
154
+ Luobo (search luobo-gem) converter's syntax:
155
+
156
+ IOS ->
157
+ some_code_only_for_iOS
158
+
159
+ Android ->
160
+ some_code_only_for_android
161
+
162
+ DEBUG ->
163
+ ...
164
+
165
+ Use indent to end the code block. If you want no indent before your code, use:
166
+
167
+ IOS: noindent ->
168
+ code_without_indent
169
+
170
+ Refer `luobo-gem` for more syntax details.
171
+
172
+ By this way, usually you only need platform-specific lua file `component_name.lua` and
173
+ `component_name.mock.lua`, and occasionally provide a `component_name.debug.lua` while
174
+ you make a long term development on that component.
175
+
176
+ API and SPEC tests
177
+ ----------------------
178
+
179
+ You should provide the same API for both build and mock version of your component.
180
+
181
+ You should have a `component_lua_file_spec.lua` file as unit test for each `.lua` module file.
182
+
183
+ This spec file should in `Luobo::CoronaSpec` format.
184
+
185
+ Components Diagram
186
+ ---------------------
187
+
188
+ Based on `components.yml` and API function definition in your source lua file (the debug version
189
+ will be parsed),
190
+
191
+ $ cbt diagram
192
+
193
+ will create a series of diagram png file reflect component relationships under `docs` folder.
194
+
195
+ Class inherit relations and class method definitions will automatically handled. You can also create
196
+ custom relationship with:
197
+
198
+ # diagram -> SomeLuaModule related to
199
+
200
+ Strings after SomeLuaModule will become `label` of Graphviz's edge (arrow).
201
+
202
+ When you done your development of all components, issue `cbt build` to create a device build of
203
+ the whole app.
204
+
205
+ Build the Entire Application
206
+ ---------------------------------
207
+
208
+ For example if you have a application names `dulcinea`, you define `main` as `lua_module` in it,
209
+ then you can build a distribution version as:
210
+
211
+ $ cbt checkout --platform ios --require_platform ios dulcinea
212
+
213
+ `build` is a alias of command `checkout` and will force `require_platform` to the same of `platform`
214
+ option. So the above command also can be issued as:
215
+
216
+ $ cbt build -p ios dulcinea
217
+
218
+ Which will results a `workspaces/dulcinea_ios` folder that contains files you can use to build
219
+ you application to distribute to AppStore.
220
+
221
+
data/ROADMAP ADDED
@@ -0,0 +1,33 @@
1
+ % ----
2
+ title: CBT - Corona Build Tools
3
+ status: producing
4
+ leader: huangw
5
+ moderator: xuyc
6
+ team: [liudx cuibg wangqh]
7
+ year: 2013
8
+ % ----
9
+
10
+ [+] design: define the interface of command line program 04/06 @huangw:04/06
11
+ [++] readme: rewrite readme document 04/06 @huangw:04/06
12
+ [++] test_design: design test strategy 04/06 @huangw:04/06
13
+
14
+ [+] alpha_release: implement all features 04/06-04/15 @huangw:04/08
15
+ [++] struct: create new directory structure 04/06-04/07 @huangw:04/07
16
+ [++] copy: copy library files to build directory 04/08-04/09 @huangw:04/08
17
+
18
+ [+] alpha2: implement all features under new design 04/06-04/20 @huangw:05/23
19
+ [++] review_readme: review readme again 04/08 @huangw:04/08
20
+ [++] revise_cmd: revise command line options again 04/12 @huangw:04/12
21
+ [++] create: create skeleton files 04/12 @huangw:04/12
22
+ [++] digest: a mechanism for file contestency 04/12-04/13 @huangw:04/12
23
+ [++] revise_again: revise command structure again 04/15 @huangw:04/15
24
+ [++] cout: checkout lua and asset files 04/13-04/15 @huangw:04/17
25
+ [++] spec: spec test mechanism with TTS function 04/16-04/22 @huangw:04/19
26
+ [++] erd: create component-relationship diagram 04/22-04/23 @huangw:05/23
27
+
28
+ [+] release_v0.0.1: create gem for the first time 06/03 @huangw:06/04
29
+
30
+ [+] beta_release: fix functionalities 04/23-04/27 @huangw
31
+ [++] rewrite_beta: review and rewrite all functions 04/23-04/25 @huangw:10
32
+
33
+ [+] release_v0.1.0: first public release 04/27 @huangw
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'rspec/core/rake_task'
2
+ RSpec::Core::RakeTask.new('spec')
3
+
data/bin/cbt ADDED
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env ruby
2
+ # vim: syn=ruby
3
+
4
+ # $: << 'lib' # debug only
5
+
6
+ require "cbt"
7
+ require "optparse"
8
+ require "term/ansicolor"
9
+ class String; include Term::ANSIColor end
10
+ require "dev_flow"
11
+
12
+ # setup for some constants
13
+ known_platforms = %w[ios android mock debug]
14
+ cmd_alias = {co: 'checkout', close: 'cleanup'}
15
+
16
+ # parse command line options
17
+ options = {}
18
+ optparse = OptionParser.new do |opt|
19
+ opt.banner = "Usage: cbt [OPTIONS] COMMAND [COMPONENT,COMPONENT,...]"
20
+ opt.separator ""
21
+ opt.separator "Commands:"
22
+ opt.separator " checkout: checkout file to workspace for development"
23
+ opt.separator " build : an alias of checkout, but force require files use"
24
+ opt.separator " the same platform version as the current component"
25
+ opt.separator " create : create skeleton files for a component"
26
+ opt.separator " diagram : create/update component relationship diagram"
27
+ opt.separator " cleanup : safely delete a workspace folder"
28
+ opt.separator ""
29
+ opt.separator "Platforms: " + known_platforms.join(', ')
30
+ opt.separator ""
31
+ opt.separator ""
32
+
33
+ # ------------------------
34
+ options[:components_dir] = 'components'
35
+ opt.on('--components_dir DIR', 'direcctory name contains all components') do |dir|
36
+ options[:components_dir] = dir
37
+ end
38
+
39
+ options[:workspace_dir] = 'workspaces'
40
+ opt.on('-w DIR', '--workspace_dir DIR', 'direcctory for development') do |dir|
41
+ options[:workspace_dir] = dir
42
+ end
43
+
44
+ options[:assets_dir] = 'assets'
45
+ opt.on('-t DIR', '--assets_dir DIR', 'global assets directory') do |dir|
46
+ options[:assets_dir] = dir
47
+ end
48
+
49
+ options[:config_file] = 'config/components.yml'
50
+ opt.on('-c FILE', '--config_file FILE', 'specify the components definition file') do |file|
51
+ options[:config_file] = file
52
+ end
53
+
54
+ options[:platform] = 'debug'
55
+ opt.on("-p PLATFORM", "--platform PLATFORM", 'platform version for component') do |platform|
56
+ raise "unknown platform #{platform}" unless known_platforms.include? platform
57
+ options[:platform] = platform
58
+ end
59
+
60
+ options[:require_platform] = 'mock'
61
+ opt.on("-r PLATFORM", "--require_platform PLATFORM", 'platform version for required components') do |rp|
62
+ raise "unknown platform #{rp}" unless known_platforms.include? rp
63
+ options[:require_platform] = rp
64
+ end
65
+
66
+ opt.on('-a', '--all', 'apply to all components') do
67
+ options[:all] = true
68
+ end
69
+
70
+ opt.on('-v', '--verbose', 'print more messages') do
71
+ options[:verbose] = true
72
+ end
73
+
74
+ opt.on('-f', '--force', 'create/checkout even if file exists') do
75
+ options[:force] = true
76
+ end
77
+
78
+ opt.on('--no-consistency-check', 'checkout without check file consistency') do
79
+ options[:no_consistency_check] = true
80
+ end
81
+
82
+ opt.on('--all-spec', 'copy spec test files from all components') do
83
+ options[:all_spec] = true
84
+ end
85
+
86
+ opt.on('-s', '--similation', 'do not actually copy files, only show file list') do
87
+ options[:simulation] = true
88
+ end
89
+
90
+ # restrict output for models with those tag only
91
+ options[:tag] = []
92
+ opt.on('-t', '--tag TAG,LIST', 'restrict diagram for modules with those tag only') do |list|
93
+ options[:tag] = list.split(/\s*,\s*/)
94
+ end
95
+
96
+ opt.on_tail('-h', '--help', 'Display this screen') do
97
+ puts opt
98
+ exit
99
+ end
100
+ end
101
+
102
+ optparse.parse!(ARGV)
103
+ command = ARGV[0]
104
+ options[:component] = ARGV[1]
105
+
106
+ unless command
107
+ # puts "Use 'checkout' as default command"
108
+ command = 'checkout'
109
+ end
110
+
111
+ # if the user used a short version of command
112
+ command = cmd_alias[command.to_sym] if cmd_alias[command.to_sym]
113
+
114
+ if command == 'build'
115
+ options[:build] = true
116
+ command = 'checkout'
117
+ end
118
+
119
+ case command
120
+ when 'create'
121
+ Cbt::Creator.new(options).process!
122
+ when 'checkout'
123
+ Cbt::Checkout.new(options).process!
124
+ when 'cleanup'
125
+ Cbt::Cleanup.new(options).process!
126
+ when 'diagram'
127
+ Cbt::Diagram.new(options).process!
128
+ else
129
+ raise "use one of the commands: create/checkout/build/cleanup/diagram"
130
+ end
data/cbt.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
+ require 'cbt/version'
3
+
4
+ Gem::Specification.new 'cbt', Cbt::VERSION do |s|
5
+ s.description = "Cbt is a bundle of tools for build and test corona based applications."
6
+ s.summary = "Cbt is a bundle of tools for build and test corona based applications."
7
+ s.executables << "cbt"
8
+ s.authors = ["Huang Wei"]
9
+ s.email = "huangw@pe-po.com"
10
+ s.homepage = "https://github.com/huangw/cbt-gem"
11
+ s.files = `git ls-files`.split("\n") - %w[.gitignore]
12
+ s.test_files = Dir.glob("{spec,test}/**/*.rb")
13
+ s.rdoc_options = %w[--line-numbers --inline-source --title Cbt --main README.rdoc --encoding=UTF-8]
14
+
15
+ s.add_development_dependency 'rspec', '~> 2.5'
16
+ s.add_dependency 'erubis'
17
+ s.add_dependency 'rviz'
18
+ end
19
+
@@ -0,0 +1,20 @@
1
+ components:
2
+ utils:
3
+ lua_modules: [util,timer]
4
+ tag: utils
5
+ LiveObject:
6
+ tag: ui.base
7
+ Panel:
8
+ lua_modules: [Panel<LiveObject]
9
+ tag: ui.full
10
+ dulcinea:
11
+ lua_modules: [main]
12
+ tag: utils
13
+
14
+ tags:
15
+ _default: {shape: record, style: filled, fillcolor: beige}
16
+ utils: {fillcolor: bisque3}
17
+ ui: {shape: Mrecord}
18
+ ui.base: {fillcolor: bisque3}
19
+ ui.full: {fillcolor: cornflowerblue}
20
+
@@ -0,0 +1,16 @@
1
+ members:
2
+ huangw: ['黄巍', 'huangw@pe-po.com']
3
+ xuyc: ['徐以臣', 'xuyc@pe-po.com']
4
+ sunyr: ['孙云蕊', 'sunyr@pe-po.com']
5
+ lizh: ['李中华', 'lizh@pe-po.com']
6
+ songcy: ['宋春月', 'songcy@pe-po.com']
7
+ du: ['杜丽玲', 'du@pe-po.com']
8
+ zhaogl: ['赵桂兰', 'zhaogl@pe-po.com']
9
+ wangh: ['王浩', 'wangh@pe-po.com']
10
+ liudx: ['刘东旭', 'liudx@pe-po.com']
11
+ zhangy: ['张祎', 'zhangy@pe-po.com']
12
+ wangqh: ['王清华', 'wangqh@pe-po.com']
13
+ cuibg: ['崔保国', 'cuibg@pe-po.com']
14
+ lixf: ['李现凤', 'lixf@pe-po.com']
15
+ zhaoxx: ['赵秀秀', 'zhaoxx@pe-po.com']
16
+