ki-repo 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YmQ2ZWU2NzU1OGRiMzZjMjJmZWY4Zjg4YTAzY2NhM2ZmOTAwZTU5YQ==
5
+ data.tar.gz: !binary |-
6
+ ZDUxMjViYmY2ZTU3ZTg0NGQ2MzViNjUwZDVkMzU3MmY2N2FjNWZiYw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YTRjZTJlN2YwNWY3NTA0NTVjYTU5N2IxZDFjZTAzZjVhNjJjMzE0MjI4MDcz
10
+ NjM1NjU1YzhhN2Q2ZTc4YjU3OGEyY2Q1Mzk0ODBmOTlkZTM5ZWY4NmZhZjlh
11
+ YjBmZWI1ZjRlYjgyMjE0NDFhZTM2YjEzNmU0MGQ4NDQ2MzYyNjc=
12
+ data.tar.gz: !binary |-
13
+ NWIwM2NmOTU4YmZlMjZiODg2NmYzZDFjYzgwMjE4MTRkZDkzMTk5YzIyY2Vj
14
+ MWFjYjcyMGJiMmNkZGMwNjRkYzE2ZDY3OTVmZjRmNWI2ZTQ5Mjk0M2Q3NmQw
15
+ OGNmYzdhMmZhOGYzNjc2M2Q3MzFmYTU3Y2EzYTQ2YTNiNWMxMjI=
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2012 Mikko Apo
1
+ Copyright 2012-2013 Mikko Apo
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -8,6 +8,7 @@ note: Currently Ki is not ready for any kind of use.
8
8
 
9
9
  * Rubygem: https://rubygems.org/gems/ki-repo
10
10
  * Documentation for latest released version is available at http://rubydoc.info/gems/ki-repo
11
+ * See also ki-flow, the advanced CI system: http://ki-flow.org and https://github.com/mikko-apo/ki-flow
11
12
 
12
13
  # Documentation
13
14
 
@@ -26,6 +27,26 @@ note: Currently Ki is not ready for any kind of use.
26
27
  Once these features are implemented Ki is ready for use on local server. In the future, the goal is to provide tools
27
28
  to manage distributed repositories: downloads and replication.
28
29
 
30
+ # Tech stack
31
+
32
+ * http://www.ruby-lang.org/en/
33
+
34
+ ## Testing and documentation
35
+
36
+ * http://rspec.info/ - Test framework
37
+ * http://gofreerange.com/mocha - Ruby test mocking
38
+ * https://github.com/colszowka/simplecov - Test coverage
39
+ * http://yardoc.org/ - Yard documentation
40
+ * https://github.com/rtomayko/rdiscount - Markdown
41
+
42
+ ## Web
43
+
44
+ * http://rack.github.com/ - Ruby web server support
45
+ * http://www.sinatrarb.com/ - Simple web application framework
46
+ * http://coffeescript.org/
47
+ * http://sass-lang.com/
48
+ * http://code.google.com/p/selenium/wiki/RubyBindings - Selenium WebDriver
49
+
29
50
  # Copyright
30
51
 
31
52
  Copyright (c) 2012 Mikko Apo. See {file:LICENSE.txt} for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/bin/ki CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
- # Copyright 2012 Mikko Apo
4
+ # Copyright 2012-2013 Mikko Apo
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
data/docs/backlog.md CHANGED
@@ -1,29 +1,29 @@
1
- # @title Ki: Backlog
1
+ # @title ki-repo: Backlog
2
2
 
3
- # Backlog for 0.2
3
+ # Next release
4
+ * if there is a file ki-version.json under ki-repo directory, many tests fail
5
+ * /web/ is not registered correctly
4
6
  * fix defined? checks
5
- * fix double repository entries in finder.all_repositories "should show imported version"
6
- * cleanup gem
7
- * create release notes
8
-
9
- # 0.3
10
- * cleanup and removal operations
11
7
  * version() returns sometime nil, sometimes Version
12
8
  * version!()
13
9
  * fix Version.exists? - there should be a better way to check if version exists
14
10
  * VersionTester should support test_version(metadata, source)
15
11
  * Download & replication
16
- * website command
17
12
  * daemon: long running processes, web site monitoring
18
13
  * multiple local repositories: command line tools and helpers
19
- * support for separate binaries directory
20
14
  * pref: define repository lookup order
15
+ * support for separate binaries directory
16
+ * cleanup and removal operations
17
+ * create release notes
18
+ * web cmd store handler to prefs
19
+ * version-build can use .ki.yml to build version
21
20
 
22
21
  # Future releases
23
22
  * Digital signing
24
23
  * Encrypted/packed packages
25
24
  * Support for using files from other repositories
26
25
  * when building version create file operations based on user's changes
26
+ * version retention strategy visible from source
27
27
 
28
28
  # Maybe at some point...
29
29
  * replace popen4.spawn with Kernel.spawn
data/docs/development.md CHANGED
@@ -16,12 +16,13 @@ Follow the instructions here: {file:docs/development_setup.md}
16
16
  * {Ki::KiCommandHelp}, {Ki::KiInfoCommand} - help, ki-info
17
17
  * {Ki::UserPrefCommand} - Stored preferences
18
18
  * {Ki::BuildVersionMetadataFile}, {Ki::TestVersion}, {Ki::ImportVersion}, {Ki::ExportVersion}, {Ki::VersionStatus}, {Ki::ShowVersion}, {Ki::VersionSearch} - repository management
19
+ * {Ki::RackCommand} - Starts up web application
19
20
 
20
21
  ## Data storage - files and directories
21
22
 
22
23
  * {Ki::KiHome}, {Ki::Repository::Repository}, {Ki::Repository::Component}, {Ki::Repository::Version} - Repository directory objects
23
24
  * {Ki::VersionMetadataFile}, {Ki::Dependency}, {Ki::VersionStatusFile} - Version metadata and statuses
24
- * {Ki::DirectoryBaseModule}, {Ki::DirectoryBase} - Base classes for file and directory management
25
+ * {Ki::DirectoryBase} - Base class for file and directory management
25
26
  * {Ki::KiJSONFile}, {Ki::KiJSONListFile}, {Ki::KiJSONHashFile}, {Ki::KiJSONHashFile::CachedMapDataAccessor} - Base classes for JSON files
26
27
  * {Ki::DirectoryWithChildrenInListFile} - Helper to generate list file class and related methods for a repository object
27
28
  * {Ki::RepositoryMethods}, {Ki::RepositoryMethods::RepositoryListFile} - Repository helper methods
@@ -43,3 +44,4 @@ Follow the instructions here: {file:docs/development_setup.md}
43
44
  * {ExceptionCatcher} - Execute multiple blocks and process exceptions in the end
44
45
  * {Ki::ServiceRegistry} - Class for storing all Ki extensions
45
46
  * {Ki::SimpleOptionParser} - Simplified OptionParser
47
+ * {Ki::HashLog} - Hash based logging
data/docs/ki_commands.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @title Ki: Command line utilities
2
- # Command line utilities for Ki Repository v0.1.0
2
+ # Command line utilities for Ki Repository v0.1.1
3
3
  "ki" is the main command line tool that starts all other Ki processes. Whenever ki command line tools
4
4
  are executed, ki goes through the following startup process
5
5
 
@@ -14,12 +14,13 @@ Examples
14
14
  ki -u my/tools compile
15
15
  ki -u my/tools:scripts,tools compile
16
16
 
17
- note: By default only files with tag "ki-cmd" are used. Use the 'my/tools:scripts,tools' to define additional tags.
17
+ note: By default only files with tag "ki" are used. Use the 'my/tools:scripts,tools' to define additional tags.
18
18
 
19
19
  Common parameters:
20
20
 
21
21
  -h, --home Path to Ki root directory
22
22
  -u, --use Use defined scripts
23
+ --require Require Ruby files, comma separated list
23
24
 
24
25
  ## help: Displays help for given Ki command
25
26
 
@@ -30,7 +31,6 @@ Common parameters:
30
31
  ki help
31
32
  ki help version-build
32
33
 
33
-
34
34
  ## ki-info: Show information about Ki
35
35
 
36
36
  "ki ki-info" shows information about Ki.
@@ -162,6 +162,14 @@ Status value order is used to determine which statuses match version queries:
162
162
  ki version-show -r -d my/component/23 my/product/127
163
163
  ki version-show -f ki-version.json -i binary-dir
164
164
 
