compass-configparser 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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +4 -0
  3. data/lib/compass-configparser.rb +52 -0
  4. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d1ff61486eaa23c09fd17ef672e89da79a787506
4
+ data.tar.gz: bde5aeda7e7ba302911d1ed40b17f1e3c38bfc81
5
+ SHA512:
6
+ metadata.gz: 0d05fa49314d1b64bdd4f4a3a23a6033a86e8fdaafe0ee4579a2e09796e2614e0c327daea4ad46e9b16a9c7c49520d7aa68a31ffad6d4b63a77e4791f728e19c
7
+ data.tar.gz: 735a15b43b90b758a115204d36192441dbb824cf9627fbefa28d20bbd19f68c6bad431ae093723c85b6a9e6b0ff3cbf1d79693888085d854a6ca72f45880fe3b
@@ -0,0 +1,4 @@
1
+ compass-configparser
2
+ ====================
3
+
4
+ Helper to parse compass config files
@@ -0,0 +1,52 @@
1
+ class CompassConfigParser
2
+
3
+ attr_accessor :config_file, :params
4
+
5
+ def initialize(config_file = nil)
6
+ @config_file = config_file
7
+ @params = {}
8
+ self.parse_config
9
+ end
10
+
11
+ def validate_config()
12
+ unless File.readable?(self.config_file)
13
+ raise Errno::EACCES, "#{self.config_file} is not readable"
14
+ end
15
+ end
16
+
17
+ def parse_config()
18
+ IO.foreach(self.config_file) do |fLine|
19
+ line = fLine.lstrip.rstrip
20
+ # ignore comments, require, include, import and empty lines
21
+ if !line.match(/^\#|require|include|import|load|discover/) && line.length > 0
22
+ if(/\s*=\s*/.match(line))
23
+ param, value = line.split(/\s*=\s*/, 2)
24
+ var_name = "#{param}".chomp.strip
25
+ value = value.chomp.strip
26
+
27
+ new_value = ''
28
+ if (value)
29
+ if value =~ /^['"](.*)['"]$/
30
+ new_value = $1
31
+ else
32
+ new_value = value
33
+ end
34
+ else
35
+ new_value = ''
36
+ end
37
+
38
+ self.params[param] = new_value
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ def get_param(key, default)
45
+ if self.params[key] != nil
46
+ self.params[key]
47
+ else
48
+ default
49
+ end
50
+ end
51
+
52
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: compass-configparser
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Tino Wehe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-01-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Helper to parse compass-style.org config files
14
+ email: tino.wehe@brandrockers.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - README.md
20
+ - lib/compass-configparser.rb
21
+ homepage: https://github.com/pixel-shock/compass-configparser
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.2.1
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Helper to parse compass-style.org config files
45
+ test_files: []