swifty 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/swifty.rb +29 -22
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67c77340ca685c1925abcb020769941fa807a53c
|
4
|
+
data.tar.gz: 22c0922842601a9e670606d1ffab6451da465d13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e60566127d16029bc310477569f290054af669add0b0ac910abe8f69b3ddf34f3f55fe0d36cf253b9bbb60b6622ea24adadd50d14784bff85456af199e50e664
|
7
|
+
data.tar.gz: a897b89cdfc46c104187783dad8de959d17e73cf3b196e367be86a7bf2f250cb190022ecc5720c1025e46cbe119e8a2d3a4534653cc404f1f3ef284958fcf170
|
data/lib/swifty.rb
CHANGED
@@ -39,32 +39,39 @@ module Cmxl
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
module Swifty
|
43
|
+
class Parser
|
44
|
+
attr_reader :content, :options, :statement
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
def initialize(content, **options)
|
47
|
+
@options = options
|
48
|
+
@content = content.is_a?(File) ? content.read : content
|
49
|
+
@statement ||= Cmxl.parse(content, encoding: options[:encoding]).first
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
def to_hash
|
53
|
+
statement.to_hash
|
54
|
+
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
def to_yaml
|
57
|
+
to_hash.to_yaml
|
58
|
+
end
|
59
|
+
alias_method :to_yml, :to_yaml
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
def save(file)
|
62
|
+
File.open(file, 'w+') { |f| f.write to_yaml }
|
63
|
+
to_hash
|
64
|
+
end
|
64
65
|
|
65
|
-
|
66
|
+
private
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
def method_missing(name, *args)
|
69
|
+
return statement.send(name, *args)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def new(*args)
|
74
|
+
Parser.new(*args)
|
75
|
+
end
|
76
|
+
module_function :new
|
70
77
|
end
|