falsework 2.1.1 → 3.0.0

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.
Files changed (72) hide show
  1. data/README.rdoc +19 -59
  2. data/Rakefile +28 -20
  3. data/bin/falsework +266 -73
  4. data/doc/NEWS.rdoc +24 -0
  5. data/doc/README.rdoc +19 -59
  6. data/doc/TODO.org +16 -6
  7. data/doc/template-tutorial.rdoc +49 -12
  8. data/dynamic.yaml +4 -0
  9. data/falsework.gemspec +10 -1
  10. data/lib/falsework/cliconfig.rb +14 -9
  11. data/lib/falsework/cliutils.rb +0 -2
  12. data/lib/falsework/meta.rb +2 -1
  13. data/lib/falsework/mould.rb +121 -192
  14. data/lib/falsework/upgrader.rb +120 -0
  15. data/lib/falsework/utils.rb +23 -0
  16. data/templates/c-glib/#config.yaml +18 -0
  17. data/{lib/falsework/templates → templates}/c-glib/README +0 -0
  18. data/{lib/falsework/templates → templates}/c-glib/doc/#doc.ascii +0 -0
  19. data/{lib/falsework/templates → templates}/c-glib/doc/%%@project%%.1.asciidoc +0 -0
  20. data/{lib/falsework/templates → templates}/c-glib/doc/LICENSE +0 -0
  21. data/{lib/falsework/templates → templates}/c-glib/doc/Makefile +0 -0
  22. data/{lib/falsework/templates → templates}/c-glib/src/#exe.c +0 -0
  23. data/{lib/falsework/templates → templates}/c-glib/src/#exe.h +0 -0
  24. data/{lib/falsework/templates → templates}/c-glib/src/%%@project%%.c +0 -0
  25. data/{lib/falsework/templates → templates}/c-glib/src/%%@project%%.h +0 -0
  26. data/{lib/falsework/templates → templates}/c-glib/src/Makefile +0 -0
  27. data/{lib/falsework/templates → templates}/c-glib/src/untest.c +0 -0
  28. data/{lib/falsework/templates → templates}/c-glib/src/untest.h +0 -0
  29. data/{lib/falsework/templates → templates}/c-glib/src/utils.c +0 -0
  30. data/{lib/falsework/templates → templates}/c-glib/src/utils.h +0 -0
  31. data/{lib/falsework/templates → templates}/c-glib/test/#test.c +0 -0
  32. data/{lib/falsework/templates → templates}/c-glib/test/Makefile +0 -0
  33. data/{lib/falsework/templates → templates}/c-glib/test/Makefile.test.mk +0 -0
  34. data/{lib/falsework/templates → templates}/c-glib/test/mycat.c +0 -0
  35. data/{lib/falsework/templates → templates}/c-glib/test/semis/text/empty.txt +0 -0
  36. data/{lib/falsework/templates → templates}/c-glib/test/test_utils.c +0 -0
  37. data/templates/ruby-cli/#config.yaml +26 -0
  38. data/{lib/falsework/templates → templates}/ruby-cli/%%@project%%.gemspec +0 -0
  39. data/{lib/falsework/templates → templates}/ruby-cli/.gitignore +0 -0
  40. data/{lib/falsework/templates → templates}/ruby-cli/.gitignore.#erb +0 -0
  41. data/{lib/falsework/templates → templates}/ruby-cli/Gemfile +0 -0
  42. data/{lib/falsework/templates → templates}/ruby-cli/README.rdoc +17 -19
  43. data/{lib/falsework/templates → templates}/ruby-cli/Rakefile +0 -0
  44. data/{lib/falsework/templates → templates}/ruby-cli/bin/%%@project%% +3 -3
  45. data/{lib/falsework/templates → templates}/ruby-cli/doc/#doc.rdoc +16 -18
  46. data/{lib/falsework/templates → templates}/ruby-cli/doc/LICENSE +0 -0
  47. data/{lib/falsework/templates → templates}/ruby-cli/doc/NEWS.rdoc +0 -0
  48. data/{lib/falsework/templates → templates}/ruby-cli/doc/README.rdoc +17 -19
  49. data/templates/ruby-cli/etc/%%@project%%.yaml +2 -0
  50. data/{lib/falsework/templates → templates}/ruby-cli/lib/%%@project%%/cliconfig.rb +14 -11
  51. data/{lib/falsework/templates → templates}/ruby-cli/lib/%%@project%%/cliutils.rb +0 -4
  52. data/{lib/falsework/templates → templates}/ruby-cli/lib/%%@project%%/meta.rb +1 -0
  53. data/{lib/falsework/templates → templates}/ruby-cli/test/helper.rb +0 -0
  54. data/{lib/falsework/templates → templates}/ruby-cli/test/helper_cliutils.rb +0 -3
  55. data/{lib/falsework/templates → templates}/ruby-cli/test/test_%%@project%%.rb +0 -0
  56. data/test/example/note/full +10 -0
  57. data/test/example/note/project-too-old +8 -0
  58. data/test/example/note/template-unknown +8 -0
  59. data/test/helper.rb +11 -0
  60. data/test/helper_cliutils.rb +0 -1
  61. data/test/templates/config-01.yaml +1 -1
  62. data/test/{test_exe.rb → test_cli.rb} +52 -29
  63. data/test/test_mould.rb +41 -16
  64. data/test/test_upgrader.rb +96 -0
  65. metadata +76 -50
  66. data/dynamic.ruby-cli +0 -3
  67. data/lib/falsework/templates/c-glib/#config.yaml +0 -18
  68. data/lib/falsework/templates/ruby-cli/#config.yaml +0 -15
  69. data/lib/falsework/templates/ruby-cli/etc/%%@project%%.yaml +0 -2
  70. data/test/rake_erb_templates.rb +0 -60
  71. data/test/templates/config-02.yaml +0 -2
  72. data/test/test_cl.rb +0 -33
