wpcli 0.2.6 → 0.2.7

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: 7814f79614d1d4afc430dedb1ea644143ad08909
4
- data.tar.gz: d3e16bf8a536e93c5c3b3610232bdf0cfad80106
3
+ metadata.gz: a08217834623204a2593c7ad1b3c8e977b9910de
4
+ data.tar.gz: 3a04774e8fc09ca06ebfc6efc2ed8b4e464f7d70
5
5
  SHA512:
6
- metadata.gz: 307303ea986e3838c693bc3872e96f164b48a4f74285204694ee9d9f69d2b6cca748384f736420a809cab620f8a43c903b0c0bc512866a42cc0e3ea384783fa0
7
- data.tar.gz: b6be0a1fe3bd1802f23e5834d0bb7303cdfe9d4ad28a7a5df1067b7280e86c22b39e84ffaf935ddb9841bac9fc942be07540b286ef46d47c27f8aa00b6474591
6
+ metadata.gz: e6c8e2b4df9d33724ee9b7b20b8c77cd24e678865544ebc546ef6c58380fa77db11023ea9428a5e440105dbfe23f28a7d1f0238fe53c653a9f4485e1a0c8b8b1
7
+ data.tar.gz: e75241aaec3ce110a2da88badb2f6087a7aadb34a06bb1cee3fa75dc712c6653714eee0cacabb1ad0bfbfc4222605b4f3b058699a0a4b81faebbb3788df1926b
data/lib/wpcli/client.rb CHANGED
@@ -11,6 +11,7 @@ module Wpcli
11
11
  private
12
12
 
13
13
  def parse text
14
+ single_value = false
14
15
  first_data_row = starts_with_plus?(text) ? 3 : 1
15
16
  rows = []
16
17
  text.split("\n").each_with_index do |line, index|
@@ -18,8 +19,9 @@ module Wpcli
18
19
  separator = line.include?('|') ? '|' : "\t"
19
20
  if index < first_data_row
20
21
  @columns = parse_header line, separator
22
+ single_value = detect_if_line_is_from_single_value_response
21
23
  else
22
- if single_value_response
24
+ if single_value
23
25
  parsed_line = parse_line(line, separator)
24
26
  value = parsed_line[:value]
25
27
  unless value.nil? || value == "null"
@@ -42,7 +44,6 @@ module Wpcli
42
44
  def parse_header line, separator
43
45
  columns = []
44
46
  line.split(separator).each_with_index do |column, index|
45
- detect_if_line_is_from_single_value_response column
46
47
  columns[index] = column.strip.downcase unless column.strip.empty?
47
48
  end
48
49
  columns
@@ -59,12 +60,11 @@ module Wpcli
59
60
  line.start_with? "+"
60
61
  end
61
62
 
62
- def detect_if_line_is_from_single_value_response column
63
- @single_value = column.strip.downcase == "field" unless @single_value
64
- end
65
-
66
- def single_value_response
67
- @single_value
63
+ def detect_if_line_is_from_single_value_response
64
+ @columns.each do |column|
65
+ return true if !column.nil? && column.strip.downcase == "field"
66
+ end
67
+ false
68
68
  end
69
69
  end
70
70
  end
data/lib/wpcli/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wpcli
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
@@ -11,6 +11,7 @@ describe Wpcli::Client do
11
11
  EOF
12
12
  end
13
13
  let(:wp_user_list_tabs_newlines) { "ID\tuser_login\tdisplay_name\tuser_email\tuser_registered\troles\n1\tadmin\tadmin\tadmin@domain.tld\t2014-01-07 09:04:08\tadministrator\n" }
14
+ let(:wp_role_list_tabs_newlines) { "name\trole\nAdministrator\tadministrator\nEditor\teditor\nAuthor\tauthor\nContributor\tcontributor\nSubscriber\tsubscriber\n" }
14
15
 
15
16
 
16
17
  let(:wp_role_list) do <<EOF
@@ -201,5 +202,32 @@ EOF
201
202
  end
202
203
  end
203
204
  end
205
+
206
+ context 'multivalue after single value' do
207
+ before :each do
208
+ @wpcli.stub(:`).with("wp user get username").and_return(single_user)
209
+ @array = @wpcli.run "user get username"
210
+ @wpcli.stub(:`).with("wp role list").and_return(wp_role_list_tabs_newlines)
211
+ @array = @wpcli.run "role list"
212
+ end
213
+
214
+ describe 'returns array' do
215
+ it { @array.kind_of?(Array).should be(true)}
216
+
217
+ it 'which contains hashes' do
218
+ @array.first.kind_of?(Hash).should be(true)
219
+ end
220
+
221
+ it 'which has five hashes' do
222
+ @array.size.should eq(5)
223
+ end
224
+
225
+ it 'first hash has correct columns' do
226
+ @array.first.has_key?(:name).should be(true)
227
+ @array.first.has_key?(:role).should be(true)
228
+ @array.first.keys.size.should eq(2)
229
+ end
230
+ end
231
+ end
204
232
  end
205
233
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wpcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joni Hasanen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-01 00:00:00.000000000 Z
11
+ date: 2014-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 10.1.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 10.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.14.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.14.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.7.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.7.0
69
69
  description: Simple wrapper for wp-cli (http://wp-cli.org/)
@@ -73,9 +73,9 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .rspec
78
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
79
  - Gemfile
80
80
  - LICENSE.txt
81
81
  - README.md
@@ -99,17 +99,17 @@ require_paths:
99
99
  - lib
100
100
  required_ruby_version: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - '>='
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.2.0
112
+ rubygems_version: 2.2.2
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Simple wrapper for wp-cli (http://wp-cli.org/)