165
+ ### Parameters
166
+
167
+ -r, --recursive Shows version's dependencies.
168
+ -d, --dirs Shows version's directories.
169
+ -f, --file FILE Version source file. By default uses file's directory as source for binary files.
170
+ -i, --input-directory INPUT-DIR Binary file input directory
171
+
172
+
165
173
  ## version-search: Searches for versions and components
166
174
 
167
175
  "ki version-search" searches for versions and components.
@@ -188,11 +196,11 @@ Syntax: ki pref prefix|use parameters...
188
196
  ki pref prefix -c
189
197
  - clears command prefix list
190
198
 
191
- ### Examples for automatic script loading:
199
+ ### Examples for default script loading:
192
200
  ki pref use
193
- - shows list of automatically loading scripts. when ki starts up, it looks for all defined versions and loads all files tagged with ki-cmd
201
+ - shows list of automatically loading scripts. when ki starts up, it looks for all defined versions and loads all files tagged with "ki"
194
202
  ki pref use ki/http ki/ftp/123:ki-extra
195
- - scripts are loaded from two different version. ki/http uses latest available version and files tagged with "ki-cmd", ki/ftp uses specific version and files tagged with "ki-extra"
203
+ - scripts are loaded from two different version. ki/http uses latest available version and files tagged with "ki", ki/ftp uses specific version and files tagged with "ki-extra"
196
204
  ki pref use + ki/scp
197
205
  - adds one more script package version
198
206
  ki pref use - ki/scp ki/ftp/123:ki-extra
@@ -200,3 +208,24 @@ Syntax: ki pref prefix|use parameters...
200
208
  ki pref use -c
201
209
  - clear use list
202
210
 
211
+ ### Examples for default Ruby file requiring:
212
+ ki pref require
213
+ ki pref require hooves/default
214
+ ki pref require + hooves/default
215
+ ki pref require - hooves/default
216
+ ki pref require -c
217
+
218
+ ## web: Starts Ki web server and uses code from Ki packages
219
+
220
+ ki-repo has a built in web server.
221
+
222
+ ### Usage
223
+
224
+ ki web - Starts Ki web server
225
+
226
+ ### Parameters
227
+
228
+ --handler HANDLER Use specified Rack Handler
229
+ --development Development mode, resource urls are reloaded
230
+ -p, --port PORT Use specified port
231
+
@@ -41,7 +41,7 @@ Ki-Repo is a repository for storing file packages and metadata about those packa
41
41
  An example repository has following structure:
42
42
 
43
43
  * Repository has three components: `"my/componentA"`, `"my/componentB"`, `"my/product"`.
44
- * Each component maintains a chronological list of versions. For example, `"my/component"` has versions `"3"`, `"2"` and `"1"`.
44
+ * Each component maintains a chronological list of versions. For example, `"my/component"` has versions `"23"`, `"22"` and `"21"`.
45
45
  * Component's name should be a unique identifier and it can include any number of identifiers. Valid component names include `"ki/repo"`, `"ki-repo"` or `"my/test/builds/ki/repo/"`.
46
46
  * Version contains a set of files. Version can also define dependencies and other metadata.
47
47
 
@@ -144,6 +144,15 @@ File operations are defined for "version-build" with -o and -O parameters
144
144
  ki version-build -d my/tests/a/123,name=tests -o "rm *.txt"
145
145
  ki version-build -O "cp scripts/start.sh start.sh"
146
146
 
147
+ ### Status information
148
+
149
+ Each version can have status values. Status values can be used to tag certain kind of versions (released),
150
+ or find latest version that has a specific status value:
151
+
152
+ my/component:released
153
+ my/component:IntegrationTest=green
154
+
155
+
147
156
  ## Component
148
157
 
149
158
  Component has only a two responsibilities:
@@ -155,6 +164,8 @@ Status value order is used to determine which statuses match version queries:
155
164
 
156
165
  my/component:maturity>alpha
157
166
 
167
+ "maturity" order could be "alpha,beta,gamma" and latest version that has either beta or gamma would get chosen.
168
+
158
169
  ## Repository
159
170
 
160
171
  Repository directory keeps a list of all components that have data in the repository.
@@ -20,31 +20,49 @@ Examples
20
20
  ki -u my/tools compile
21
21
  ki -u my/tools:scripts,tools compile
22
22
 
23
- note: By default only files with tag "ki-cmd" are used. Use the 'my/tools:scripts,tools' to define additional tags.
23
+ note: By default only files with tag "ki" are used. Use the 'my/tools:scripts,tools' to define additional tags.
24
24
 
25
25
  Ki's extension mechanism makes it easy to manage different scenarios:
26
26
  * write and distribute command line utilities
27
27
  * use different versions of those utilities at the same time on the same machine (backwards compatability)
28
28
  * add new features to existing utilities: hashing algorithms, integrations to different tools like git, mercurial and svn
29
29
 
30
- # Command line utility
30
+ # Extension points
31
+
32
+ {Ki::KiCommand} stores all registered extensions to its class variable {Ki::KiCommand::KiExtensions} ({Ki::ServiceRegistry}).
33
+
34
+ Currently used extension points are:
35
+
36
+ * /commands/
37
+ * /hashing/
38
+ * /web/
39
+
40
+ ## Command line utility - /commands/
31
41
 
32
42
  Command classes are registered with KiCommand.register_cmd
33
43
 
34
44
  KiCommand.register_cmd("version-build", BuildVersionMetadataFile)
35
45
 
36
46
  They should implement following methods:
47
+
37
48
  * execute(ctx, args)
38
49
  * help, summary
39
50
  * attr_chain :shell_command, :require is optional but help method can use it to generate more useful help texts
40
51
 
41
52
  For more information, see {Ki::ImportVersion}
42
53
 
43
- # Extension points
54
+ ## Cryptographic hash functions - /hashing/
44
55
 
45
- {Ki::KiCommand} stores all registered extensions to its class variable {Ki::KiCommand::KiExtensions} ({Ki::ServiceRegistry}).
56
+ Classes used for hashing must implement class method digest which returns a class extending Digest::Class
46
57
 
47
- Currently used extension points are:
58
+ For more information, see {Ki::SHA2} and {Digest::SHA2}
48
59
 
49
- * /commands/
50
- * /hashing/
60
+ ## Web classes - /web/
61
+
62
+ Ki-repo includes support for running web applications. Web applications are created by creating Rack application classes
63
+ and tagging each file containing classes with "ki". That way "ki" command loads files and {Ki::RackCommand} starts
64
+ web application from classes that were loaded. Each class is registered to the path remaining from registration key:
65
+
66
+ KiCommand.register("/web/test", MyApp2)
67
+
68
+ For more information, see {Ki::RackCommand}
data/lib/cmd/cmd.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- # Copyright 2012 Mikko Apo
3
+ # Copyright 2012-2013 Mikko Apo
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -39,12 +39,52 @@ module Ki
39
39
  KiExtensions.register(name, clazz)
40
40
  end
41
41
 
42
+ # bin/ki command line tool calls this method, which finds the correct class to manage the execution
43
+ def execute(args)
44
+ @use = []
45
+ @require = []
46
+ @load = []
47
+ my_args = opts.parse(args.dup)
48
+ require_files
49
+ load_scripts
50
+ if my_args.empty?
51
+ KiCommandHelp.new.shell_command("#{0} help").execute(self, [])
52
+ else
53
+ find_cmd(my_args.delete_at(0)).execute(self, my_args)
54
+ end
55
+ end
56
+
57
+ def opts
58
+ SimpleOptionParser.new do |opts|
59
+ opts.on("-h", "--home HOME-PATH", "Path to Ki root directory") do |v|
60
+ ki_home(KiHome.new(v))
61
+ end
62
+ opts.on("-u", "--use VER", "Use defined scripts") do |v|
63
+ @use << v.split(",")
64
+ end
65
+ opts.on("--require RUBYFILE", "Require Ruby files, comma separated list") do |v|
66
+ @require << v.split(",")
67
+ end
68
+ end
69
+ end
70
+
71
+ def require_files
72
+ @require.flatten!
73
+ requires = @require.empty? ? user_pref.requires : @require
74
+ requires.each do |req|
75
+ Dir.glob(req).each do |path|
76
+ require path
77
+ end
78
+ end
79
+ end
80
+
42
81
  def load_scripts
43
82
  # load all script files defined in UserPrefFile uses
83
+ @use.flatten!
44
84
  uses = @use.empty? ? user_pref.uses : @use
45
85
  uses.each do |use_str|
46
86
  ver, tags_str = use_str.split(":")
47
- tags = tags_str ? tags_str.split(",") : "ki-cmd"
87
+ tags = tags_str ? tags_str.split(",") : "ki"
48
88
  version = ki_home.version(ver)
49
89
  version.find_files.tags(tags).file_list.each do |full_path|
50
90
  load full_path
@@ -79,30 +119,6 @@ module Ki
79
119
  cmd
80
120
  end
81
121
 
82
- # bin/kaiju command line tool calls this method, which finds the correct class to manage the execution
83
- def execute(args)
84
- @use = []
85
- my_args = opts.parse(args.dup)
86
- load_scripts
87
- if my_args.empty?
88
- KiCommandHelp.new.shell_command("#{0} help").execute(self, [])
89
- else
90
- find_cmd(my_args.delete_at(0)).execute(self, my_args)
91
- end
92
- end
93
-
94
- def opts
95
- o = SimpleOptionParser.new do |opts|
96
- opts.on("-h", "--home HOME-PATH", "Path to Ki root directory") do |v|
97
- ki_home(KiHome.new(v))
98
- end
99
- opts.on("-u", "--use VER", "Use defined scripts") do |v|
100
- @use << v
101
- end
102
- end
103
- o
104
- end
105
-
106
122
  def help
107
123
  <<EOF
108
124
  "ki" is the main command line tool that starts all other Ki processes. Whenever ki command line tools
@@ -119,7 +135,7 @@ Examples
119
135
  ki -u my/tools compile
120
136
  ki -u my/tools:scripts,tools compile
121
137
 
122
- note: By default only files with tag "ki-cmd" are used. Use the 'my/tools:scripts,tools' to define additional tags.
138
+ note: By default only files with tag "ki" are used. Use the 'my/tools:scripts,tools' to define additional tags.
123
139
 
124
140
  Common parameters:
125
141
 
@@ -134,17 +150,6 @@ EOF
134
150
  attr_chain :summary, -> { "Displays help for given Ki command" }
135
151
  attr_chain :shell_command, :require
136
152
 
137
- def help
138
- <<EOF
139
- "#{shell_command}" shows information Ki and its commands.
140
-
141
- ### Examples
142
-
143
- #{shell_command}
144
- #{shell_command} version-build
145
- EOF
146
- end
147
-
148
153
  # Finds matching command and displays its help
149
154
  def execute(ctx, args)
150
155
  if args.size == 1
@@ -169,6 +174,17 @@ EOF
169
174
  puts "\nRun '#{$0} help COMMAND' for more information about that command."
170
175
  end
171
176
  end
177
+
178
+ def help
179
+ <<EOF
180
+ "#{shell_command}" shows information Ki and its commands.
181
+
182
+ ### Examples
183
+
184
+ #{shell_command}
185
+ #{shell_command} version-build
186
+ EOF
187
+ end
172
188
  end
173
189
 
174
190
  # Lists available Ki commands
@@ -182,22 +198,8 @@ EOF
182
198
  opts.parse(args.empty? ? ["-c"] : args)
183
199
  end
184
200
 
185
- def help
186
- <<EOF
187
- "#{shell_command}" shows information about Ki.
188
-
189
- ### Examples
190
-
191
- #{shell_command} -c
192
- #{shell_command} -r
193
-
194
- ### Parameters
195
- #{opts}
196
- EOF
197
- end
198
-
199
201
  def opts
200
- o = SimpleOptionParser.new do |opts|
202
+ SimpleOptionParser.new do |opts|
201
203
  opts.on("-c", "--commands", "List commands") do |v|
202
204
  commands = KiCommand::KiExtensions.find(KiCommand::CommandPrefix[0..-2])
203
205
  commands.each do |id, service_class|
@@ -214,7 +216,20 @@ EOF
214
216
  end
215
217
  end
216
218
  end
217
- o
219
+ end
220
+
221
+ def help
222
+ <<EOF
223
+ "#{shell_command}" shows information about Ki.
224
+
225
+ ### Examples
226
+
227
+ #{shell_command} -c
228
+ #{shell_command} -r
229
+
230
+ ### Parameters
231
+ #{opts}
232
+ EOF
218
233
  end
219
234
  end
220
235