placid 0.0.5 → 0.0.6

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/History.md CHANGED
@@ -1,6 +1,12 @@
1
1
  Placid History
2
2
  ==============
3
3
 
4
+ 0.0.6
5
+ -----
6
+
7
+ - Rename #url to #get_url to avoid conflicts with `url` fields
8
+
9
+
4
10
  0.0.5
5
11
  -----
6
12
 
data/README.md CHANGED
@@ -21,7 +21,7 @@ Define a subclass with the name of your REST model:
21
21
  class Person < Placid::Model
22
22
  end
23
23
 
24
- and you'll get these class methods, and their REST equivalents:
24
+ and you'll get these class methods, and their REST equivalents, automatically:
25
25
 
26
26
  Person.list # GET /people
27
27
  Person.create(attrs) # POST /person (attrs)
@@ -43,9 +43,10 @@ different field name, you can specify it like this:
43
43
  unique_id :email
44
44
  end
45
45
 
46
- The `Placid::Model` base class includes helper methods for basic HTTP requests.
47
- You can use these from any model instance, or call them from custom methods you
48
- define on your model. For example:
46
+ The `Placid::Model` base class includes helper methods for basic HTTP requests,
47
+ the most important of which is `request`. You can use these from any model
48
+ instance, or call them from custom methods you define on your model. For
49
+ example:
49
50
 
50
51
  class Person < Placid::Model
51
52
  unique_id :email
@@ -57,8 +58,12 @@ define on your model. For example:
57
58
 
58
59
  jenny = Person.new(:email => 'jenny@example.com')
59
60
 
61
+ Now, calling this:
62
+
60
63
  jenny.add_phone('867-5309')
61
- # Same as:
64
+
65
+ Is the same as:
66
+
62
67
  jenny.request(:put, 'person', 'jenny@example.com', 'add_phone', '867-5309')
63
68
 
64
69
 
@@ -116,7 +121,8 @@ License
116
121
 
117
122
  The MIT License
118
123
 
119
- Copyright (c) 2012 Society for Human Resource Management
124
+ Copyright (c) 2012 Eric Pierce, Automation Excellence, Society for Human
125
+ Resource Management
120
126
 
121
127
  Permission is hereby granted, free of charge, to any person obtaining
122
128
  a copy of this software and associated documentation files (the
data/lib/placid/helper.rb CHANGED
@@ -21,15 +21,15 @@ module Placid
21
21
  # URI-escaped.
22
22
  #
23
23
  # @example
24
- # url('people', 'eric') #=> 'http://localhost/people/eric'
25
- # url('a b', 'c:d') #=> 'http://localhost/a%20b/c%3Ad'
24
+ # get_url('people', 'eric') #=> 'http://localhost/people/eric'
25
+ # get_url('a b', 'c:d') #=> 'http://localhost/a%20b/c%3Ad'
26
26
  #
27
27
  # @param [Array] path
28
28
  # Parts of the path to request. These will be escaped and joined with '/'.
29
29
  #
30
30
  # @return [String]
31
31
  #
32
- def url(*path)
32
+ def get_url(*path)
33
33
  url = Placid::Config.rest_url.to_s.gsub(/\/$/, '')
34
34
  joined_path = path.map { |p| escape(p) }.join('/')
35
35
  return "#{url}/#{joined_path}"
@@ -62,7 +62,7 @@ module Placid
62
62
  method = method.to_sym
63
63
  params = path.extract_options!
64
64
  params = {:params => params} if method == :get
65
- rest_url = url(*path)
65
+ rest_url = get_url(*path)
66
66
  begin
67
67
  response = RestClient.send(method, rest_url, params)
68
68
  rescue RestClient::Exception => e
data/lib/placid/model.rb CHANGED
@@ -82,6 +82,7 @@ module Placid
82
82
 
83
83
  # Get or set the field name used for uniquely identifying instances of this
84
84
  # model.
85
+ #
85
86
  def self.unique_id(field=nil)
86
87
  if field.nil?
87
88
  return @unique_id || :id
@@ -104,7 +105,8 @@ module Placid
104
105
  end
105
106
  end
106
107
 
107
- # Return a Model instance matching the given id
108
+ # Return a Model instance matching the given id. Sends a GET request to the
109
+ # REST API.
108
110
  #
109
111
  # @param [String] id
110
112
  # Identifier for the model instance to fetch
@@ -116,7 +118,8 @@ module Placid
116
118
  return self.new(json)
117
119
  end
118
120
 
119
- # Create a new model instance and return it.
121
+ # Create a new model instance and return it. Sends a POST request
122
+ # to the REST API.
120
123
  #
121
124
  # @param [Hash] attrs
122
125
  # Attribute values for the new instance
@@ -130,7 +133,7 @@ module Placid
130
133
  return obj
131
134
  end
132
135
 
133
- # Update an existing model instance.
136
+ # Update an existing model instance. Sends a PUT request to the REST API.
134
137
  #
135
138
  # @param [String] id
136
139
  # Identifier of the model instance to update
@@ -146,7 +149,7 @@ module Placid
146
149
  return obj
147
150
  end
148
151
 
149
- # Destroy a model instance.
152
+ # Destroy a model instance. Sends a DELETE request to the REST API.
150
153
  #
151
154
  # @param [String] id
152
155
  # Identifier for the model instance to delete
data/placid.gemspec CHANGED
@@ -1,8 +1,11 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "placid"
3
- s.version = "0.0.5"
3
+ s.version = "0.0.6"
4
4
  s.summary = "Models from REST"
5
5
  s.description = <<-EOS
6
+ Placid is an ActiveRecord-ish model using a REST API for storage. The REST API
7
+ can be any backend you choose or create yourself, provided it follows some basic
8
+ conventions.
6
9
  EOS
7
10
  s.authors = ["Eric Pierce"]
8
11
  s.email = "epierce@automation-excellence.com"
@@ -7,13 +7,13 @@ describe Placid::Helper do
7
7
  end
8
8
  end
9
9
 
10
- describe "#url" do
10
+ describe "#get_url" do
11
11
  it "joins path components with '/'" do
12
- url('foo', 'bar', 'baz').should == 'http://localhost/foo/bar/baz'
12
+ get_url('foo', 'bar', 'baz').should == 'http://localhost/foo/bar/baz'
13
13
  end
14
14
 
15
15
  it "escapes path components to make them URI-safe" do
16
- url('a b', 'c:d', 'e/f').should == 'http://localhost/a%20b/c%3Ad/e%2Ff'
16
+ get_url('a b', 'c:d', 'e/f').should == 'http://localhost/a%20b/c%3Ad/e%2Ff'
17
17
  end
18
18
  end
19
19
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: placid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Pierce
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-05 00:00:00 Z
18
+ date: 2012-08-27 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: hashie
@@ -129,7 +129,7 @@ dependencies:
129
129
  version: "0"
130
130
  type: :development
131
131
  version_requirements: *id008
132
- description: ""
132
+ description: " Placid is an ActiveRecord-ish model using a REST API for storage. The REST API\n can be any backend you choose or create yourself, provided it follows some basic\n conventions.\n"
133
133
  email: epierce@automation-excellence.com
134
134
  executables: []
135
135