somefixtures 0.1.1 → 0.1.5

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.
data/README.md CHANGED
@@ -14,17 +14,17 @@ Install
14
14
  Usage
15
15
  -----
16
16
  foo = Fixture.new(
17
- :save_to => "/Users/jbw/Desktop/",
18
- :format => "json",
19
- :base_uri => "http://github.com/api/v2/json",
20
- :login => "jbw",
21
- :token => "d6c339d410e3e35917f3c40caba8f241" )
17
+ :save_to => "/Users/jbw/Desktop/",
18
+ :format => "json"
19
+ :base_uri => "http://github.com/api/v2/json",
20
+ :login => "jbw",
21
+ :token => "account_password" )
22
22
 
23
23
  foo.add(:get, "/user/search/jbw", "search")
24
24
  foo.add_get("/user/search/jbw", "search")
25
25
 
26
26
  foo.add_get("/user/show/jbw", "show_unauthenticated")
27
- foo.add_get("/user/show/jbw", "show_authenticated", true)
27
+ foo.add_get("/user/show", "show_authenticated", true)
28
28
  foo.add_get("/user/show/jbw/followers", "followers")
29
29
 
30
30
  foo.add(:post, "/user/follow/jbw", "follow", true)
@@ -40,3 +40,4 @@ TODO
40
40
  ----
41
41
  * Make more generic
42
42
  * Documentation
43
+
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rake/gempackagetask'
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = 'somefixtures'
5
- s.version = '0.0.1'
5
+ s.version = '0.1.5'
6
6
  s.date = '2010-07-30'
7
7
  s.description = "Testing fixture automator. Easies the pain of getting sample data for testing."
8
8
  s.summary = s.description
@@ -26,7 +26,6 @@ spec = Gem::Specification.new do |s|
26
26
  s.homepage = "http://github.com/jbw/somefixtures/"
27
27
  s.require_paths = %w[lib]
28
28
  s.rubyforge_project = 'somefixtures'
29
- s.add_dependency('httparty', '>= 0.6.1' )
30
29
  end
31
30
 
32
31
  Rake::GemPackageTask.new(spec) do |pkg|
data/lib/somefixtures.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'HTTParty'
2
1
 
3
2
  Dir[File.join(File.dirname(__FILE__), "somefixtures/*.rb")].each { |m| require m }
4
3
 
@@ -1,9 +1,5 @@
1
- require 'HTTParty'
2
-
3
1
  module SomeFixtures
4
2
  class Fixture
5
- include HTTParty
6
- format @format
7
3
 
8
4
  def initialize fixture_info
9
5
  @format = fixture_info[:format]
@@ -22,7 +18,7 @@ module SomeFixtures
22
18
 
23
19
 
24
20
  def make_fixtures!
25
- save (query)
21
+ save query
26
22
  end
27
23
 
28
24
  def add_post(*args); add(:post, *args) end
@@ -41,20 +37,40 @@ module SomeFixtures
41
37
  end
42
38
  responses
43
39
  end
44
-
40
+
41
+ def authenticated? name
42
+ @authenticate = @fixtures[name][:authenticate];
43
+ auth_params
44
+ end
45
+
45
46
  def get name
46
- self.class.get( @base_uri + @fixtures[name][:query], :query => (authenticated? name) )
47
+ Net::HTTP.start((split_uri @base_uri)[1]) do |http|
48
+ req = Net::HTTP::Get.new((split_uri @base_uri)[2] + @fixtures[name][:query])
49
+ if @fixtures[name][:authenticate] == true
50
+ req.basic_auth (authenticated? name)[:login], (authenticated? name)[:token]
51
+ else
52
+ req.basic_auth @login, @token
53
+ end
54
+ response = http.request(req)
55
+ response.body
56
+ end
47
57
  end
48
58
 
49
59
  def post name
50
- self.class.post( @base_uri + @fixtures[name][:query], :query => (authenticated? name) )
60
+ Net::HTTP.start((split_uri @base_uri)[1]) do |http|
61
+ req = Net::HTTP::Post.new((split_uri @base_uri)[2] + @fixtures[name][:query])
62
+ req.basic_auth @login, @token
63
+ response = http.request(req)
64
+ response.body
65
+ end
51
66
  end
52
67
 
53
- def authenticated? name
54
- @authenticate = @fixtures[name][:authenticate];
55
- auth_params
68
+ def split_uri uri
69
+ if uri.match(/(http:\/\/)([a-zA-Z.]+)([a-zA-Z\d\/]+)/)
70
+ [$1, $2, $3]
71
+ end
56
72
  end
57
-
73
+
58
74
  def save fixtures
59
75
  name = @fixtures.keys
60
76
 
data/somefixtures.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'somefixtures'
3
- s.version = '0.1.1'
3
+ s.version = '0.1.5'
4
4
  s.date = '2010-07-30'
5
5
  s.description = "Testing fixture automator. Easies the pain of getting sample data for testing."
6
6
  s.summary = s.description
@@ -23,5 +23,4 @@ Gem::Specification.new do |s|
23
23
  s.homepage = "http://github.com/jbw/somefixtures/"
24
24
  s.require_paths = %w[lib]
25
25
  s.rubyforge_project = 'somefixtures'
26
- s.add_dependency('httparty', '>= 0.6.1')
27
26
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: somefixtures
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Watson
@@ -17,23 +17,8 @@ cert_chain: []
17
17
 
18
18
  date: 2010-07-30 00:00:00 +01:00
19
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
20
+ dependencies: []
21
+
37
22
  description: Testing fixture automator. Easies the pain of getting sample data for testing.
38
23
  email: jbw@bw.cc
39
24
  executables: []