configural 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,318 @@
1
+ commit 3aedf30e220481cb015c162eacf41a56c4b9d12a
2
+ Author: John Croisant <john@croisant.net>
3
+ Date: Sun Sep 11 22:24:51 2011 -0500
4
+
5
+ Added methods: Config#[]= and Data#[]=
6
+
7
+ M lib/configural/config.rb
8
+ M lib/configural/data.rb
9
+
10
+ commit 025610e4d06cc8e5d50abaa00c8e4776a72d8ee5
11
+ Author: John Croisant <john@croisant.net>
12
+ Date: Sat Sep 10 02:11:41 2011 -0500
13
+
14
+ App can now also have non-per-user #cache/#config/#data.
15
+
16
+ These are for files that are stored within the app's directory,
17
+ such as config files and data that ship with the app.
18
+
19
+ Before you can use App#cache, #config, or #data, you must must set
20
+ #cache_path, #config_path, and/or #data_path to the directories where
21
+ each kind of file is located.
22
+
23
+ Or, you can set App#path to the app's main directory; then files
24
+ default to the 'cache', 'config', and 'data' directories within that
25
+ main directory. If a specific path (e.g. #cache_path) is set, that
26
+ path takes precedence over the default path.
27
+
28
+ M lib/configural/app.rb
29
+
30
+ commit bbe7a87968b146aa25b532adbb66caf3a01c5418
31
+ Author: John Croisant <john@croisant.net>
32
+ Date: Fri Sep 9 16:07:41 2011 -0500
33
+
34
+ FileBase now takes a file path, instead of a Config instance.
35
+
36
+ This makes FileBase more flexible and useful. Config class now handles
37
+ the logic for deciding the path and extension for config files.
38
+
39
+ M lib/configural/config.rb
40
+ M lib/configural/config/file_base.rb
41
+
42
+ commit 4b8a788e4fe69c3aa1ae1d7a17d3d5ca05d711a5
43
+ Author: John Croisant <john@croisant.net>
44
+ Date: Fri Sep 9 14:37:17 2011 -0500
45
+
46
+ Added Configural::User class, which will manage per-user stuff.
47
+
48
+ M lib/configural.rb
49
+ M lib/configural/app.rb
50
+ M lib/configural/config.rb
51
+ M lib/configural/data.rb
52
+ A lib/configural/user.rb
53
+
54
+ commit 4c3855be515030407a4960efcf917dc00df8639f
55
+ Author: John Croisant <john@croisant.net>
56
+ Date: Tue Aug 30 00:54:50 2011 -0500
57
+
58
+ Config and Data ask App for paths instead of Platform directly.
59
+
60
+ M lib/configural/app.rb
61
+ M lib/configural/config.rb
62
+ M lib/configural/data.rb
63
+
64
+ commit 5c3f3a1018866582a1aacd2e4d506a70b7a8050d
65
+ Author: John Croisant <john@croisant.net>
66
+ Date: Mon Aug 29 02:11:34 2011 -0500
67
+
68
+ Updated README.rdoc to mention SDL support.
69
+
70
+ M README.rdoc
71
+
72
+ commit 7604f3b88bb071821c6dc13a398ab024ce9cddf5
73
+ Author: John Croisant <john@croisant.net>
74
+ Date: Mon Aug 29 01:59:11 2011 -0500
75
+
76
+ Added Config::SDLFile (Simple Declarative Language). [#1]
77
+
78
+ M lib/configural/config.rb
79
+ A lib/configural/config/sdl_file.rb
80
+
81
+ commit ff1eddc54ee9e16d7e31e1eaaf25cca7efe3a0f4
82
+ Author: John Croisant <john@croisant.net>
83
+ Date: Mon Aug 29 01:30:00 2011 -0500
84
+
85
+ Fixed silly mistakes in yaml_file.rb and plist_file.rb.
86
+
87
+ M lib/configural/config/plist_file.rb
88
+ M lib/configural/config/yaml_file.rb
89
+
90
+ commit 3e46378b51366128dfc70583e24f87d0cc491b10
91
+ Author: John Croisant <john@croisant.net>
92
+ Date: Sun Aug 28 22:07:17 2011 -0500
93
+
94
+ More error checking for JSON, Plist, and YAML saving/loading.
95
+
96
+ M lib/configural/config/json_file.rb
97
+ M lib/configural/config/plist_file.rb
98
+ M lib/configural/config/yaml_file.rb
99
+
100
+ commit 42b752e236764c94f768881979aa6041f67d8060
101
+ Author: John Croisant <john@croisant.net>
102
+ Date: Sun Aug 28 21:59:21 2011 -0500
103
+
104
+ Wrote config file format section of docs/extending_configural.rdoc.
105
+
106
+ M docs/extending_configural.rdoc
107
+
108
+ commit 625e6924a86759079bbba4d4bedc47d29e8ccc26
109
+ Author: John Croisant <john@croisant.net>
110
+ Date: Sun Aug 28 13:50:35 2011 -0500
111
+
112
+ Added "Extending Configural" guide. Still more to be written.
113
+
114
+ M README.rdoc
115
+ A docs/extending_configural.rdoc
116
+
117
+ commit 07b8345e03957008df0211154734931cd9ffa26f
118
+ Author: John Croisant <john@croisant.net>
119
+ Date: Sun Aug 28 01:32:25 2011 -0500
120
+
121
+ Split the README section about config files to its own guide.
122
+
123
+ The guide content has also been updated since the README.
124
+ See docs/using_config_files.rdoc.
125
+
126
+ M README.rdoc
127
+ A docs/using_config_files.rdoc
128
+
129
+ commit 27cf614487dc49da4e12c1f60bb374763e572280
130
+ Author: John Croisant <john@croisant.net>
131
+ Date: Sun Aug 28 00:58:34 2011 -0500
132
+
133
+ Added Config::FileBase#close, for "unloading" all data.
134
+
135
+ M lib/configural/config/file_base.rb
136
+
137
+ commit 89cb2d3e3b0d42d0c4f3aede84afe2410568658c
138
+ Author: John Croisant <john@croisant.net>
139
+ Date: Sun Aug 28 00:58:32 2011 -0500
140
+
141
+ Changed how Config::FileBase is loaded and saved.
142
+
143
+ * #load only loads if the file has not been loaded yet.
144
+ * #load! loads no matter what.
145
+ * #save only saves if the file has been loaded.
146
+ * #save! saves no matter what.
147
+ * #_load and #_save implement the format-specific logic. These are the
148
+ methods subclasses should override now, instead of #load and #save.
149
+
150
+ M lib/configural/config/file_base.rb
151
+ M lib/configural/config/json_file.rb
152
+ M lib/configural/config/plist_file.rb
153
+ M lib/configural/config/yaml_file.rb
154
+
155
+ commit 49695b3c90d6dcdbde78e2cb75aeee327b8b2afa
156
+ Author: John Croisant <john@croisant.net>
157
+ Date: Sun Aug 28 00:58:31 2011 -0500
158
+
159
+ You can now use a file extension in config names.
160
+
161
+ If it has no file extension, use the default format. If it has a file
162
+ extension, check for a format that provides that extension. If no
163
+ format provides that extension, raise an error.
164
+
165
+ M lib/configural/config.rb
166
+ M lib/configural/config/file_base.rb
167
+
168
+ commit 5dd1672b57f5b4f5a8a178694a6173ecb68882e1
169
+ Author: John Croisant <john@croisant.net>
170
+ Date: Sun Aug 28 00:58:30 2011 -0500
171
+
172
+ FileBase#extnames should be class method. FileBase.format was missing.
173
+
174
+ M lib/configural/config/file_base.rb
175
+
176
+ commit 73df309c3a5611a38f2ac3581f4dd4727a8680ad
177
+ Author: John Croisant <john@croisant.net>
178
+ Date: Sun Aug 28 00:58:28 2011 -0500
179
+
180
+ Replaced Config#format with the :default_format option.
181
+
182
+ M lib/configural/config.rb
183
+
184
+ commit 6692d912b73a0d9402dd337e89563d500d37e8a0
185
+ Author: John Croisant <john@croisant.net>
186
+ Date: Sun Aug 28 00:58:26 2011 -0500
187
+
188
+ Split config.rb into separate files for each class.
189
+
190
+ M lib/configural/config.rb
191
+ A lib/configural/config/file_base.rb
192
+ A lib/configural/config/json_file.rb
193
+ A lib/configural/config/plist_file.rb
194
+ A lib/configural/config/yaml_file.rb
195
+
196
+ commit a8944eab2d1451e2b42369c4841aea8c0cf73ed8
197
+ Author: John Croisant <john@croisant.net>
198
+ Date: Sun Aug 28 00:58:22 2011 -0500
199
+
200
+ Config files load when initialized unless Config has :lazy_loading enabled.
201
+
202
+ This should hopefully be the "least surprising" behavior.
203
+
204
+ M lib/configural/config.rb
205
+
206
+ commit f8d7196eacd0966d661b0ba31f8bbaa6f56b5c87
207
+ Author: John Croisant <john@croisant.net>
208
+ Date: Sun Aug 28 00:57:58 2011 -0500
209
+
210
+ Added Config @options and accessors.
211
+
212
+ M lib/configural/config.rb
213
+
214
+ commit 9e82862fc6435dcd8a5e63f56f17eaef295dee15
215
+ Author: John Croisant <john@croisant.net>
216
+ Date: Wed Aug 24 03:34:36 2011 -0500
217
+
218
+ Updated README.rdoc with a lot of info.
219
+
220
+ M README.rdoc
221
+
222
+ commit 8ae0e51e397d4bb821574612dc55aa0e64c0ce27
223
+ Author: John Croisant <john@croisant.net>
224
+ Date: Wed Aug 24 01:10:50 2011 -0500
225
+
226
+ Store config and data in different directories on Windows.
227
+
228
+ M lib/configural/platform.rb
229
+
230
+ commit 0ea1e419d476b02adf1b0a68e2d4208cc2304dd3
231
+ Author: John Croisant <john@croisant.net>
232
+ Date: Wed Aug 24 00:30:17 2011 -0500
233
+
234
+ Added JSONFile class, for serializing configs as JSON.
235
+
236
+ M lib/configural/config.rb
237
+
238
+ commit 56f6fd565ffc34e62043261147fffd0b88f69574
239
+ Author: John Croisant <john@croisant.net>
240
+ Date: Wed Aug 24 00:17:01 2011 -0500
241
+
242
+ Added method: Config::FileBase#to_hash
243
+
244
+ M lib/configural/config.rb
245
+
246
+ commit b910dd7145c9bd67de13b2d43c316ff0de33863c
247
+ Author: John Croisant <john@croisant.net>
248
+ Date: Wed Aug 24 00:16:25 2011 -0500
249
+
250
+ Fixed bogus logic in Config::FileBase#load_if_uninitialized
251
+
252
+ M lib/configural/config.rb
253
+
254
+ commit 8707356c520d64bc349c2f390b52ea0d2800d578
255
+ Author: John Croisant <john@croisant.net>
256
+ Date: Tue Aug 23 23:28:59 2011 -0500
257
+
258
+ Added PlistFile class, for storing configs as property lists.
259
+
260
+ M lib/configural/config.rb
261
+
262
+ commit a89964791d56d792103e8ee224ca7e27fab9449d
263
+ Author: John Croisant <john@croisant.net>
264
+ Date: Tue Aug 23 21:38:44 2011 -0500
265
+
266
+ Added proper support for multiple possible config file extensions.
267
+
268
+ M lib/configural/config.rb
269
+
270
+ commit 118e78f92006729947a0e0e3a2727983808011a0
271
+ Author: John Croisant <john@croisant.net>
272
+ Date: Tue Aug 23 21:11:56 2011 -0500
273
+
274
+ Revamped Config format selection system.
275
+
276
+ M lib/configural/config.rb
277
+
278
+ commit d3af955376b9c3ecfbbe852db9f15bf8fdd74b48
279
+ Author: John Croisant <john@croisant.net>
280
+ Date: Tue Aug 23 18:30:31 2011 -0500
281
+
282
+ Revamped platform detection.
283
+
284
+ M lib/configural.rb
285
+ M lib/configural/app.rb
286
+ M lib/configural/config.rb
287
+ M lib/configural/data.rb
288
+ A lib/configural/platform.rb
289
+
290
+ commit 372a63c1b754ab798613e5b651597d9b346617c9
291
+ Author: John Croisant <john@croisant.net>
292
+ Date: Mon Aug 22 23:50:52 2011 -0500
293
+
294
+ First attempt at implementation.
295
+
296
+ A lib/configural.rb
297
+ A lib/configural/app.rb
298
+ A lib/configural/config.rb
299
+ A lib/configural/data.rb
300
+
301
+ commit 539982d794c319051fb2a1ab9ff25775c5fb1412
302
+ Author: John Croisant <john@croisant.net>
303
+ Date: Mon Aug 22 15:25:31 2011 -0500
304
+
305
+ Checked in project infrastructure.
306
+
307
+ A .gitignore
308
+ A NEWS.rdoc
309
+ A README.rdoc
310
+ A Rakefile
311
+ A configural.gemspec
312
+ A scripts/mkchangelog.rb
313
+
314
+ commit b77e356d4fb023dde8c16f03ff63edc108b8efc8
315
+ Author: John Croisant <john@croisant.net>
316
+ Date: Mon Aug 22 15:14:41 2011 -0500
317
+
318
+ Initial commit.
@@ -0,0 +1,4 @@
1
+ = NEWS
2
+
3
+ == Configural 0.1
4
+
@@ -0,0 +1,158 @@
1
+
2
+ = Configural
3
+
4
+ Version:: 0.0.1
5
+ Date:: 2011-08-22
6
+
7
+ Homepage:: http://github.com/jacius/configural/
8
+ Author:: John Croisant <john@croisant.net>
9
+ Copyright:: 2011 John Croisant
10
+
11
+
12
+ == Description
13
+
14
+ Configural is a Ruby library for managing per-user configuration files
15
+ and data storage. It aims to provide an easy to use API to allow
16
+ applications to store and retrieve user configuration, cache, and
17
+ persistant data files without any hassle.
18
+
19
+ == Features
20
+
21
+ - Stores config, cache, and data files in the conventional location
22
+ for each operating system. Comes with support for Linux, Mac, and
23
+ Windows out of the box.
24
+ - Comes with support for YAML, JSON, Plist, and SDL config files out
25
+ of the box (assuming you have the proper libraries; see the
26
+ "Dependencies" section, below.)
27
+ - Really easy to add support for more operating systems and more file
28
+ formats.
29
+ - Really, really easy to use!
30
+
31
+ == Dependencies
32
+
33
+ Configural's only dependencies are for the config file formats you
34
+ want to use:
35
+
36
+ - YAML: Requires 'yaml' (standard on most versions of Ruby).
37
+ - JSON: Requires 'json' (standard on some versions of Ruby, otherwise
38
+ install the gem or download from <http://json.rubyforge.org>).
39
+ - Plist: Requires 'plist' (install the gem or download from
40
+ <http://plist.rubyforge.org>).
41
+ - SDL: Requires 'sdl4r' (install the gem or download from
42
+ <http://sdl4r.rubyforge.org>).
43
+
44
+ == Usage
45
+
46
+ Here is some basic usage information. For more details, see the
47
+ documentation for Configural::App, Configural::Config,
48
+ Configural::Data, and Configural::Cache.
49
+
50
+ To add support for another operating system or file format, see the
51
+ "Extending Configural" guide (docs/extending_configural.rdoc).
52
+
53
+ === Setting up
54
+
55
+ Before you can use any part of Configural, you must create an App
56
+ instance, like so:
57
+
58
+ require 'configural'
59
+ app = Configural::App.new("My App")
60
+
61
+ Replace "My App" with the name of your application. This string is
62
+ used to name the directories where your config, data, and cache files
63
+ are saved.
64
+
65
+ === Config files
66
+
67
+ See the "Using Config Files" guide (docs/using_config_files.rdoc).
68
+
69
+ === Data and cache files
70
+
71
+ Data and cache files are just files where you can read and write
72
+ anything you want. They have no special magic, except Configural helps
73
+ you store them in the conventional location for each OS.
74
+
75
+ You can use the +read+ and +write+ methods for convenience, or use the
76
+ +open+ method to get a File instance. +open+ accepts an optional mode
77
+ and an optional block, just like File.open.
78
+
79
+ app.data['mydata.txt'].write("My data.")
80
+ app.data['mydata.txt'].read # => "My data."
81
+ app.data['mydata.txt'].open{ |file|
82
+ # Do whatever you want with the File instance.
83
+ }
84
+
85
+ In this case, 'mydata.txt' refers to a file inside the data storage
86
+ directory, which is different for each operating system. Unlike
87
+ configs, you _should_ use a file extension when referring to a data or
88
+ cache file. (Configural can't automatically guess a file extension,
89
+ because data and cache files can be any file format you want.)
90
+
91
+ Caches work the same as data, except you use +app.cache+ instead of
92
+ +app.data+, and cache files are stored in a different directory.
93
+
94
+ == Where files are stored
95
+
96
+ Configural supports three kinds of files:
97
+
98
+ - Config: User preferences and other configuration settings.
99
+ - Data: Persistant data files. This could be used for things like
100
+ saved playlists, installed add-ons, downloaded music files, or any
101
+ other user data that should be preserved indefinitely.
102
+ - Cache: Temporary files created (for example) to save bandwidth or
103
+ time. These are files that can safely be deleted by the user;
104
+ deleting them won't break the application or cause data loss.
105
+
106
+ Each kind of file is stored in a different directory, as appropriate
107
+ to the conventions of the user's operating system.
108
+
109
+ (The following examples assume your app is named "My App".)
110
+
111
+ === Linux
112
+
113
+ Config: ~/.config/My App/
114
+ Data: ~/.local/share/My App/
115
+ Cache: ~/.cache/My App/
116
+
117
+ === Mac
118
+
119
+ Config: ~/Library/Preferences/My App/
120
+ Data: ~/Library/Application Support/My App/
121
+ Cache: ~/Library/Caches/My App/
122
+
123
+ === Windows
124
+
125
+ Config: %APPDATA%\My App\Config\
126
+ Data: %APPDATA%\My App\Data\
127
+ Cache: %APPDATA%\My App\Cache\
128
+
129
+ %APPDATA% is an environment variable with different values depending
130
+ on your version of Windows. The usual values are:
131
+
132
+ XP: C:\Documents and Settings\%USERNAME%\Application Data
133
+ Vista and later: C:\Users\%USERNAME%\AppData\Roaming
134
+
135
+ == License
136
+
137
+ Configural is licensed under the following terms (the "MIT License"):
138
+
139
+ Copyright (c) 2011 John Croisant
140
+
141
+ Permission is hereby granted, free of charge, to any person obtaining
142
+ a copy of this software and associated documentation files (the
143
+ "Software"), to deal in the Software without restriction, including
144
+ without limitation the rights to use, copy, modify, merge, publish,
145
+ distribute, sublicense, and/or sell copies of the Software, and to
146
+ permit persons to whom the Software is furnished to do so, subject to
147
+ the following conditions:
148
+
149
+ The above copyright notice and this permission notice shall be
150
+ included in all copies or substantial portions of the Software.
151
+
152
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
153
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
154
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
155
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
156
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
157
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
158
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.