data/doc/README.rdoc CHANGED
@@ -17,21 +17,23 @@ Initially the template spec was designed only for Ruby projects but
17
17
  later (from version 1.3.0) hard-coded Ruby staff was removed which added
18
18
  more flexibility.
19
19
 
20
- The generated project <b>is not dependent</b> on falsework. The utility
21
- can also add skeletons for tests end executables <i>after</i> the
20
+ Generated projects <b>are not dependent</b> on falsework. The utility
21
+ can also add skeletons for tests end executables <b>after</b> the
22
22
  project generation.
23
23
 
24
24
 
25
25
  ==Ruby Template
26
26
 
27
- ... is default. It generates a scaffold which have:
27
+ ... is default. It generates a scaffold which has:
28
28
 
29
29
  * auto-created git (but not github) project;
30
30
 
31
- * <tt>gem</tt> (a file list is pulled from the git repository, <b>no more
32
- missing files in gems!</b>), <tt>doc</tt>, <tt>test</tt> targets;
31
+ * <tt>gemspec</tt> (a file list is pulled from the git repository),
32
+ <tt>doc</tt>, <tt>test</tt> targets; +build+, +install+ & +release+
33
+ bundler targets.
33
34
 
34
- * easy to use configuration parser/loader. This includes scanning for:
35
+ * easy to use configuration parser/loader. This includes auto-scanning
36
+ for:
35
37
 
36
38
  * env variable(s);
37
39
  * the flat YAML configuration file;
@@ -45,83 +47,41 @@ Version & name of your project can be located at generated
45
47
 
46
48
  ==Options
47
49
 
48
- The commands:
50
+ Run
49
51
 
50
- list:: Do nothing except listing all available
51
- templates. You can add your own templates in
52
- <tt>~/.falsework/templates</tt> directory.
52
+ $ falsework -h
53
53
 
54
- listdirs:: Do nothing except listing all available
55
- templates directories. You can add another
56
- directory by modifying <tt>tdir</tt> option
57
- in the config file. (<tt>tdir</tt> is an
58
- array).
59
-
60
- new NAME:: Create a new project. It creates a directory
61
- <i>NAME</i> and populates it with files.
54
+ to read all possible commands & global options. All of them, except
55
+ +new+ & +list+, work from the root project directory.
62
56
 
