zemax 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +4 -0
- data/LICENSE +20 -20
- data/README.rdoc +26 -17
- data/Rakefile +16 -57
- data/VERSION +1 -1
- data/bin/zemax +7 -0
- data/lib/zemax.rb +32 -1
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +18 -190
- data/spec/zemax_spec.rb +7 -0
- data/tasks/common.rake +11 -0
- data/tasks/gem.rake +11 -0
- metadata +41 -46
- data/.document +0 -5
- data/.gitignore +0 -21
- data/bin/git_hub +0 -7
- data/features/step_definitions/zemax_steps.rb +0 -0
- data/features/support/env.rb +0 -4
- data/features/zemax.feature +0 -9
- data/lib/git_hub.rb +0 -48
- data/lib/git_hub/api.rb +0 -39
- data/lib/git_hub/base.rb +0 -50
- data/lib/git_hub/repo.rb +0 -155
- data/spec/git_hub/api_spec.rb +0 -99
- data/spec/git_hub/base_spec.rb +0 -47
- data/spec/git_hub/repo_spec.rb +0 -247
- data/spec/stubs/repos/create.res +0 -24
- data/spec/stubs/repos/delete/new_repo.1.res +0 -14
- data/spec/stubs/repos/delete/new_repo.2.res +0 -14
- data/spec/stubs/repos/search/joe+repo.res +0 -54
- data/spec/stubs/repos/show/joe007.res +0 -44
- data/spec/stubs/repos/show/joe007/err_repo.res +0 -14
- data/spec/stubs/repos/show/joe007/fine_repo.res +0 -24
- data/spec/stubs/repos/show/joe007/new_repo.res +0 -24
- data/zemax.gemspec +0 -80
data/HISTORY
ADDED
data/LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c)
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2010 Arvicco
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,17 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
==
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
*
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
==zemax
|
2
|
+
by: Arvicco
|
3
|
+
url: http://github.com/arvicco/zemax
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
FIXME (describe your package)
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* FIXME (list of features or problems)
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
FIXME (code sample of usage)
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
* FIXME (list of requirements)
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
* FIXME (sudo gem install, anything else)
|
24
|
+
|
25
|
+
== LICENSE:
|
26
|
+
Copyright (c) 2010 Arvicco. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,57 +1,16 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
|
4
|
-
begin
|
5
|
-
require '
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
Jeweler::GemcutterTasks.new
|
18
|
-
rescue LoadError
|
19
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
-
end
|
21
|
-
|
22
|
-
require 'spec/rake/spectask'
|
23
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
-
spec.libs << 'lib' << 'spec'
|
25
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
-
end
|
27
|
-
|
28
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
-
spec.libs << 'lib' << 'spec'
|
30
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
-
spec.rcov = true
|
32
|
-
end
|
33
|
-
|
34
|
-
task :spec => :check_dependencies
|
35
|
-
|
36
|
-
begin
|
37
|
-
require 'cucumber/rake/task'
|
38
|
-
Cucumber::Rake::Task.new(:features)
|
39
|
-
|
40
|
-
task :features => :check_dependencies
|
41
|
-
rescue LoadError
|
42
|
-
task :features do
|
43
|
-
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
task :default => :spec
|
48
|
-
|
49
|
-
require 'rake/rdoctask'
|
50
|
-
Rake::RDocTask.new do |rdoc|
|
51
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
52
|
-
|
53
|
-
rdoc.rdoc_dir = 'rdoc'
|
54
|
-
rdoc.title = "zemax #{version}"
|
55
|
-
rdoc.rdoc_files.include('README*')
|
56
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
-
end
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require "zemax"
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rake'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
gem 'rake', '~> 0.8.3.1'
|
9
|
+
require 'rake'
|
10
|
+
end
|
11
|
+
|
12
|
+
# Load rakefile tasks
|
13
|
+
Dir['tasks/*.rake'].sort.each { |file| load file }
|
14
|
+
|
15
|
+
#task :default => 'test:run'
|
16
|
+
#task 'gem:release' => 'test:run'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/zemax
ADDED
data/lib/zemax.rb
CHANGED
@@ -1 +1,32 @@
|
|
1
|
-
|
1
|
+
module Zemax
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
VERSION_FILE = Pathname.new(__FILE__).dirname + '../VERSION' # :nodoc:
|
5
|
+
VERSION = VERSION_FILE.exist? ? VERSION_FILE.read.strip : nil
|
6
|
+
|
7
|
+
# Require ruby source file(s). Lib should be either file name or glob
|
8
|
+
# Accepts following options:
|
9
|
+
# :file:: Libs are required relative to this file - defaults to __FILE__
|
10
|
+
# :dir:: Required libs are located under this dir name - defaults to gem name
|
11
|
+
#
|
12
|
+
def self.require_lib( lib, opts={} )
|
13
|
+
file = Pathname.new(opts[:file] || __FILE__)
|
14
|
+
name = file.dirname + (opts[:dir] || file.basename('.*')) + lib.gsub(/(?<!.rb)$/, '.rb')
|
15
|
+
Pathname.glob(name.to_s).sort.each {|rb| require rb}
|
16
|
+
end
|
17
|
+
|
18
|
+
# Requires ruby source file(s). Accepts either single name or Array of filenames/globs
|
19
|
+
# Accepts following options:
|
20
|
+
# :file:: Libs are required relative to this file - defaults to __FILE__
|
21
|
+
# :dir:: Required libs are located under this dir name - defaults to gem name
|
22
|
+
#
|
23
|
+
def self.require_libs( libs, opts={} )
|
24
|
+
[libs].flatten.each {|lib| require_lib lib, opts }
|
25
|
+
end
|
26
|
+
|
27
|
+
end # module Zemax
|
28
|
+
|
29
|
+
# Require all ruby source files located under directory lib/zemax
|
30
|
+
# If you need files in specific order, you should specify it here before the glob
|
31
|
+
Zemax.require_libs %W[**/*]
|
32
|
+
|
data/spec/spec.opts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
--color
|
1
|
+
--color
|
2
2
|
--format nested
|
data/spec/spec_helper.rb
CHANGED
@@ -1,190 +1,18 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
f.lines.to_a[line-1].gsub( Regexp.new('(spec.*?{)|(use.*?{)|}'), '' ).lstrip.rstrip
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
Spec::Runner.configure do |config|
|
25
|
-
# Add my macros
|
26
|
-
config.extend(SpecMacros)
|
27
|
-
end
|
28
|
-
|
29
|
-
module GitHubTest
|
30
|
-
|
31
|
-
# Test related Constants:
|
32
|
-
TEST_PROJECT = 'GitHub'
|
33
|
-
TEST_STRING = 'This is test string'
|
34
|
-
|
35
|
-
# Checks that given block does not raise any errors
|
36
|
-
def use
|
37
|
-
lambda {yield}.should_not raise_error
|
38
|
-
end
|
39
|
-
|
40
|
-
# Returns empty block (for use in spec descriptions)
|
41
|
-
def any_block
|
42
|
-
lambda {|*args| args}
|
43
|
-
end
|
44
|
-
|
45
|
-
# Extract response from file
|
46
|
-
def response_from_file(path)
|
47
|
-
filename = File.join(File.dirname(__FILE__), 'stubs', path + '.res')
|
48
|
-
unless File.exists?(filename) && !File.directory?(filename)
|
49
|
-
raise "No stub file #{filename}. To obtain it use:\n#{curl_string(path, filename)}"
|
50
|
-
end
|
51
|
-
filename
|
52
|
-
end
|
53
|
-
|
54
|
-
# Extract response body from file
|
55
|
-
def body_from_file(path)
|
56
|
-
File.read(response_from_file(path)).gsub(/.*\n\n/m, '')
|
57
|
-
end
|
58
|
-
|
59
|
-
def curl_string(path, filename)
|
60
|
-
auth_string = api.authenticated? ? "?login=#{api.auth['login']}&token=#{api.auth['token']}" : ""
|
61
|
-
"curl -i #{github_yaml}#{path}#{auth_string} > #{filename}"
|
62
|
-
end
|
63
|
-
|
64
|
-
# Stubs github server, with options:
|
65
|
-
# :host:: Host name - default 'github.com'
|
66
|
-
# :port:: Port - default 80
|
67
|
-
def stub_server(options={})
|
68
|
-
server = Net::HTTP.new(options[:host] ||'github.com', options[:port] || 80)
|
69
|
-
Net::HTTP.stub!(:new).and_return(server)
|
70
|
-
server
|
71
|
-
end
|
72
|
-
|
73
|
-
# Stubs http request, with options:
|
74
|
-
# :path:: Request path - default '/api/v2/yaml/repos/create'
|
75
|
-
# :get:: Indicates that request is get, otherwise post
|
76
|
-
def stub_req(options={})
|
77
|
-
path = options[:path] || '/api/v2/yaml/repos/create'
|
78
|
-
options[:get] ? Net::HTTP::Get.new(path) : Net::HTTP::Post.new(path)
|
79
|
-
end
|
80
|
-
|
81
|
-
def stub_server_and_req(options = {})
|
82
|
-
[stub_server(options), stub_req(options)]
|
83
|
-
end
|
84
|
-
|
85
|
-
# Turns string into appropriate class constant, returns nil if class not found
|
86
|
-
def classify name
|
87
|
-
klass = name.split("::").inject(Kernel) {|klass, const_name| klass.const_get const_name }
|
88
|
-
klass.is_a?(Class) ? klass : nil
|
89
|
-
rescue NameError
|
90
|
-
nil
|
91
|
-
end
|
92
|
-
|
93
|
-
# Builds fake HTTP response from a given options Hash. Accepts options:
|
94
|
-
# :klass:: Response class, default - Net::HTTPOK
|
95
|
-
# :http_version:: HTTP version - default 1.1
|
96
|
-
# :code:: Response return code - default 200
|
97
|
-
# :message:: Response message - default 'OK'
|
98
|
-
# :status:: [code, message] pair as one option
|
99
|
-
# :body:: Response body - default ''
|
100
|
-
# TODO: make it more lifelike using StringIO, instead of just stubbing :body
|
101
|
-
def build_response(options={})
|
102
|
-
code = options[:status] ? options[:status].first : options[:code] || 200
|
103
|
-
message = options[:status] ? options[:status].last : options[:message] || 'OK'
|
104
|
-
version = options[:http_version] || 1.1
|
105
|
-
resp = (options[:klass] || Net::HTTPOK).new(code, version, message)
|
106
|
-
resp.stub!(:body).and_return(options[:body] || '')
|
107
|
-
resp
|
108
|
-
end
|
109
|
-
|
110
|
-
# Expects request of certain method(:get, :post, ... :any) to specific uri (given as a String, URI or Regexp),
|
111
|
-
# (optionally) matches expected query keys with actuals and handles request and response according to options.
|
112
|
-
# In addition to build_response options (:klass, :http_version, :code, :message, :status, :body), it supports:
|
113
|
-
# :expected_keys:: Hash of expected query keys(if value is not important, :key => :any)
|
114
|
-
# :response:: Use this ready-made response object instead of building response
|
115
|
-
# :exception:: Raise this Exception object instead of response
|
116
|
-
# If you expect multiple requests to the same uri, options may also be an Array containing a list of the
|
117
|
-
# above-described Hashes - requests will be expected in the same order they appear in the Array
|
118
|
-
def expects(method, uri, options={})
|
119
|
-
@github ||= stub_server
|
120
|
-
opts = options.is_a?(Array) ? options.shift : options # may be a single options Hash or Array of Hashes
|
121
|
-
@github.should_receive(:request) do |req|
|
122
|
-
case method # match expected request method to actual
|
123
|
-
when :any
|
124
|
-
Net::HTTPRequest
|
125
|
-
when Class
|
126
|
-
method
|
127
|
-
when Symbol, String
|
128
|
-
classify('Net::HTTP::' + method.to_s.capitalize)
|
129
|
-
end.should === req
|
130
|
-
case uri # match expected uri to actual
|
131
|
-
when URI::HTTP, URI::HTTPS
|
132
|
-
uri.path
|
133
|
-
when String
|
134
|
-
URI.parse(uri).path
|
135
|
-
when Regexp
|
136
|
-
uri
|
137
|
-
end.should === req.path
|
138
|
-
if opts[:expected_keys] # match expected request query keys to actual keys
|
139
|
-
actuals = CGI::parse(req.body)
|
140
|
-
opts[:expected_keys].each do |key, val|
|
141
|
-
actuals.should have_key key.to_s
|
142
|
-
actual = actuals[key.to_s]
|
143
|
-
actual = actual.first if actual.size == 1 # if only one array element, extract it
|
144
|
-
case val # match expected key value to actual
|
145
|
-
when :any
|
146
|
-
when Class, Regexp, String
|
147
|
-
val.should === actual
|
148
|
-
else
|
149
|
-
val.to_s.should === actual
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
expects(method, uri, options) if options.is_a?(Array) && !options.empty? # expect next request in Array
|
154
|
-
raise opts[:exception] if opts[:exception] && opts[:exception].kind_of?(Exception)
|
155
|
-
opts[:response] || build_response(opts)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
# Extends path to uri, registers it with FakeWeb with stub file at stubs/path as a response
|
160
|
-
# If block is given, yields to block and checks that registered uri was hit during block execution
|
161
|
-
def expect(method, path)
|
162
|
-
case path
|
163
|
-
when Regexp.new(github_yaml)
|
164
|
-
uri = path
|
165
|
-
file = path.sub(github_yaml, '')
|
166
|
-
else
|
167
|
-
uri = github_yaml + path
|
168
|
-
file = path
|
169
|
-
end
|
170
|
-
FakeWeb.register_uri(method, uri, :response=>response_from_file(file))
|
171
|
-
if block_given?
|
172
|
-
yield
|
173
|
-
FakeWeb.should have_requested(method, uri)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
# Auth for joe
|
178
|
-
def joe_auth
|
179
|
-
{'login' => 'joe007', 'token' => 'b937c8e7ea5a5b47f94eafa39b1e0462'}
|
180
|
-
end
|
181
|
-
|
182
|
-
def github_yaml
|
183
|
-
'http://github.com/api/v2/yaml'
|
184
|
-
end
|
185
|
-
|
186
|
-
def api
|
187
|
-
GitHub::Api.instance
|
188
|
-
end
|
189
|
-
|
190
|
-
end # module GithubTest
|
1
|
+
require 'zemax'
|
2
|
+
require 'spec'
|
3
|
+
require 'spec/autorun'
|
4
|
+
|
5
|
+
Spec::Runner.configure do |config|
|
6
|
+
# == Mock Framework
|
7
|
+
#
|
8
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
9
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
10
|
+
#
|
11
|
+
# config.mock_with :mocha
|
12
|
+
# config.mock_with :flexmock
|
13
|
+
# config.mock_with :rr
|
14
|
+
end
|
15
|
+
|
16
|
+
module ZemaxTest
|
17
|
+
|
18
|
+
end # module ZemaxTest
|
data/spec/zemax_spec.rb
ADDED
data/tasks/common.rake
ADDED