rooftop 0.0.3 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a9d8c7ae19dac1d8c551531855e0d3e27250192
4
- data.tar.gz: 9c74850f0c4152e96f76033a2bd6c9cf8abdae01
3
+ metadata.gz: 17838c2957390cba459e722b6b6c24e107db27c2
4
+ data.tar.gz: 7a2616214f7e5e5ac829e34c53d4d191a7fef6b6
5
5
  SHA512:
6
- metadata.gz: 6d48a437b703b9bc90fcbf81d7df4151ef6d632fb3a94f63449df99b6fd758fc4a621cc5da0780581a2a0853664b9ce4c9ccb390fd0c67948a48cb85bd25ba3f
7
- data.tar.gz: 60a7a48f74f2b30f2550b547c51b01ee3bfb7671749fb118795521bfabee07b2f262167dac60d2961e0506866a49b32f91c7d22192594addf28f1668e127eaea
6
+ metadata.gz: 7e043daa4269c79ed27af44fc7e18b00d07f11227b88404807c018608b791510a1618fdc4f367eca7e0f98903b5922f4ac550c09d55ecaadf7b840476496059a
7
+ data.tar.gz: e2c2142efc855d53db5e9443bcaf9ec3877b86184cec3a3f7c013b7b379cbc8ca34083739685b4e2279971f84acb58a38d897fb0a409eee8d0e1f9656a146782
data/README.md CHANGED
@@ -137,6 +137,35 @@ p.parent #returns the parent entity
137
137
  ## Handling Content Fields
138
138
  Rooftop can return a variable number of content fields depending on what you've configured in advanced custom fields.
139
139
 
140
+ The raw data is available in your object at `.content`:
141
+
142
+ ```
143
+ p = Page.first
144
+ p.content #returns a hash of content data
145
+ ```
146
+ But that's not super-helpful, so the gem generates a collection for you.
147
+
148
+ ```
149
+ p = Page.first
150
+ p.fields #a Rooftop::Content::Collection, containing Rooftop::Content::Field entries.
151
+ ```
152
+
153
+ You can access a particular piece of content like this:
154
+
155
+ ```
156
+ p = Page.first
157
+ p.fields.your_field #your_field would be a custom field you've created in Advanced Custom Fields
158
+ p.fields.content #the default 'content' field from the Rooftop admin interface
159
+ ```
160
+
161
+ You can get a list of all the fields on your model like this:
162
+
163
+ ```
164
+ p = Page.first
165
+ p.fields.field_names #returns an array of field names you can call
166
+ ```
167
+
168
+
140
169
  ## SSL / TLS
141
170
  Hosted Rooftop from rooftopcms.io exclusively uses ssl/tls. you need to configure the rooftop library to use ssl.
142
171
 
@@ -16,8 +16,30 @@ module Rooftop
16
16
  end
17
17
 
18
18
  def named(name)
19
- find_by(name: name.to_s).first
19
+ find_by(name: name.to_s)
20
20
  end
21
+
22
+ def field_names
23
+ collect(&:name)
24
+ end
25
+
26
+ def method_missing(method, *args, &block)
27
+ fields = named(method)
28
+ if fields.length > 0
29
+ fields.first.value
30
+ else
31
+ raise Rooftop::Content::FieldNotFoundError, "No field named #{method} was found"
32
+ end
33
+ end
34
+
35
+ def respond_to_missing?(method, private=false)
36
+ if named(method).length == 0
37
+ super
38
+ else
39
+ true
40
+ end
41
+ end
42
+
21
43
  end
22
44
  end
23
45
  end
File without changes
@@ -0,0 +1,5 @@
1
+ module Rooftop
2
+ module Content
3
+ class FieldNotFoundError < NoMethodError; end
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Rooftop
2
+ class RecordNotFoundError < NoMethodError; end
3
+ end
@@ -27,7 +27,7 @@ module Rooftop
27
27
  if results.present?
28
28
  results
29
29
  else
30
- raise Rooftop::RecordNotFound
30
+ raise Rooftop::RecordNotFoundError
31
31
  end
32
32
  end
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module Rooftop
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
22
  spec.add_development_dependency "rake"
23
23
 
24
- spec.add_dependency "activesupport"
25
- spec.add_dependency "require_all"
26
- spec.add_dependency "her"
27
- spec.add_dependency "faraday-http-cache"
24
+ spec.add_dependency "activesupport", "~> 4"
25
+ spec.add_dependency "require_all", "~> 1.3"
26
+ spec.add_dependency "her", "~> 0.8"
27
+ spec.add_dependency "faraday-http-cache", "~> 1.2"
28
28
 
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rooftop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Jones
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-19 00:00:00.000000000 Z
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,58 +42,58 @@ dependencies:
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: require_all
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.3'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '1.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: her
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '0.8'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '0.8'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: faraday-http-cache
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '1.2'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '1.2'
97
97
  description: An ActiveRecord-like interface to the Rooftop CMS JSON API
98
98
  email:
99
99
  - ed@errorstudio.co.uk
@@ -112,10 +112,11 @@ files:
112
112
  - lib/rooftop/coercions.rb
113
113
  - lib/rooftop/coercions/author_coercion.rb
114
114
  - lib/rooftop/coercions/parent_coercion.rb
115
- - lib/rooftop/content_fields/collection.rb
116
- - lib/rooftop/content_fields/content_fields.rb
117
- - lib/rooftop/content_fields/field.rb
118
- - lib/rooftop/errors/record_not_found.rb
115
+ - lib/rooftop/content/collection.rb
116
+ - lib/rooftop/content/content_fields.rb
117
+ - lib/rooftop/content/field.rb
118
+ - lib/rooftop/errors/field_not_found_error.rb
119
+ - lib/rooftop/errors/record_not_found_error.rb
119
120
  - lib/rooftop/field_aliases.rb
120
121
  - lib/rooftop/headers.rb
121
122
  - lib/rooftop/hook_calls.rb
@@ -133,7 +134,7 @@ files:
133
134
  - lib/rooftop/resource_links/link.rb
134
135
  - lib/rooftop/resource_links/resource_links.rb
135
136
  - lib/rooftop/version.rb
136
- - rooftop_ruby_client.gemspec
137
+ - rooftop.gemspec
137
138
  homepage: http://www.rooftopcms.com
138
139
  licenses:
139
140
  - GPL v3
@@ -1,3 +0,0 @@
1
- module Rooftop
2
- class RecordNotFound < StandardError; end
3
- end