63
- The following commands works only from the root project directory:
57
+ Some of the commands support <tt>-h</tt> option too, for example:
64
58
 
65
- exe NAME:: Add a new executable to an existing
66
- project and a corresponding doc in
67
- <tt>doc</tt> sub-directory.
68
-
69
- doc NAME:: Add a new doc file in
70
- <tt>doc</tt> sub-directory.
71
-
72
- test NAME:: Add a new test in
73
- <tt>test</tt> sub-directory.
74
-
75
- upgrade:: 'Inject' or upgrade some vital files from the
76
- template into the project. Currently only
77
- 'ruby-cli' template supports this.
78
-
79
- The options are as follows:
80
-
81
- -t:: A template name.
82
-
83
- -b:: A batch mode. (No questions asked.)
84
-
85
- --no-git:: Don't create a Git repository. Don't use
86
- this for 'ruby-cli' template.
87
-
88
- --config-dirs:: List all possible locations for the
89
- configuration file. The first found wins.
90
-
91
- --config NAME:: The name of the configuration file. If
92
- it contains <tt>/</tt> in it, the list from
93
- <tt>--config-dirs</tt> is ignored.
94
-
95
- -V:: Show falsework version and exit.
96
-
97
- -v:: Be more verbose. You can supply it several
98
- times, viz. <tt>-vv</tt> dumps even more
99
- debug info.
59
+ $ falsework upgrade -h
100
60
 
101
61
 
102
62
  ==Examples
103
63
 
104
64
  Create a new project:
105
65
 
106
- % falsework -v new foobar
66
+ $ falsework -v new foobar
107
67
 
108
68
  Add another CL util to the existing project:
109
69
 
110
- % pwd
70
+ $ pwd
111
71
  .../foobar
112
- % falsework exe foo
72
+ $ falsework exe foo
113
73
 
114
74
  (It will appear in <tt>bin/</tt> sub-directory.)
115
75
 
116
76
  Add another test file:
117
77
 
118
- % falsework test foo
78
+ $ falsework test foo
119
79
 
120
80
  (It will appear in <tt>test/</tt> sub-directory.)
121
81
 
122
82
  Create a project from another template:
123
83
 
124
- % falsework -t c-glib -v new foo-bar
84
+ $ falsework -t c-glib -v new foo-bar
125
85
 
126
86
 
127
87
  ==Bugs
data/doc/TODO.org CHANGED
@@ -1,14 +1,24 @@
1
- * TODO In the distant future [3/7] [42%]
1
+ * TODO In the distant future [9/12] [75%]
2
2
 
3
- - [-] more templates [1/4]
3
+ - [-] more templates [1/3]
4
4
  - [X] c glib
5
- - [ ] java android
6
5
  - [ ] ruby sinatra
7
- - [ ] ruby cli but a lighter one
6
+ - [ ] ruby cli, but a lighter one
8
7
  - [X] write a small tutorial 'how to write a template'
9
- - [ ] release to rubygems.org (it must run test, pull to github, tag,
8
+ - [X] release to rubygems.org (it must run test, pull to github, tag,
10
9
  create gem & upload it)
11
10
  - [ ] describe c-glib template
12
11
  - [X] normalize 'name' of the project before actually making a template
13
12
  - [X] target_uuid variable for exe/doc/test templates
14
- - [ ] relocate templates from lib/falsework directory to project root
13
+ - [X] relocate templates from lib/falsework directory to project root
14
+ - [X] project creation
15
+ - [X] embed a note--'.falsework' file into a new generated project
16
+ - [X] options to do not embed a note file
17
+ - [X] new upgrade command
18
+ - [X] check if current project can be upgraded
19
+ - [X] list upgradeable files
20
+ - [X] list obsolete files
21
+ - [X] upgrade in overwrite mode
22
+ - [X] check in 'falsework' executable for exceptions in mould.rb
23
+ - [ ] move project creation factory to utils.rb
24
+ - [X] make dynamic.ruby-cli a static file
@@ -15,6 +15,11 @@ Your personal templates must be in <tt>~/.falsework/templates</tt>
15
15
  directory. To view all currently available templates, run <tt>falsework
16
16
  list</tt>.
17
17
 
18
+ To add another directory to a search list (visible via <tt>falsework
19
+ list dirs</tt>), modify value of +tdir+ key in
20
+ <tt>~/.falsework/falsework.yaml</tt>. The value must be an array of
21
+ readable directories.
22
+
18
23
 
19
24
  == Hierarchy
20
25
 
@@ -85,20 +90,20 @@ set it permission afterwards.
85
90
  The default configuration is:
86
91
 
87
92
  ---
88
- :exe:
89
- - :src: null
90
- :dest: bin/%s'
91
- :mode_int: 0744
93
+ exe:
94
+ - src: null
95
+ dest: bin/%s'
96
+ mode_int: 0744
92
97
 
93
- :doc:
94
- - :src: null
95
- :dest: 'doc/%s.rdoc'
96
- :mode_int: null
98
+ doc:
99
+ - src: null
100
+ dest: 'doc/%s.rdoc'
101
+ mode_int: null
97
102
 
98
- :test:
99
- - :src: null
100
- :dest: 'test/test_%s.rb'
101
- :mode_int: null
103
+ test:
104
+ - src: null
105
+ dest: 'test/test_%s.rb'
106
+ mode_int: null
102
107
 
103
108
  The value of each top level key is an array, so you can inject several
104
109
  files at once.
@@ -111,3 +116,35 @@ dest:: Sub-key can have <tt>%s</tt> in it which will be replaced with
111
116
  target value ('foobar' in the example above).
112
117
 
113
118
  mode_int:: Permission bits.
119
+
120
+ Top level keys must be one of: +exe+, +doc+, +test+ or +file+ string
121
+ values. Each of these strings correspond to a hard-coded command in
122
+ +falsework+ executable.
123
+
124
+
125
+ == Upgrade command
126
+
127
+ Any template may have instructions for updating files in old
128
+ projects. To make your template 'upgradable', add to
129
+ <tt>#config.yaml</tt>:
130
+
131
+ version: 2.3.4
132
+ upgrade:
133
+ obsolete:
134
+ - some/file
135
+ files:
136
+ - foo
137
+ - bar/baz
138
+ from: 1.2.3
139
+
140
+ where
141
+
142
+ version:: Sets a current version of the template. Required.
143
+
144
+ obsolete:: Means a list of files that user may delete. Optional.
145
+
146
+ files:: A list of 'upgradable' files. It must be relative to the
147
+ template directory. Required.
148
+
149
+ from:: A minimal template version number from which it is possible to
150
+ perform an upgrade. Required.
data/dynamic.yaml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ templates/ruby-cli/lib/%%@project%%/cliconfig.rb: lib/falsework/cliconfig.rb
3
+ templates/ruby-cli/lib/%%@project%%/cliutils.rb: lib/falsework/cliutils.rb
4
+ templates/ruby-cli/test/helper_cliutils.rb: test/helper_cliutils.rb
data/falsework.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.homepage = Meta::HOMEPAGE
11
11
 
12
12
  gem.files = `git ls-files`.split($\)
13
- gem.files.concat File.read('dynamic.ruby-cli').split("\n")
13
+ gem.files.concat YAML.load_file('dynamic.yaml').keys
14
14
 
15
15
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
16
  gem.test_files = gem.files.grep(%r{^test/test_.+\.rb})
@@ -20,9 +20,18 @@ Gem::Specification.new do |gem|
20
20
  gem.required_ruby_version = '>= 1.9.2'
21
21
  gem.extra_rdoc_files = gem.files.grep(%r{^doc/})
22
22
  gem.rdoc_options << '-m' << 'doc/README.rdoc' << '-x' << 'lib/.+/templates/'
23
+
24
+ gem.post_install_message = <<-MESSAGE
25
+ Users of 2.x! Your custom templates must be updated--format
26
+ of #config.yaml has changed.
27
+
28
+ See also doc/NEWS.rdoc file even if you don't have custom templates.
29
+ MESSAGE
23
30
 
24
31
  gem.add_dependency "open4", "~> 1.3.0"
25
32
  gem.add_dependency "rdoc", "~> 3.12"
26
33
  gem.add_dependency "bundler", "~> 1.1.3"
27
34
  gem.add_dependency "git", "~>1.2.5"
35
+
36
+ gem.add_development_dependency "fakefs", "~> 0.4.0"
28
37
  end
@@ -1,5 +1,3 @@
1
- # :erb: ruby-cli
2
-
3
1
  require 'pathname'
4
2
  require 'yaml'
5
3
  require 'optparse'
@@ -31,6 +29,7 @@ module Falsework
31
29
  @conf[:config_name] = Meta::NAME + '.yaml'
32
30
  @conf[:config_env] = Meta::NAME.upcase + '_CONF'
33
31
  @conf[:config_dirs] = DIR_CONFIG
32
+ @conf[:cl_parse_in_order] = false
34
33
  end
35
34
 
36
35
  # Setter for @conf
@@ -55,7 +54,7 @@ module Falsework
55
54
  }
56
55
  end
57
56
 
58
- CliUtils.warnx "no config file '#{@conf[:config_name]}' found" if @conf[:verbose] >= 2
57
+ CliUtils.warnx "config file '#{@conf[:config_name]}' not found" if @conf[:verbose] >= 2
59
58
  return nil
60
59
  end
61
60
 
@@ -75,15 +74,15 @@ module Falsework
75
74
  # Check if options in array opts are in @conf.
76
75
  def requiredOptions?(opts)
77
76
  opts.each {|idx|
78
- if !@conf.key?(idx.to_sym) || !@conf[idx.to_sym]
79
- CliUtils.errx EX_CONFIG, "option #{idx} is either nil or missing"
77
+ if !@conf.key?(idx) || !@conf[idx]
78
+ CliUtils.errx EX_CONFIG, "option '#{idx}' is either nil or missing"
80
79
  end
81
80
  }
82
81
  end
83
82
 
84
83
  # Parse CLO and env variable. If block is given it is passed with
85
84
  # OptionParser object as a parameter.
86
- def optParse
85
+ def optParse argv
87
86
  OptionParser.new do |o|
88
87
  o.on('-v', 'Be more verbose.') { |i|
89
88
  self[:verbose] += 1
@@ -118,7 +117,13 @@ module Falsework
118
117
  env = ENV[@conf[:config_env]].shellsplit if ENV.key?(@conf[:config_env])
119
118
 
120
119
  begin
121
- [env, ARGV].each { |i| o.parse!(i) if i }
120
+ [env, argv].each { |i|
121
+ if @conf[:cl_parse_in_order]
122
+ o.order!(i) if i
123
+ else
124
+ o.parse!(i) if i
125
+ end
126
+ }
122
127
  rescue
123
128
  CliUtils.errx EX_USAGE, $!.to_s
124
129
  end
@@ -129,8 +134,8 @@ module Falsework
129
134
  #
130
135
  # [reqOpts] an array of requied options
131
136
  # [&block] a optional block for OptionParser
132
- def load(reqOpts = [], &block)
133
- optParse(&block)
137
+ def load(reqOpts = [], argv = ARGV, &block)
138
+ optParse(argv, &block)
134
139
  loadFile
135
140
  requiredOptions?(reqOpts)
136
141
  end
@@ -1,5 +1,3 @@
1
- # :erb: ruby-cli
2
-
3
1
  require 'pp'
4
2
  require 'open4'
5
3
  require 'pathname'
@@ -1,7 +1,8 @@
1
+ # :include: ../../README.rdoc
1
2
  module Falsework
2
3
  module Meta # :nodoc:
3
4
  NAME = 'falsework'
4
- VERSION = '2.1.1'
5
+ VERSION = '3.0.0'
5
6
  AUTHOR = 'Alexander Gromnitsky'
6
7
  EMAIL = 'alexander.gromnitsky@gmail.com'
7
8
  HOMEPAGE = 'http://github.com/gromnitsky/' + NAME