rm-wsse 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +97 -0
- data/Guardfile +12 -0
- data/LICENSE.txt +13 -0
- data/README.md +58 -0
- data/Rakefile +17 -0
- data/app/app.rb +7 -0
- data/app/app_delegate.rb +5 -0
- data/app/kernel.rb +9 -0
- data/app/rm-ansiterm.rb +558 -0
- data/app/string.rb +5 -0
- data/lib/rm-wsse.rb +21 -0
- data/lib/rm-wsse/rm-wsse.rb +18 -0
- data/lib/rm-wsse/version.rb +3 -0
- data/rm-wsse.gemspec +23 -0
- data/spec/00-redgreen.rb +108 -0
- data/spec/rm-wsse_spec.rb +20 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0bf5d35ec3300f8dd3d0c060f84fd4eb7dc4935b
|
4
|
+
data.tar.gz: 8c8c648e88e34ff8f25465396266f99047671d51
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3c0e7aa9d6017536b6f274e4c48641c0f2d715a5b816f811f45e715c21dc3a18b25dea1965e0db7bbd266e82c8d1ae029606f47b2896c9a2a6c4ae9c4d3b61f3
|
7
|
+
data.tar.gz: e0fa0049b7412c248f6e66a57518bbede22dca0d6841d04ce2fc60d0ae580997ff9c9c8608832c96a1c4cb2d1e25b849be6d51fad3445cf9df43c4f5204dcb33
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
language: objective-c
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rm-wsse (0.0.1)
|
5
|
+
cocoapods (= 0.20.2)
|
6
|
+
motion-cocoapods (= 1.3.2)
|
7
|
+
rm-digest
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (3.2.13)
|
13
|
+
i18n (= 0.6.1)
|
14
|
+
multi_json (~> 1.0)
|
15
|
+
addressable (2.3.5)
|
16
|
+
claide (0.3.2)
|
17
|
+
cocoapods (0.20.2)
|
18
|
+
activesupport (~> 3.2.13)
|
19
|
+
claide (~> 0.3.2)
|
20
|
+
cocoapods-core (= 0.20.2)
|
21
|
+
cocoapods-downloader (~> 0.1.1)
|
22
|
+
colored (~> 1.2)
|
23
|
+
escape (~> 0.0.4)
|
24
|
+
faraday (~> 0.8.1)
|
25
|
+
json (~> 1.8.0)
|
26
|
+
octokit (~> 1.7)
|
27
|
+
open4 (~> 1.3.0)
|
28
|
+
rake (~> 10.0.0)
|
29
|
+
xcodeproj (~> 0.6.0)
|
30
|
+
cocoapods-core (0.20.2)
|
31
|
+
activesupport (~> 3.2.13)
|
32
|
+
rake (~> 10.0.0)
|
33
|
+
cocoapods-downloader (0.1.1)
|
34
|
+
coderay (1.0.9)
|
35
|
+
colored (1.2)
|
36
|
+
escape (0.0.4)
|
37
|
+
faraday (0.8.7)
|
38
|
+
multipart-post (~> 1.1)
|
39
|
+
faraday_middleware (0.9.0)
|
40
|
+
faraday (>= 0.7.4, < 0.9)
|
41
|
+
ffi (1.9.0)
|
42
|
+
formatador (0.2.4)
|
43
|
+
guard (1.8.1)
|
44
|
+
formatador (>= 0.2.4)
|
45
|
+
listen (>= 1.0.0)
|
46
|
+
lumberjack (>= 1.0.2)
|
47
|
+
pry (>= 0.9.10)
|
48
|
+
thor (>= 0.14.6)
|
49
|
+
guard-motion (0.1.2)
|
50
|
+
guard (>= 1.1.0)
|
51
|
+
rake (>= 0.9)
|
52
|
+
hashie (2.0.5)
|
53
|
+
i18n (0.6.1)
|
54
|
+
json (1.8.0)
|
55
|
+
listen (1.2.2)
|
56
|
+
rb-fsevent (>= 0.9.3)
|
57
|
+
rb-inotify (>= 0.9)
|
58
|
+
rb-kqueue (>= 0.2)
|
59
|
+
lumberjack (1.0.4)
|
60
|
+
method_source (0.8.1)
|
61
|
+
motion-cocoapods (1.3.2)
|
62
|
+
cocoapods (>= 0.17.0)
|
63
|
+
multi_json (1.7.7)
|
64
|
+
multipart-post (1.2.0)
|
65
|
+
netrc (0.7.7)
|
66
|
+
octokit (1.25.0)
|
67
|
+
addressable (~> 2.2)
|
68
|
+
faraday (~> 0.8)
|
69
|
+
faraday_middleware (~> 0.9)
|
70
|
+
hashie (~> 2.0)
|
71
|
+
multi_json (~> 1.3)
|
72
|
+
netrc (~> 0.7.7)
|
73
|
+
open4 (1.3.0)
|
74
|
+
pry (0.9.12.2)
|
75
|
+
coderay (~> 1.0.5)
|
76
|
+
method_source (~> 0.8)
|
77
|
+
slop (~> 3.4)
|
78
|
+
rake (10.0.4)
|
79
|
+
rb-fsevent (0.9.3)
|
80
|
+
rb-inotify (0.9.0)
|
81
|
+
ffi (>= 0.5.0)
|
82
|
+
rb-kqueue (0.2.0)
|
83
|
+
ffi (>= 0.5.0)
|
84
|
+
rm-digest (0.0.2)
|
85
|
+
slop (3.4.5)
|
86
|
+
thor (0.18.1)
|
87
|
+
xcodeproj (0.6.0)
|
88
|
+
activesupport (~> 3.2.13)
|
89
|
+
colored (~> 1.2)
|
90
|
+
|
91
|
+
PLATFORMS
|
92
|
+
ruby
|
93
|
+
|
94
|
+
DEPENDENCIES
|
95
|
+
guard-motion
|
96
|
+
rake
|
97
|
+
rm-wsse!
|
data/Guardfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'motion' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
|
7
|
+
# RubyMotion App example
|
8
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
9
|
+
|
10
|
+
# RubyMotion gem example
|
11
|
+
watch(%r{^lib/[^/]+/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
12
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2013- Naoya Ito
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# RmWsse
|
2
|
+
|
3
|
+
gem for RubyMotion, to create WSSE header string.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
wsse = RmWsse.wsse_header('username', 'password')
|
9
|
+
|
10
|
+
## Example: w/ BubbleWrap
|
11
|
+
BW::HTTP.post('http://example.com/api', {
|
12
|
+
:headers => {
|
13
|
+
'X-WSSE' => wsse
|
14
|
+
}
|
15
|
+
})
|
16
|
+
```
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
gem 'rm-wsse'
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install rm-digest
|
31
|
+
|
32
|
+
## Copyright
|
33
|
+
|
34
|
+
* Copyright (c) 2013- Naoya Ito (@naoya_ito)
|
35
|
+
* License
|
36
|
+
* Apache License, Version 2.0
|
37
|
+
|
38
|
+
## Installation
|
39
|
+
|
40
|
+
Add this line to your application's Gemfile:
|
41
|
+
|
42
|
+
gem 'fluent-plugin-config-pit'
|
43
|
+
|
44
|
+
And then execute:
|
45
|
+
|
46
|
+
$ bundle
|
47
|
+
|
48
|
+
Or install it yourself as:
|
49
|
+
|
50
|
+
$ gem install fluent-plugin-config-pit
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
1. Fork it
|
55
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
56
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
57
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
58
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
$:.unshift("/Library/RubyMotion/lib")
|
4
|
+
require 'motion/project/template/ios'
|
5
|
+
|
6
|
+
require 'guard/motion'
|
7
|
+
require 'rm-digest'
|
8
|
+
require 'motion-cocoapods'
|
9
|
+
|
10
|
+
Motion::Project::App.setup do |app|
|
11
|
+
app.name = 'spec'
|
12
|
+
app.files += Dir.glob(File.join(app.project_dir, 'lib/rm-wsse/*.rb'))
|
13
|
+
|
14
|
+
app.pods do
|
15
|
+
pod 'Base64'
|
16
|
+
end
|
17
|
+
end
|
data/app/app.rb
ADDED
data/app/app_delegate.rb
ADDED
data/app/kernel.rb
ADDED
data/app/rm-ansiterm.rb
ADDED
@@ -0,0 +1,558 @@
|
|
1
|
+
return unless App.development?
|
2
|
+
|
3
|
+
module Term
|
4
|
+
# The ANSIColor module can be used for namespacing and mixed into your own
|
5
|
+
# classes.
|
6
|
+
module ANSIColor
|
7
|
+
# :stopdoc:
|
8
|
+
ATTRIBUTES = [
|
9
|
+
[ :clear , 0 ],
|
10
|
+
[ :reset , 0 ], # synonym for :clear
|
11
|
+
[ :bold , 1 ],
|
12
|
+
[ :dark , 2 ],
|
13
|
+
[ :italic , 3 ], # not widely implemented
|
14
|
+
[ :underline , 4 ],
|
15
|
+
[ :underscore , 4 ], # synonym for :underline
|
16
|
+
[ :blink , 5 ],
|
17
|
+
[ :rapid_blink , 6 ], # not widely implemented
|
18
|
+
[ :negative , 7 ], # no reverse because of String#reverse
|
19
|
+
[ :concealed , 8 ],
|
20
|
+
[ :strikethrough, 9 ], # not widely implemented
|
21
|
+
[ :black , 30 ],
|
22
|
+
[ :red , 31 ],
|
23
|
+
[ :green , 32 ],
|
24
|
+
[ :yellow , 33 ],
|
25
|
+
[ :blue , 34 ],
|
26
|
+
[ :magenta , 35 ],
|
27
|
+
[ :cyan , 36 ],
|
28
|
+
[ :white , 37 ],
|
29
|
+
[ :on_black , 40 ],
|
30
|
+
[ :on_red , 41 ],
|
31
|
+
[ :on_green , 42 ],
|
32
|
+
[ :on_yellow , 43 ],
|
33
|
+
[ :on_blue , 44 ],
|
34
|
+
[ :on_magenta , 45 ],
|
35
|
+
[ :on_cyan , 46 ],
|
36
|
+
[ :on_white , 47 ],
|
37
|
+
]
|
38
|
+
|
39
|
+
ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
|
40
|
+
# :startdoc:
|
41
|
+
|
42
|
+
# Returns true, if the coloring function of this module
|
43
|
+
# is switched on, false otherwise.
|
44
|
+
def self.coloring?
|
45
|
+
@coloring
|
46
|
+
end
|
47
|
+
|
48
|
+
# Turns the coloring on or off globally, so you can easily do
|
49
|
+
# this for example:
|
50
|
+
# Term::ANSIColor::coloring = STDOUT.isatty
|
51
|
+
def self.coloring=(val)
|
52
|
+
@coloring = val
|
53
|
+
end
|
54
|
+
self.coloring = true
|
55
|
+
|
56
|
+
|
57
|
+
def clear(string = nil)
|
58
|
+
result = ''
|
59
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
60
|
+
if block_given?
|
61
|
+
result << yield
|
62
|
+
elsif string
|
63
|
+
result << string
|
64
|
+
elsif respond_to?(:to_str)
|
65
|
+
result << self
|
66
|
+
else
|
67
|
+
return result #only switch on
|
68
|
+
end
|
69
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
70
|
+
result
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def reset(string = nil)
|
75
|
+
result = ''
|
76
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
77
|
+
if block_given?
|
78
|
+
result << yield
|
79
|
+
elsif string
|
80
|
+
result << string
|
81
|
+
elsif respond_to?(:to_str)
|
82
|
+
result << self
|
83
|
+
else
|
84
|
+
return result #only switch on
|
85
|
+
end
|
86
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
87
|
+
result
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def bold(string = nil)
|
92
|
+
result = ''
|
93
|
+
result << "[1m" if Term::ANSIColor.coloring?
|
94
|
+
if block_given?
|
95
|
+
result << yield
|
96
|
+
elsif string
|
97
|
+
result << string
|
98
|
+
elsif respond_to?(:to_str)
|
99
|
+
result << self
|
100
|
+
else
|
101
|
+
return result #only switch on
|
102
|
+
end
|
103
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
104
|
+
result
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
def dark(string = nil)
|
109
|
+
result = ''
|
110
|
+
result << "[2m" if Term::ANSIColor.coloring?
|
111
|
+
if block_given?
|
112
|
+
result << yield
|
113
|
+
elsif string
|
114
|
+
result << string
|
115
|
+
elsif respond_to?(:to_str)
|
116
|
+
result << self
|
117
|
+
else
|
118
|
+
return result #only switch on
|
119
|
+
end
|
120
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
121
|
+
result
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
def italic(string = nil)
|
126
|
+
result = ''
|
127
|
+
result << "[3m" if Term::ANSIColor.coloring?
|
128
|
+
if block_given?
|
129
|
+
result << yield
|
130
|
+
elsif string
|
131
|
+
result << string
|
132
|
+
elsif respond_to?(:to_str)
|
133
|
+
result << self
|
134
|
+
else
|
135
|
+
return result #only switch on
|
136
|
+
end
|
137
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
138
|
+
result
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
def underline(string = nil)
|
143
|
+
result = ''
|
144
|
+
result << "[4m" if Term::ANSIColor.coloring?
|
145
|
+
if block_given?
|
146
|
+
result << yield
|
147
|
+
elsif string
|
148
|
+
result << string
|
149
|
+
elsif respond_to?(:to_str)
|
150
|
+
result << self
|
151
|
+
else
|
152
|
+
return result #only switch on
|
153
|
+
end
|
154
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
155
|
+
result
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
def underscore(string = nil)
|
160
|
+
result = ''
|
161
|
+
result << "[4m" if Term::ANSIColor.coloring?
|
162
|
+
if block_given?
|
163
|
+
result << yield
|
164
|
+
elsif string
|
165
|
+
result << string
|
166
|
+
elsif respond_to?(:to_str)
|
167
|
+
result << self
|
168
|
+
else
|
169
|
+
return result #only switch on
|
170
|
+
end
|
171
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
172
|
+
result
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
def blink(string = nil)
|
177
|
+
result = ''
|
178
|
+
result << "[5m" if Term::ANSIColor.coloring?
|
179
|
+
if block_given?
|
180
|
+
result << yield
|
181
|
+
elsif string
|
182
|
+
result << string
|
183
|
+
elsif respond_to?(:to_str)
|
184
|
+
result << self
|
185
|
+
else
|
186
|
+
return result #only switch on
|
187
|
+
end
|
188
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
189
|
+
result
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
def rapid_blink(string = nil)
|
194
|
+
result = ''
|
195
|
+
result << "[6m" if Term::ANSIColor.coloring?
|
196
|
+
if block_given?
|
197
|
+
result << yield
|
198
|
+
elsif string
|
199
|
+
result << string
|
200
|
+
elsif respond_to?(:to_str)
|
201
|
+
result << self
|
202
|
+
else
|
203
|
+
return result #only switch on
|
204
|
+
end
|
205
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
206
|
+
result
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
def negative(string = nil)
|
211
|
+
result = ''
|
212
|
+
result << "[7m" if Term::ANSIColor.coloring?
|
213
|
+
if block_given?
|
214
|
+
result << yield
|
215
|
+
elsif string
|
216
|
+
result << string
|
217
|
+
elsif respond_to?(:to_str)
|
218
|
+
result << self
|
219
|
+
else
|
220
|
+
return result #only switch on
|
221
|
+
end
|
222
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
223
|
+
result
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
def concealed(string = nil)
|
228
|
+
result = ''
|
229
|
+
result << "[8m" if Term::ANSIColor.coloring?
|
230
|
+
if block_given?
|
231
|
+
result << yield
|
232
|
+
elsif string
|
233
|
+
result << string
|
234
|
+
elsif respond_to?(:to_str)
|
235
|
+
result << self
|
236
|
+
else
|
237
|
+
return result #only switch on
|
238
|
+
end
|
239
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
240
|
+
result
|
241
|
+
end
|
242
|
+
|
243
|
+
|
244
|
+
def strikethrough(string = nil)
|
245
|
+
result = ''
|
246
|
+
result << "[9m" if Term::ANSIColor.coloring?
|
247
|
+
if block_given?
|
248
|
+
result << yield
|
249
|
+
elsif string
|
250
|
+
result << string
|
251
|
+
elsif respond_to?(:to_str)
|
252
|
+
result << self
|
253
|
+
else
|
254
|
+
return result #only switch on
|
255
|
+
end
|
256
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
257
|
+
result
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
def black(string = nil)
|
262
|
+
result = ''
|
263
|
+
result << "[30m" if Term::ANSIColor.coloring?
|
264
|
+
if block_given?
|
265
|
+
result << yield
|
266
|
+
elsif string
|
267
|
+
result << string
|
268
|
+
elsif respond_to?(:to_str)
|
269
|
+
result << self
|
270
|
+
else
|
271
|
+
return result #only switch on
|
272
|
+
end
|
273
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
274
|
+
result
|
275
|
+
end
|
276
|
+
|
277
|
+
|
278
|
+
def red(string = nil)
|
279
|
+
result = ''
|
280
|
+
result << "[31m" if Term::ANSIColor.coloring?
|
281
|
+
if block_given?
|
282
|
+
result << yield
|
283
|
+
elsif string
|
284
|
+
result << string
|
285
|
+
elsif respond_to?(:to_str)
|
286
|
+
result << self
|
287
|
+
else
|
288
|
+
return result #only switch on
|
289
|
+
end
|
290
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
291
|
+
result
|
292
|
+
end
|
293
|
+
|
294
|
+
|
295
|
+
def green(string = nil)
|
296
|
+
result = ''
|
297
|
+
result << "[32m" if Term::ANSIColor.coloring?
|
298
|
+
if block_given?
|
299
|
+
result << yield
|
300
|
+
elsif string
|
301
|
+
result << string
|
302
|
+
elsif respond_to?(:to_str)
|
303
|
+
result << self
|
304
|
+
else
|
305
|
+
return result #only switch on
|
306
|
+
end
|
307
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
308
|
+
result
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
def yellow(string = nil)
|
313
|
+
result = ''
|
314
|
+
result << "[33m" if Term::ANSIColor.coloring?
|
315
|
+
if block_given?
|
316
|
+
result << yield
|
317
|
+
elsif string
|
318
|
+
result << string
|
319
|
+
elsif respond_to?(:to_str)
|
320
|
+
result << self
|
321
|
+
else
|
322
|
+
return result #only switch on
|
323
|
+
end
|
324
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
325
|
+
result
|
326
|
+
end
|
327
|
+
|
328
|
+
|
329
|
+
def blue(string = nil)
|
330
|
+
result = ''
|
331
|
+
result << "[34m" if Term::ANSIColor.coloring?
|
332
|
+
if block_given?
|
333
|
+
result << yield
|
334
|
+
elsif string
|
335
|
+
result << string
|
336
|
+
elsif respond_to?(:to_str)
|
337
|
+
result << self
|
338
|
+
else
|
339
|
+
return result #only switch on
|
340
|
+
end
|
341
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
342
|
+
result
|
343
|
+
end
|
344
|
+
|
345
|
+
|
346
|
+
def magenta(string = nil)
|
347
|
+
result = ''
|
348
|
+
result << "[35m" if Term::ANSIColor.coloring?
|
349
|
+
if block_given?
|
350
|
+
result << yield
|
351
|
+
elsif string
|
352
|
+
result << string
|
353
|
+
elsif respond_to?(:to_str)
|
354
|
+
result << self
|
355
|
+
else
|
356
|
+
return result #only switch on
|
357
|
+
end
|
358
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
359
|
+
result
|
360
|
+
end
|
361
|
+
|
362
|
+
|
363
|
+
def cyan(string = nil)
|
364
|
+
result = ''
|
365
|
+
result << "[36m" if Term::ANSIColor.coloring?
|
366
|
+
if block_given?
|
367
|
+
result << yield
|
368
|
+
elsif string
|
369
|
+
result << string
|
370
|
+
elsif respond_to?(:to_str)
|
371
|
+
result << self
|
372
|
+
else
|
373
|
+
return result #only switch on
|
374
|
+
end
|
375
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
376
|
+
result
|
377
|
+
end
|
378
|
+
|
379
|
+
|
380
|
+
def white(string = nil)
|
381
|
+
result = ''
|
382
|
+
result << "[37m" if Term::ANSIColor.coloring?
|
383
|
+
if block_given?
|
384
|
+
result << yield
|
385
|
+
elsif string
|
386
|
+
result << string
|
387
|
+
elsif respond_to?(:to_str)
|
388
|
+
result << self
|
389
|
+
else
|
390
|
+
return result #only switch on
|
391
|
+
end
|
392
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
393
|
+
result
|
394
|
+
end
|
395
|
+
|
396
|
+
|
397
|
+
def on_black(string = nil)
|
398
|
+
result = ''
|
399
|
+
result << "[40m" if Term::ANSIColor.coloring?
|
400
|
+
if block_given?
|
401
|
+
result << yield
|
402
|
+
elsif string
|
403
|
+
result << string
|
404
|
+
elsif respond_to?(:to_str)
|
405
|
+
result << self
|
406
|
+
else
|
407
|
+
return result #only switch on
|
408
|
+
end
|
409
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
410
|
+
result
|
411
|
+
end
|
412
|
+
|
413
|
+
|
414
|
+
def on_red(string = nil)
|
415
|
+
result = ''
|
416
|
+
result << "[41m" if Term::ANSIColor.coloring?
|
417
|
+
if block_given?
|
418
|
+
result << yield
|
419
|
+
elsif string
|
420
|
+
result << string
|
421
|
+
elsif respond_to?(:to_str)
|
422
|
+
result << self
|
423
|
+
else
|
424
|
+
return result #only switch on
|
425
|
+
end
|
426
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
427
|
+
result
|
428
|
+
end
|
429
|
+
|
430
|
+
|
431
|
+
def on_green(string = nil)
|
432
|
+
result = ''
|
433
|
+
result << "[42m" if Term::ANSIColor.coloring?
|
434
|
+
if block_given?
|
435
|
+
result << yield
|
436
|
+
elsif string
|
437
|
+
result << string
|
438
|
+
elsif respond_to?(:to_str)
|
439
|
+
result << self
|
440
|
+
else
|
441
|
+
return result #only switch on
|
442
|
+
end
|
443
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
444
|
+
result
|
445
|
+
end
|
446
|
+
|
447
|
+
|
448
|
+
def on_yellow(string = nil)
|
449
|
+
result = ''
|
450
|
+
result << "[43m" if Term::ANSIColor.coloring?
|
451
|
+
if block_given?
|
452
|
+
result << yield
|
453
|
+
elsif string
|
454
|
+
result << string
|
455
|
+
elsif respond_to?(:to_str)
|
456
|
+
result << self
|
457
|
+
else
|
458
|
+
return result #only switch on
|
459
|
+
end
|
460
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
461
|
+
result
|
462
|
+
end
|
463
|
+
|
464
|
+
|
465
|
+
def on_blue(string = nil)
|
466
|
+
result = ''
|
467
|
+
result << "[44m" if Term::ANSIColor.coloring?
|
468
|
+
if block_given?
|
469
|
+
result << yield
|
470
|
+
elsif string
|
471
|
+
result << string
|
472
|
+
elsif respond_to?(:to_str)
|
473
|
+
result << self
|
474
|
+
else
|
475
|
+
return result #only switch on
|
476
|
+
end
|
477
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
478
|
+
result
|
479
|
+
end
|
480
|
+
|
481
|
+
|
482
|
+
def on_magenta(string = nil)
|
483
|
+
result = ''
|
484
|
+
result << "[45m" if Term::ANSIColor.coloring?
|
485
|
+
if block_given?
|
486
|
+
result << yield
|
487
|
+
elsif string
|
488
|
+
result << string
|
489
|
+
elsif respond_to?(:to_str)
|
490
|
+
result << self
|
491
|
+
else
|
492
|
+
return result #only switch on
|
493
|
+
end
|
494
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
495
|
+
result
|
496
|
+
end
|
497
|
+
|
498
|
+
|
499
|
+
def on_cyan(string = nil)
|
500
|
+
result = ''
|
501
|
+
result << "[46m" if Term::ANSIColor.coloring?
|
502
|
+
if block_given?
|
503
|
+
result << yield
|
504
|
+
elsif string
|
505
|
+
result << string
|
506
|
+
elsif respond_to?(:to_str)
|
507
|
+
result << self
|
508
|
+
else
|
509
|
+
return result #only switch on
|
510
|
+
end
|
511
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
512
|
+
result
|
513
|
+
end
|
514
|
+
|
515
|
+
|
516
|
+
def on_white(string = nil)
|
517
|
+
result = ''
|
518
|
+
result << "[47m" if Term::ANSIColor.coloring?
|
519
|
+
if block_given?
|
520
|
+
result << yield
|
521
|
+
elsif string
|
522
|
+
result << string
|
523
|
+
elsif respond_to?(:to_str)
|
524
|
+
result << self
|
525
|
+
else
|
526
|
+
return result #only switch on
|
527
|
+
end
|
528
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
529
|
+
result
|
530
|
+
end
|
531
|
+
|
532
|
+
# Regular expression that is used to scan for ANSI-sequences while
|
533
|
+
# uncoloring strings.
|
534
|
+
COLORED_REGEXP = /\e\[([34][0-7]|[0-9])m/
|
535
|
+
|
536
|
+
# Returns an uncolored version of the string, that is all
|
537
|
+
# ANSI-sequences are stripped from the string.
|
538
|
+
def uncolored(string = nil) # :yields:
|
539
|
+
if block_given?
|
540
|
+
yield.gsub(COLORED_REGEXP, '')
|
541
|
+
elsif string
|
542
|
+
string.gsub(COLORED_REGEXP, '')
|
543
|
+
elsif respond_to?(:to_str)
|
544
|
+
gsub(COLORED_REGEXP, '')
|
545
|
+
else
|
546
|
+
''
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
550
|
+
module_function
|
551
|
+
|
552
|
+
# Returns an array of all Term::ANSIColor attributes as symbols.
|
553
|
+
def attributes
|
554
|
+
ATTRIBUTE_NAMES
|
555
|
+
end
|
556
|
+
extend self
|
557
|
+
end
|
558
|
+
end
|
data/app/string.rb
ADDED
data/lib/rm-wsse.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'motion-cocoapods'
|
2
|
+
require 'rm-digest'
|
3
|
+
|
4
|
+
unless defined?(Motion::Project::Config)
|
5
|
+
raise "This file must be requried within a RubyMotion project Rakefile."
|
6
|
+
end
|
7
|
+
|
8
|
+
Motion::Project::App.setup do |app|
|
9
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'rm-wsse/*.rb')).each do |file|
|
10
|
+
app.files.unshift(file)
|
11
|
+
end
|
12
|
+
|
13
|
+
app.pods do
|
14
|
+
pod 'Base64'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'rm-wsse/version'
|
19
|
+
|
20
|
+
class RmWsse
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class RmWsse
|
2
|
+
class << self
|
3
|
+
def wsse_header(user, password, date = nil, rnd = nil)
|
4
|
+
formatter = NSDateFormatter.new.tap do |f|
|
5
|
+
f.setDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZ")
|
6
|
+
end
|
7
|
+
|
8
|
+
date ||= NSDate.new
|
9
|
+
rnd ||= Random.new.rand
|
10
|
+
|
11
|
+
created = formatter.stringFromDate(date)
|
12
|
+
nonce = RmDigest::SHA1.hexdigest(created + rnd.to_s)
|
13
|
+
digest = RmDigest::SHA1.digest(nonce + created + password)
|
14
|
+
|
15
|
+
"UsernameToken Username=\"#{user}\", PasswordDigest=\"#{digest.base64String}\", Nonce=\"#{nonce.base64String}\", Created=\"#{created}\""
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/rm-wsse.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../lib/rm-wsse/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["Naoya Ito"]
|
5
|
+
gem.email = ["i.naoya@gmail.com"]
|
6
|
+
gem.description = %q{Creates WSSE authentication header}
|
7
|
+
gem.summary = %q{Creates WSSE authentication header}
|
8
|
+
gem.homepage = "https://github.com/naoya/rm-wsse"
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
12
|
+
gem.name = "rm-wsse"
|
13
|
+
gem.require_paths = ["lib"]
|
14
|
+
|
15
|
+
gem.version = RmWsse::VERSION
|
16
|
+
|
17
|
+
gem.add_development_dependency "rake"
|
18
|
+
gem.add_development_dependency "guard-motion"
|
19
|
+
|
20
|
+
gem.add_runtime_dependency "rm-digest"
|
21
|
+
gem.add_runtime_dependency "motion-cocoapods", '= 1.3.2'
|
22
|
+
gem.add_runtime_dependency "cocoapods", "= 0.20.2"
|
23
|
+
end
|
data/spec/00-redgreen.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Supported styles:
|
3
|
+
# :focused, :full, :original
|
4
|
+
# --------------
|
5
|
+
style = :full
|
6
|
+
# --------------
|
7
|
+
if Term.nil? || (style == :original)
|
8
|
+
if Term.nil?
|
9
|
+
puts "You need to get the RubyMotion-compatible ansiterm lib."
|
10
|
+
puts "You can find it at https://github.com/mdks/rm-regreen"
|
11
|
+
end
|
12
|
+
else
|
13
|
+
puts "Bacon Output Style: :#{style}".cyan
|
14
|
+
def color_for(error)
|
15
|
+
if error =~ /ERROR/
|
16
|
+
:red
|
17
|
+
elsif error =~ /MISSING/
|
18
|
+
:yellow
|
19
|
+
else
|
20
|
+
:red
|
21
|
+
end
|
22
|
+
end
|
23
|
+
if style == :full
|
24
|
+
module Bacon
|
25
|
+
module SpecDoxOutput
|
26
|
+
def handle_specification_begin(name)
|
27
|
+
puts "#{spaces + name}".bold
|
28
|
+
end
|
29
|
+
|
30
|
+
def handle_specification_end
|
31
|
+
puts if Counter[:context_depth] == 1
|
32
|
+
end
|
33
|
+
|
34
|
+
def handle_requirement_begin(description)
|
35
|
+
puts "#{spaces} - #{description}".magenta
|
36
|
+
end
|
37
|
+
|
38
|
+
def handle_requirement_end(error)
|
39
|
+
color = color_for(error)
|
40
|
+
if error.empty?
|
41
|
+
mark = "✓".green
|
42
|
+
msg = "This test has passed! Good job!".green
|
43
|
+
else
|
44
|
+
mark = "✗".send(color)
|
45
|
+
msg = "This test has not passed: #{error}!".send(color)
|
46
|
+
error_output = "[#{error}] \n BACKTRACE: #{ErrorLog}".send(color)
|
47
|
+
end
|
48
|
+
puts " [#{mark}] #{msg} \n #{error_output ||= ""}"
|
49
|
+
ErrorLog.clear
|
50
|
+
end
|
51
|
+
|
52
|
+
def handle_summary
|
53
|
+
puts "%d specifications (%d requirements), %d failures, %d errors" %
|
54
|
+
# if Backtraces
|
55
|
+
# print ErrorLog
|
56
|
+
# end
|
57
|
+
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
elsif style == :focused
|
62
|
+
module Bacon
|
63
|
+
module SpecDoxOutput
|
64
|
+
@focus = nil
|
65
|
+
|
66
|
+
def handle_specification_begin(name)
|
67
|
+
puts "#{spaces + name}".bold
|
68
|
+
end
|
69
|
+
|
70
|
+
def handle_specification_end
|
71
|
+
puts if Counter[:context_depth] == 1
|
72
|
+
end
|
73
|
+
|
74
|
+
def handle_requirement_begin(description)
|
75
|
+
@spec_description_cache = description
|
76
|
+
end
|
77
|
+
|
78
|
+
def handle_requirement_end(error)
|
79
|
+
if error.empty?
|
80
|
+
print ".".green
|
81
|
+
else
|
82
|
+
if @focus.nil?
|
83
|
+
@focus = @spec_description_cache
|
84
|
+
color = color_for(error)
|
85
|
+
print "\n#{spaces}[#{error}]".send(color)
|
86
|
+
print " - #{@focus}".magenta
|
87
|
+
print "\nBACKTRACE: #{ErrorLog}".send(color)
|
88
|
+
else
|
89
|
+
if error =~ /MISSING/
|
90
|
+
print "?".yellow
|
91
|
+
else
|
92
|
+
print "F".red
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def handle_summary
|
99
|
+
puts "%d specifications (%d requirements), %d failures, %d errors" %
|
100
|
+
# if Backtraces
|
101
|
+
# print ErrorLog
|
102
|
+
# end
|
103
|
+
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
describe "WSSE header" do
|
2
|
+
it "should be true" do
|
3
|
+
true.should == true
|
4
|
+
end
|
5
|
+
|
6
|
+
it "should return random WSSE header string" do
|
7
|
+
header = RmWsse.wsse_header("melody", "nelson")
|
8
|
+
header.should =~ /UsernameToken Username="melody"/
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return fixed WSSE header string" do
|
12
|
+
created = NSDate.alloc.initWithString("1977-09-18 12:34:56 +0900")
|
13
|
+
header = RmWsse.wsse_header("melody", "nelson", created, 100)
|
14
|
+
|
15
|
+
digest = 'cIYQOAtdYIAQhQv7KfEijYyLhoM='
|
16
|
+
nonce = 'YTVmNGZjMDgxNmYxMjNhYTc0MTJhNjMxOGY1NThmOGM0ZmYyMWQ5ZQ=='
|
17
|
+
|
18
|
+
header.should == "UsernameToken Username=\"melody\", PasswordDigest=\"#{digest}\", Nonce=\"#{nonce}\", Created=\"1977-09-18T12:34:56+0900\""
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rm-wsse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Naoya Ito
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: guard-motion
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rm-digest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: motion-cocoapods
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.3.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.3.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cocoapods
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.20.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.20.2
|
83
|
+
description: Creates WSSE authentication header
|
84
|
+
email:
|
85
|
+
- i.naoya@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .travis.yml
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- Guardfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- app/app.rb
|
99
|
+
- app/app_delegate.rb
|
100
|
+
- app/kernel.rb
|
101
|
+
- app/rm-ansiterm.rb
|
102
|
+
- app/string.rb
|
103
|
+
- lib/rm-wsse.rb
|
104
|
+
- lib/rm-wsse/rm-wsse.rb
|
105
|
+
- lib/rm-wsse/version.rb
|
106
|
+
- rm-wsse.gemspec
|
107
|
+
- spec/00-redgreen.rb
|
108
|
+
- spec/rm-wsse_spec.rb
|
109
|
+
homepage: https://github.com/naoya/rm-wsse
|
110
|
+
licenses: []
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.0.2
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Creates WSSE authentication header
|
132
|
+
test_files:
|
133
|
+
- spec/00-redgreen.rb
|
134
|
+
- spec/rm-wsse_spec.rb
|