somefixtures 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENCE +20 -0
- data/README.md +39 -0
- data/Rakefile +34 -0
- data/VERSION +0 -0
- data/lib/somefixtures/fixture.rb +57 -0
- data/lib/somefixtures.rb +4 -0
- data/somefixtures.gemspec +27 -0
- metadata +88 -0
data/LICENCE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Jason Watson
|
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.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
SomeFixtures
|
2
|
+
============
|
3
|
+
|
4
|
+
SomeFixtures was created to make local fixtures (sample data) for stubs by
|
5
|
+
specifying a fixture location which is then downloaded and saved to disk.
|
6
|
+
|
7
|
+
It was basically made to automate the task a little bit for me and deep down is
|
8
|
+
nothing more than a downward file transfer tool.
|
9
|
+
|
10
|
+
Install
|
11
|
+
-------
|
12
|
+
gem install somefixtures
|
13
|
+
|
14
|
+
Usage
|
15
|
+
-----
|
16
|
+
|
17
|
+
foo = Fixture.new(
|
18
|
+
:save_to => "/Users/jbw/project/spec/fixtures/",
|
19
|
+
:format => "json",
|
20
|
+
:base_uri => "http://github.com/api/v2/json",
|
21
|
+
:login => "jbw",
|
22
|
+
:token => "YOUR_AUTHENTICATION_API_TOKEN" )
|
23
|
+
|
24
|
+
foo.add("/user/search/jbw", "search")
|
25
|
+
foo.add("/user/show/jbw", "show_unauthenticated")
|
26
|
+
foo.add("/user/show/jbw", "show_authenticated", true)
|
27
|
+
foo.add("/user/show/jbw/following", "following")
|
28
|
+
foo.add("/user/show/jbw/followers", "followers")
|
29
|
+
|
30
|
+
foo.make_fixtures!
|
31
|
+
|
32
|
+
Licence
|
33
|
+
-------
|
34
|
+
MIT
|
35
|
+
|
36
|
+
TODO
|
37
|
+
----
|
38
|
+
* Make more generic
|
39
|
+
* Documentation
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rake/gempackagetask'
|
2
|
+
|
3
|
+
spec = Gem::Specification.new do |s|
|
4
|
+
s.name = 'somefixtures'
|
5
|
+
s.version = '0.0.1'
|
6
|
+
s.date = '2010-07-30'
|
7
|
+
s.description = "Testing fixture automator. Easies the pain of getting sample data for testing."
|
8
|
+
s.summary = s.description
|
9
|
+
|
10
|
+
s.authors = ["Jason Watson"]
|
11
|
+
s.email = "jbw@bw.cc"
|
12
|
+
|
13
|
+
s.files = %w[
|
14
|
+
CHANGELOG
|
15
|
+
LICENCE
|
16
|
+
README.markdown
|
17
|
+
Rakefile
|
18
|
+
VERSION
|
19
|
+
docs/
|
20
|
+
examples/
|
21
|
+
lib/somefixtures.rb
|
22
|
+
lib/somefixtures/fixture.rb
|
23
|
+
test/
|
24
|
+
somefixtures.gemspec
|
25
|
+
]
|
26
|
+
s.homepage = "http://github.com/jbw/somefixtures/"
|
27
|
+
s.require_paths = %w[lib]
|
28
|
+
s.rubyforge_project = 'somefixtures'
|
29
|
+
s.add_dependency('HTTParty', '>= 0.6.1' )
|
30
|
+
end
|
31
|
+
|
32
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
33
|
+
pkg.need_tar = true
|
34
|
+
end
|
data/VERSION
ADDED
File without changes
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'HTTParty'
|
2
|
+
|
3
|
+
module SomeFixtures
|
4
|
+
class Fixture
|
5
|
+
include HTTParty
|
6
|
+
format @format
|
7
|
+
|
8
|
+
def initialize fixture_info
|
9
|
+
@format = fixture_info[:format]
|
10
|
+
@base_uri = fixture_info[:base_uri]
|
11
|
+
@save_to = fixture_info[:save_to]
|
12
|
+
@login = fixture_info[:login]
|
13
|
+
@token = fixture_info[:token]
|
14
|
+
|
15
|
+
@fixtures = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def add query, name, authenticate = false
|
19
|
+
@fixtures.each_key { |key| print name == key ? "You have added \"#{key}\" for a file name already. Each filename must be unique!\n" : nil }
|
20
|
+
@fixtures[name] = { :query => query, :authenticate => authenticate }
|
21
|
+
end
|
22
|
+
|
23
|
+
def make_fixtures!
|
24
|
+
save (get @fixtures)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def get fixtures
|
29
|
+
responses = []
|
30
|
+
|
31
|
+
@fixtures.each_key do |name|
|
32
|
+
responses << self.class.get( @base_uri + @fixtures[name][:query], :query => (authenticated? name) )
|
33
|
+
end
|
34
|
+
|
35
|
+
responses
|
36
|
+
end
|
37
|
+
|
38
|
+
def authenticated? name
|
39
|
+
@authenticate = @fixtures[name][:authenticate];
|
40
|
+
auth_params
|
41
|
+
end
|
42
|
+
|
43
|
+
def save fixtures
|
44
|
+
name = @fixtures.keys
|
45
|
+
|
46
|
+
fixtures.each do |f|
|
47
|
+
File.new(@save_to + name.first + "." + @format, "w").puts f
|
48
|
+
name.shift
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def auth_params
|
53
|
+
if @authenticate; (@login.nil? ? {} : { :login => @login, :token => @token }); end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
data/lib/somefixtures.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'somefixtures'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.date = '2010-07-30'
|
5
|
+
s.description = "Testing fixture automator. Easies the pain of getting sample data for testing."
|
6
|
+
s.summary = s.description
|
7
|
+
|
8
|
+
s.authors = ["Jason Watson"]
|
9
|
+
s.email = "jbw@bw.cc"
|
10
|
+
|
11
|
+
s.files = %w[
|
12
|
+
LICENCE
|
13
|
+
README.md
|
14
|
+
Rakefile
|
15
|
+
VERSION
|
16
|
+
docs/
|
17
|
+
examples/
|
18
|
+
lib/somefixtures.rb
|
19
|
+
lib/somefixtures/fixture.rb
|
20
|
+
spec/
|
21
|
+
somefixtures.gemspec
|
22
|
+
]
|
23
|
+
s.homepage = "http://github.com/jbw/somefixtures/"
|
24
|
+
s.require_paths = %w[lib]
|
25
|
+
s.rubyforge_project = 'somefixtures'
|
26
|
+
s.add_dependency('httparty', '>= 0.6.1')
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: somefixtures
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jason Watson
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-07-30 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: httparty
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 5
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 6
|
33
|
+
- 1
|
34
|
+
version: 0.6.1
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Testing fixture automator. Easies the pain of getting sample data for testing.
|
38
|
+
email: jbw@bw.cc
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- LICENCE
|
47
|
+
- README.md
|
48
|
+
- Rakefile
|
49
|
+
- VERSION
|
50
|
+
- lib/somefixtures.rb
|
51
|
+
- lib/somefixtures/fixture.rb
|
52
|
+
- somefixtures.gemspec
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://github.com/jbw/somefixtures/
|
55
|
+
licenses: []
|
56
|
+
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: 3
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project: somefixtures
|
83
|
+
rubygems_version: 1.3.7
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Testing fixture automator. Easies the pain of getting sample data for testing.
|
87
|
+
test_files: []
|
88
|
+
|