org_tp 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 703ec54e13e94b547bfb120fbd9a5876fee1269e
4
- data.tar.gz: 2b7498e7f7a6d9a2dbbd9c58d86bd5c1fa75250d
3
+ metadata.gz: 5739280d770002d46e6eaf8ce1926db5b2cce7dc
4
+ data.tar.gz: 56097cb749aff8e5661932544774829abc1c328b
5
5
  SHA512:
6
- metadata.gz: ac82e9d5fd8f682012dde62fad80ba29a0d4e5ffa95756176fe6a8bc08cbff1c472c11333d6ff22e08abb7df4e4abf760ac1249e618ff63404d8a9aac7b35898
7
- data.tar.gz: 3fd8f1268341e40bc8a1aaa9bf10bf2c4416fdf55ad6ea1408d29a87d4a0b6f2362052c77b5188a3858499f75a4c8500071a8aa9c2275e3974f4c7d42a073539
6
+ metadata.gz: a56e75a5c191b9d6a8221999dc9a90c2d891cd8a381c2a8e9f8ef2d2762e7031ab4b93c22e8e1b72d1a3f6f3d736af2c9a6ebc9068465d6e04c96ed916258c6d
7
+ data.tar.gz: 9d27789a067b83ca23da8676fd9b283da5757981adb8e35fe4f8c18aa690f2527b7e72fe2edae26247b44f3a31d330cb87da065cad3771ea95792267225a9ed0
@@ -128,6 +128,7 @@ module OrgTp
128
128
 
129
129
  def pre_processes
130
130
  [
131
+ # Hash
131
132
  {
132
133
  _case: -> e { e.kind_of?(Hash) },
133
134
  header: false,
@@ -137,24 +138,40 @@ module OrgTp
137
138
  end
138
139
  },
139
140
  },
141
+
142
+ # Array of Hash
140
143
  {
141
- _case: -> e { e.kind_of?(Array) && e.any? { |e| !e.kind_of?(Hash) } },
144
+ _case: -> e { e.kind_of?(Array) && e.all? { |e| e.kind_of?(Hash) } }, # !> shadowing outer local variable - e
145
+ header: true,
146
+ process: -> e { e },
147
+ },
148
+
149
+ # Array excluding Hash
150
+ {
151
+ _case: -> e { e.kind_of?(Array) && e.none? { |e| e.kind_of?(Hash) } }, # !> shadowing outer local variable - e
142
152
  header: false,
143
153
  process: -> e {
144
- e.collect do |e|
154
+ e.collect do |e| # !> shadowing outer local variable - e
155
+ {'(array_element)' => e}
156
+ end
157
+ },
158
+ },
159
+
160
+ # Array containing Hash and others
161
+ {
162
+ _case: -> e { e.kind_of?(Array) && e.any? { |e| !e.kind_of?(Hash) } }, # !> shadowing outer local variable - e
163
+ header: true,
164
+ process: -> e {
165
+ e.collect do |e| # !> shadowing outer local variable - e
145
166
  if e.kind_of? Hash
146
167
  e
147
168
  else
148
- {'(array_value)' => e}
169
+ {'(array_element)' => e}
149
170
  end
150
171
  end
151
172
  },
152
173
  },
153
- {
154
- _case: -> e { e.kind_of?(Array) && e.all? { |e| e.kind_of?(Hash) } },
155
- header: true,
156
- process: -> e { e },
157
- },
174
+
158
175
  ]
159
176
  end
160
177
  end
@@ -170,19 +187,30 @@ if $0 == __FILE__
170
187
  print OrgTp.generate([])
171
188
  print OrgTp.generate(rows)
172
189
  print OrgTp.generate({a: 1, b: 2}, header: false)
190
+ print OrgTp.generate([["a", "b"], ["c", "d"]])
191
+ print OrgTp.generate([["a", "b"], {"c" => "d"}])
173
192
  end
174
- # >> +---+----+
193
+ # >> |---+----|
175
194
  # >> | a | [] |
176
- # >> +---+----+
177
- # >>
178
- # >> +----+-------+-------------+
195
+ # >> |---+----|
196
+ # >> |----+-------+-------------|
179
197
  # >> | id | name | description |
180
- # >> +----+-------+-------------+
198
+ # >> |----+-------+-------------|
181
199
  # >> | 1 | alice | 0123456789 |
182
200
  # >> | 2 | bob | あいうえお |
183
201
  # >> | 3 | carol | |
184
- # >> +----+-------+-------------+
185
- # >> +---+---+
202
+ # >> |----+-------+-------------|
203
+ # >> |---+---|
186
204
  # >> | a | 1 |
187
205
  # >> | b | 2 |
188
- # >> +---+---+
206
+ # >> |---+---|
207
+ # >> |------------|
208
+ # >> | ["a", "b"] |
209
+ # >> | ["c", "d"] |
210
+ # >> |------------|
211
+ # >> |-----------------+---|
212
+ # >> | (array_element) | c |
213
+ # >> |-----------------+---|
214
+ # >> | ["a", "b"] | |
215
+ # >> | | d |
216
+ # >> |-----------------+---|
@@ -1,3 +1,3 @@
1
1
  module OrgTp
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
data/spec/org_tp_spec.rb CHANGED
@@ -103,6 +103,17 @@ EOT
103
103
  |-------|
104
104
  | ["a"] |
105
105
  |-------|
106
+ EOT
107
+ end
108
+
109
+ it 'Array containing Hash and others' do
110
+ OrgTp.generate([["a", "b"], {"c" => "d"}]).should == <<~EOT
111
+ |-----------------+---|
112
+ | (array_element) | c |
113
+ |-----------------+---|
114
+ | ["a", "b"] | |
115
+ | | d |
116
+ |-----------------+---|
106
117
  EOT
107
118
  end
108
119
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: org_tp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - akicho8
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-20 00:00:00.000000000 Z
11
+ date: 2017-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport