weary 0.4.1 → 0.4.3

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
@@ -29,7 +29,7 @@ You do have Rubygems right?
29
29
  class TwitterUser
30
30
  extend Weary
31
31
 
32
- on_domain "http://twitter.com/users/"
32
+ domain "http://twitter.com/users/"
33
33
 
34
34
  get "show" do |resource|
35
35
  resource.with = [:id, :user_id, :screen_name]
@@ -106,9 +106,9 @@ There are many ways to form URLs in Weary. You can define URLs for the entire cl
106
106
  class Foo
107
107
  extend Weary
108
108
 
109
- on_domain "http://foo.bar/"
110
- construct_url "<domain><resource>.<format>"
111
- as_format :xml
109
+ domain "http://foo.bar/"
110
+ url "<domain><resource>.<format>"
111
+ format :xml
112
112
 
113
113
  get "show_users"
114
114
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.3
data/examples/repo.rb CHANGED
@@ -6,8 +6,8 @@ class Repository
6
6
  @gh_user = "mwunsch"
7
7
  @gh_repo = "weary"
8
8
 
9
- on_domain "http://github.com/api/v2/"
10
- as_format :yaml
9
+ domain "http://github.com/api/v2/"
10
+ format :yaml
11
11
 
12
12
  get "show" do |r|
13
13
  r.url = "<domain><format>/repos/show/#{@gh_user}/#{@gh_repo}"
data/examples/status.rb CHANGED
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'weary')
3
3
  class Status
4
4
  extend Weary
5
5
 
6
- on_domain "http://twitter.com/statuses/"
6
+ domain "http://twitter.com/statuses/"
7
7
 
8
8
  get "user_timeline" do |resource|
9
9
  resource.requires = [:id]
data/lib/weary.rb CHANGED
@@ -37,24 +37,30 @@ module Weary
37
37
  req.parse
38
38
  end
39
39
 
40
- attr_reader :domain, :resources
40
+ attr_reader :resources
41
41
 
42
- # Sets the domain the resource is on.
42
+ # Sets the domain the resource is on or use it to retrieve a domain you've already set.
43
+ # It's a getter and a setter. It's an attribute!
43
44
  #
44
45
  # If the domain is not provided and you use a URL pattern that asks for it,
45
46
  # an exception will be raised.
46
- def on_domain(domain)
47
- parse_domain = URI.extract(domain)
48
- raise ArgumentError, 'The domain must be a URL.' if parse_domain.empty?
49
- @domain = parse_domain[0]
47
+ def domain(dom=nil)
48
+ raise ArgumentError, 'No domain provided' if (dom.nil? && @domain.nil?)
49
+ if (!dom.nil?)
50
+ parse_domain = URI.extract(dom)
51
+ raise ArgumentError, 'The domain must be a URL.' if parse_domain.empty?
52
+ @domain = parse_domain[0]
53
+ end
50
54
  return @domain
51
55
  end
56
+ alias on_domain domain
52
57
 
53
58
  # Sets a default format to make your Requests in.
54
59
  # Defaults to JSON.
55
- def as_format(format)
60
+ def format(format)
56
61
  @default_format = format
57
62
  end
63
+ alias as_format format
58
64
 
59
65
  # Construct a URL pattern for your resources to follow.
60
66
  # You can use flags like
@@ -62,24 +68,28 @@ module Weary
62
68
  # * <format>
63
69
  # * <resource>
64
70
  # To aid your construction. Defaults to "<domain><resource>.<format>"
65
- def construct_url(pattern)
71
+ def url(pattern)
66
72
  @url_pattern = pattern.to_s
67
73
  end
74
+ alias construct_url url
68
75
 
69
- def authenticates_with(username,password)
76
+ def authenticates(username,password)
70
77
  @username = username
71
78
  @password = password
72
79
  return nil
73
80
  end
81
+ alias authenticates_with authenticates
74
82
 
75
- def always_with(params)
83
+ def with(params)
76
84
  @always_with = params
77
85
  end
86
+ alias always_with with
78
87
 
79
88
  # Set custom Headers for your Request
80
- def set_headers(headers)
89
+ def headers(headers)
81
90
  @headers = headers
82
91
  end
92
+ alias set_headers headers
83
93
 
84
94
  # Declare a resource. Use it with a block to setup the resource
85
95
  #
@@ -54,10 +54,10 @@ module Weary
54
54
  @requires.each { |key| params[key] = nil unless params.has_key?(key) }
55
55
  @with = params
56
56
  else
57
- unless @requires.nil?
58
- @with = params.collect {|x| x.to_sym} | @requires
59
- else
57
+ if @requires.nil?
60
58
  @with = params.collect {|x| x.to_sym}
59
+ else
60
+ @with = params.collect {|x| x.to_sym} | @requires
61
61
  end
62
62
  end
63
63
  end
data/weary.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{weary}
5
- s.version = "0.4.1"
5
+ s.version = "0.4.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Mark Wunsch"]
9
- s.date = %q{2009-06-24}
9
+ s.date = %q{2009-06-30}
10
10
  s.description = %q{The Weary need REST: a tiny DSL that makes the consumption of RESTful web services simple.}
11
11
  s.email = %q{mark@markwunsch.com}
12
12
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Wunsch
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-24 00:00:00 -04:00
12
+ date: 2009-06-30 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency