ppds-libs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ == PPDS libraries
2
+
3
+ Copyright (c) 2009, Paul Philippov
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
+ * Neither the name of the Paul Philippov nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13
+
data/README ADDED
@@ -0,0 +1,18 @@
1
+ = ppds-libs
2
+
3
+ Collection of goodies shared in miscellaneous projects of mine.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but
13
+ bump version in a commit by itself I can ignore when I pull)
14
+ * Send me a pull request. Bonus points for topic branches.
15
+
16
+ == Copyright
17
+
18
+ Copyright (c) 2009 Paul Philippov. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/gempackagetask'
5
+ require 'rake/rdoctask'
6
+ require 'rake/testtask'
7
+ require 'spec/rake/spectask'
8
+
9
+ spec = Gem::Specification.new do |s|
10
+ s.name = 'ppds-libs'
11
+ s.version = '0.0.1'
12
+ s.has_rdoc = true
13
+ s.extra_rdoc_files = ['README', 'LICENSE']
14
+ s.summary = 'PPDS shared libraries'
15
+ s.description = 'A collection of ruby code shared between projects of PPDS'
16
+ s.author = 'Paul Philippov'
17
+ s.email = 'themactep@gmail.com'
18
+ s.homepage = 'http://themactep.com/ppds-libs'
19
+ s.rubyforge_project = 'ppds-libs'
20
+ s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
21
+ s.require_path = "lib"
22
+ s.bindir = "bin"
23
+ end
24
+
25
+ Rake::GemPackageTask.new(spec) do |p|
26
+ p.gem_spec = spec
27
+ p.need_tar = true
28
+ p.need_zip = true
29
+ end
30
+
31
+ Rake::RDocTask.new do |rdoc|
32
+ files =['README', 'LICENSE', 'lib/**/*.rb']
33
+ rdoc.rdoc_files.add(files)
34
+ rdoc.main = "README" # page to start on
35
+ rdoc.title = "ppds-libs Docs"
36
+ rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
37
+ rdoc.options << '--line-numbers'
38
+ end
39
+
40
+ Rake::TestTask.new do |t|
41
+ t.test_files = FileList['test/**/*.rb']
42
+ end
43
+
44
+ Spec::Rake::SpecTask.new do |t|
45
+ t.spec_files = FileList['spec/**/*.rb']
46
+ end
@@ -0,0 +1,17 @@
1
+ module Ppds
2
+ class ClassFactory
3
+ def initialize(data=[])
4
+ for att in data
5
+ set(att.name.gsub(/-/,'_'), att.value)
6
+ end
7
+ end
8
+
9
+ def get(name)
10
+ instance_variable_get("@#{name}")
11
+ end
12
+
13
+ def set(name, value)
14
+ instance_variable_set("@#{name}", value)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,54 @@
1
+ require 'gconf2'
2
+
3
+ module Ppds
4
+ class Config
5
+ @@gconf = GConf::Client.default
6
+
7
+ def gconf
8
+ @@gconf
9
+ end
10
+
11
+ def initialize(app)
12
+ @root = '/apps/%s' % app
13
+ gconf.add_dir(@root)
14
+ end
15
+
16
+ def all
17
+ gconf.all_entries(@root)
18
+ end
19
+
20
+ def get(name)
21
+ gconf[key_from_name(name)]
22
+ end
23
+
24
+ def set(name, value)
25
+ gconf[key_from_name(name)] = value
26
+ end
27
+
28
+ def drop(name)
29
+ gconf.unset(key_from_name(name))
30
+ end
31
+
32
+ def save
33
+ gconf.suggest_sync
34
+ end
35
+
36
+ def destroy
37
+ for one in all
38
+ gconf.unset(one.key)
39
+ end
40
+ save
41
+ end
42
+
43
+ private
44
+
45
+ def name_from_key(key)
46
+ key.split('/').last
47
+ end
48
+
49
+ def key_from_name(name)
50
+ [ @root, name ].join("/")
51
+ end
52
+
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ppds-libs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Paul Philippov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-24 00:00:00 +07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A collection of ruby code shared between projects of PPDS
17
+ email: themactep@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - LICENSE
25
+ files:
26
+ - LICENSE
27
+ - README
28
+ - Rakefile
29
+ - lib/ppds/config.rb
30
+ - lib/ppds/class_factory.rb
31
+ has_rdoc: true
32
+ homepage: http://themactep.com/ppds-libs
33
+ licenses: []
34
+
35
+ post_install_message:
36
+ rdoc_options: []
37
+
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ requirements: []
53
+
54
+ rubyforge_project: ppds-libs
55
+ rubygems_version: 1.3.5
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: PPDS shared libraries
59
+ test_files: []
60
+