postfix_status_line 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b10924e32ce6ebffb06011504d98b5a58215ffd
4
- data.tar.gz: 2b651b2c2167f9bf337fcf9d85c1ee56a96a6a08
3
+ metadata.gz: 6e0228c71c5531a6bc5859266242b3c31e6e6479
4
+ data.tar.gz: cc24c357e37e617b4e50bad0d7480584391f99db
5
5
  SHA512:
6
- metadata.gz: 2098822209549b5a511050b43448714b32dc4a44e3d87d4cda001233e738edd6019aecec612aa0a9e493a6a46298869c92c30a68fda5df74f4c6a0c4d1743a3b
7
- data.tar.gz: 562cc8ceb999f4f158fa4413c05a5d0f429e407d63f8781755de3311ce36bd6bbc42fcae79e1505bc9343705c62f70341eb4dc5784af99da5f8dfb8d486b1624
6
+ metadata.gz: a2010e03c30750c4cf8234b6c35bf6f04bc9617f10621c3cf8544cdf993abb49cc2088b008c68130fb238b8187b0343463093a4464636485ad842b7ad9bf4c2b
7
+ data.tar.gz: b7a7a09bb7c84721ea0bc7d9c5d81881f965b586b3d3dfb64641422695a50bbbd488c41707d4bc11de0cf2f71a6d63b18fbbdad56495e073b50e68f2eb3448dd
@@ -104,6 +104,40 @@ static void mask_email(char *str) {
104
104
  }
105
105
  }
106
106
 
107
+ static void put_domain(char *value, VALUE hash) {
108
+ char *domain = strchr(value, '@');
109
+
110
+ if (domain == NULL) {
111
+ return;
112
+ }
113
+
114
+ domain++;
115
+
116
+ char *bracket = strchr(domain, '>');
117
+ VALUE v_value;
118
+
119
+ if (bracket == NULL) {
120
+ v_value = rb_str_new2(domain);
121
+ } else {
122
+ size_t len = bracket - domain;
123
+ v_value = rb_str_new(domain, len);
124
+ }
125
+
126
+ rb_hash_aset(hash, rb_str_new2("domain"), v_value);
127
+ }
128
+
129
+ static void put_status(char *value, VALUE hash) {
130
+ char *reason = strchr(value, ' ');
131
+
132
+ if (reason != NULL) {
133
+ *reason = '\0';
134
+ reason++;
135
+ rb_hash_aset(hash, rb_str_new2("reason"), rb_str_new2(reason));
136
+ }
137
+
138
+ rb_hash_aset(hash, rb_str_new2("status"), rb_str_new2(value));
139
+ }
140
+
107
141
  static void put_attr(char *str, VALUE hash) {
108
142
  char *value = strchr(str, '=');
109
143
 
@@ -115,35 +149,19 @@ static void put_attr(char *str, VALUE hash) {
115
149
  value++;
116
150
 
117
151
  VALUE v_key = rb_str_new2(str);
118
- VALUE v_value;
119
152
 
120
153
  if (strcmp(str, "delay") == 0) {
121
- v_value = rb_float_new(atof(value));
154
+ VALUE v_value = rb_float_new(atof(value));
155
+ rb_hash_aset(hash, v_key, v_value);
156
+ } else if (strcmp(str, "status") == 0) {
157
+ put_status(value, hash);
122
158
  } else {
123
- v_value = rb_str_new2(value);
159
+ VALUE v_value = rb_str_new2(value);
160
+ rb_hash_aset(hash, v_key, v_value);
124
161
  }
125
162
 
126
- rb_hash_aset(hash, v_key, v_value);
127
-
128
163
  if (strcmp(str, "to") == 0) {
129
- char *domain = strchr(value, '@');
130
-
131
- if (domain == NULL) {
132
- return;
133
- }
134
-
135
- domain++;
136
-
137
- char *bracket = strchr(domain, '>');
138
-
139
- if (bracket == NULL) {
140
- v_value = rb_str_new2(domain);
141
- } else {
142
- size_t len = bracket - domain;
143
- v_value = rb_str_new(domain, len);
144
- }
145
-
146
- rb_hash_aset(hash, rb_str_new2("domain"), v_value);
164
+ put_domain(value, hash);
147
165
  }
148
166
  }
149
167
 
@@ -1,3 +1,3 @@
1
1
  module PostfixStatusLine
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postfix_status_line
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-21 00:00:00.000000000 Z
11
+ date: 2015-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler