enigmamachine 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +16 -11
  2. data/VERSION +1 -1
  3. data/enigmamachine.gemspec +1 -1
  4. metadata +3 -3
data/README.rdoc CHANGED
@@ -69,28 +69,33 @@ Programmatic requests in Ruby might look something like this:
69
69
  # enigma_client.rb:
70
70
 
71
71
  require 'rubygems'
72
- require 'base64'
73
- require 'net/http'
74
- require 'uri'
72
+ require 'httparty'
75
73
 
76
74
  class EnigmaClient
77
75
 
76
+ include HTTParty
77
+
78
+ base_uri "localhost:2002"
79
+
78
80
  def initialize (u, p)
79
- @username, @password = u, p
81
+ @auth = encode_credentials(u, p)
80
82
  end
81
83
 
82
84
  def post(path_to_video, encoder_id)
83
- request = {:body => {
84
- :video => {:file => path_to_video},
85
- :encoder_id => encoder_id
86
- }}
87
- Net::HTTP.post_form(
88
- URI.parse("http://#{@username}:#{@password}@localhost:2002/videos"),
89
- request)
85
+ self.class.post("/videos", {
86
+ :body => {:video => {:file => path_to_video}, :encoder_id => encoder_id},
87
+ :basic_auth => @auth})
88
+ end
89
+
90
+ private
91
+
92
+ def encode_credentials(username, password)
93
+ {:username => username, :password => password}
90
94
  end
91
95
 
92
96
  end
93
97
 
98
+
94
99
  # Let's use it!
95
100
  #
96
101
  irb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{enigmamachine}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["dave"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enigmamachine
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - dave