noms-command 0.5.0
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 +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE +191 -0
- data/README.rst +376 -0
- data/ROADMAP.rst +127 -0
- data/Rakefile +49 -0
- data/TODO.rst +7 -0
- data/bin/noms2 +20 -0
- data/fixture/dnc.rb +120 -0
- data/fixture/identity +5 -0
- data/fixture/public/dnc.json +22 -0
- data/fixture/public/echo.json +7 -0
- data/fixture/public/files/data.json +12 -0
- data/fixture/public/files/foo.json +2 -0
- data/fixture/public/lib/dnc.js +81 -0
- data/fixture/public/lib/noms-args.js +13 -0
- data/fixture/public/lib/showopt.js +18 -0
- data/fixture/public/location.json +8 -0
- data/fixture/public/showopt.json +15 -0
- data/fixture/rig2json +21 -0
- data/lib/noms/command/application.rb +204 -0
- data/lib/noms/command/auth/identity.rb +62 -0
- data/lib/noms/command/auth.rb +117 -0
- data/lib/noms/command/base.rb +22 -0
- data/lib/noms/command/document.rb +59 -0
- data/lib/noms/command/error.rb +11 -0
- data/lib/noms/command/formatter.rb +178 -0
- data/lib/noms/command/urinion/data.rb +63 -0
- data/lib/noms/command/urinion.rb +29 -0
- data/lib/noms/command/useragent.rb +134 -0
- data/lib/noms/command/version.rb +7 -0
- data/lib/noms/command/window.rb +95 -0
- data/lib/noms/command/xmlhttprequest.rb +181 -0
- data/lib/noms/command.rb +107 -0
- data/noms-command.gemspec +30 -0
- data/spec/01noms-command_spec.rb +30 -0
- data/spec/02noms-command.sh +31 -0
- data/spec/03application_spec.rb +47 -0
- data/spec/04application_spec.rb +61 -0
- data/spec/05formatter_spec.rb +195 -0
- data/spec/06urinion_data.rb +20 -0
- data/spec/07js_spec.rb +87 -0
- data/spec/08xhr_spec.rb +209 -0
- data/spec/09bookmarks_spec.rb +60 -0
- data/spec/10auth_spec.rb +33 -0
- data/spec/spec_helper.rb +40 -0
- metadata +228 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
require 'noms/command'
|
7
|
+
|
8
|
+
describe NOMS::Command do
|
9
|
+
|
10
|
+
before(:all) do
|
11
|
+
# An application which echoes all arguments, not just argument arguments
|
12
|
+
setup_fixture 'test'
|
13
|
+
@url = %q(data:application/json,{"$doctype":"noms-v2","$script":["document.body = document.argv.join(' ')"],"$body":[]})
|
14
|
+
FileUtils.mkdir_p 'test/etc/noms' unless File.directory? 'test/etc/noms'
|
15
|
+
File.open('test/etc/noms/bookmarks.json', 'w') { |fh| fh.puts({'echo1' => @url}.to_json) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.run' do
|
19
|
+
|
20
|
+
context 'with noms-v2 documents' do
|
21
|
+
|
22
|
+
it "should set argv[0]" do
|
23
|
+
expect {
|
24
|
+
NOMS::Command.run [@url, 'one', 'two', 'three']
|
25
|
+
}.to output("#{@url} one two three\n").to_stdout
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should parse initial options" do
|
29
|
+
expect {
|
30
|
+
NOMS::Command.run ['--bookmarks=/dev/null', @url, 'one', 'two', 'three']
|
31
|
+
}.to output("#{@url} one two three\n").to_stdout
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should leave post-arg options alone" do
|
35
|
+
expect {
|
36
|
+
NOMS::Command.run ['--bookmarks=/dev/null', @url, '--command-opt', 'one']
|
37
|
+
}.to output("#{@url} --command-opt one\n").to_stdout
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should honor bookmarks" do
|
41
|
+
expect {
|
42
|
+
NOMS::Command.run ['--bookmarks=test/etc/noms/bookmarks.json',
|
43
|
+
'echo1', 'one', 'two', 'three']
|
44
|
+
}.to output("echo1 one two three\n").to_stdout
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should honor /" do
|
48
|
+
expect {
|
49
|
+
NOMS::Command.run ['--bookmarks=test/etc/noms/bookmarks.json',
|
50
|
+
'echo1/special', 'one', 'two', 'three']
|
51
|
+
}.to output("echo1/special one two three\n").to_stdout
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|
data/spec/10auth_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "NOMS::Command::Application" do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
setup_fixture
|
9
|
+
start_server
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:all) do
|
13
|
+
stop_server
|
14
|
+
teardown_fixture
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".new" do
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
@app = NOMS::Command::Application.
|
21
|
+
new('http://localhost:8787/auth/dnc.json', ['dnc'])
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# it "prompts for authentication" do
|
26
|
+
# expect {
|
27
|
+
# @app.fetch!
|
28
|
+
# }.to output(Regexp.new 'Authorization Required at http://localhost:8787').to_stdout
|
29
|
+
# end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
def server_running?(pidfile="test/dnc.pid")
|
6
|
+
begin
|
7
|
+
Process.kill 0, File.read(pidfile).to_i
|
8
|
+
true
|
9
|
+
rescue Errno::ESRCH, Errno::ENOENT
|
10
|
+
false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def setup_fixture(dir='test')
|
15
|
+
system "cp -R fixture #{dir}" unless File.directory? dir
|
16
|
+
end
|
17
|
+
|
18
|
+
def start_server(dir='test')
|
19
|
+
unless server_running? "#{dir}/dnc.pid"
|
20
|
+
system "sh -c '#{RbConfig.ruby} #{dir}/dnc.rb >#{dir}/dnc.out 2>&1 &'"
|
21
|
+
sleep 2
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def stop_server(dir='test')
|
26
|
+
if server_running? "#{dir}/dnc.pid"
|
27
|
+
begin
|
28
|
+
Process.kill 'TERM', File.read("#{dir}/dnc.pid").to_i
|
29
|
+
sleep 2
|
30
|
+
rescue Errno::ESRCH
|
31
|
+
end
|
32
|
+
FileUtils.rm "#{dir}/dnc.pid"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def teardown_fixture(dir='test')
|
37
|
+
if File.directory? dir
|
38
|
+
FileUtils.rm_r dir
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: noms-command
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremy Brinkley
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: therubyracer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
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: mime-types
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: httpclient
|
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: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: trollop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: highline
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bundler
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.7'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.7'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '10.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '10.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: sinatra
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description:
|
140
|
+
email:
|
141
|
+
- jbrinkley@evernote.com
|
142
|
+
executables:
|
143
|
+
- noms2
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- .gitignore
|
148
|
+
- Gemfile
|
149
|
+
- LICENSE
|
150
|
+
- README.rst
|
151
|
+
- ROADMAP.rst
|
152
|
+
- Rakefile
|
153
|
+
- TODO.rst
|
154
|
+
- bin/noms2
|
155
|
+
- fixture/dnc.rb
|
156
|
+
- fixture/identity
|
157
|
+
- fixture/public/dnc.json
|
158
|
+
- fixture/public/echo.json
|
159
|
+
- fixture/public/files/data.json
|
160
|
+
- fixture/public/files/foo.json
|
161
|
+
- fixture/public/lib/dnc.js
|
162
|
+
- fixture/public/lib/noms-args.js
|
163
|
+
- fixture/public/lib/showopt.js
|
164
|
+
- fixture/public/location.json
|
165
|
+
- fixture/public/showopt.json
|
166
|
+
- fixture/rig2json
|
167
|
+
- lib/noms/command.rb
|
168
|
+
- lib/noms/command/application.rb
|
169
|
+
- lib/noms/command/auth.rb
|
170
|
+
- lib/noms/command/auth/identity.rb
|
171
|
+
- lib/noms/command/base.rb
|
172
|
+
- lib/noms/command/document.rb
|
173
|
+
- lib/noms/command/error.rb
|
174
|
+
- lib/noms/command/formatter.rb
|
175
|
+
- lib/noms/command/urinion.rb
|
176
|
+
- lib/noms/command/urinion/data.rb
|
177
|
+
- lib/noms/command/useragent.rb
|
178
|
+
- lib/noms/command/version.rb
|
179
|
+
- lib/noms/command/window.rb
|
180
|
+
- lib/noms/command/xmlhttprequest.rb
|
181
|
+
- noms-command.gemspec
|
182
|
+
- spec/01noms-command_spec.rb
|
183
|
+
- spec/02noms-command.sh
|
184
|
+
- spec/03application_spec.rb
|
185
|
+
- spec/04application_spec.rb
|
186
|
+
- spec/05formatter_spec.rb
|
187
|
+
- spec/06urinion_data.rb
|
188
|
+
- spec/07js_spec.rb
|
189
|
+
- spec/08xhr_spec.rb
|
190
|
+
- spec/09bookmarks_spec.rb
|
191
|
+
- spec/10auth_spec.rb
|
192
|
+
- spec/spec_helper.rb
|
193
|
+
homepage: http://github.com/en-jbrinkley/noms-command
|
194
|
+
licenses:
|
195
|
+
- Apache-2
|
196
|
+
metadata: {}
|
197
|
+
post_install_message:
|
198
|
+
rdoc_options: []
|
199
|
+
require_paths:
|
200
|
+
- lib
|
201
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
202
|
+
requirements:
|
203
|
+
- - '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - '>='
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '0'
|
211
|
+
requirements: []
|
212
|
+
rubyforge_project:
|
213
|
+
rubygems_version: 2.0.14
|
214
|
+
signing_key:
|
215
|
+
specification_version: 4
|
216
|
+
summary: Interpreter for server-defined command-line interfaces
|
217
|
+
test_files:
|
218
|
+
- spec/01noms-command_spec.rb
|
219
|
+
- spec/02noms-command.sh
|
220
|
+
- spec/03application_spec.rb
|
221
|
+
- spec/04application_spec.rb
|
222
|
+
- spec/05formatter_spec.rb
|
223
|
+
- spec/06urinion_data.rb
|
224
|
+
- spec/07js_spec.rb
|
225
|
+
- spec/08xhr_spec.rb
|
226
|
+
- spec/09bookmarks_spec.rb
|
227
|
+
- spec/10auth_spec.rb
|
228
|
+
- spec/spec_helper.rb
|