focus-utils 0.0.7 → 0.0.8
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/lib/ares/add_singleton.rb +52 -0
- data/lib/focus-utils.rb +2 -0
- metadata +23 -17
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module ActiveResource
|
4
|
+
module Extend
|
5
|
+
module Singleton
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
class << self
|
10
|
+
alias_method_chain :find_one, :singleton
|
11
|
+
alias_method_chain :collection_name, :singleton
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module ClassMethods
|
16
|
+
def singleton
|
17
|
+
# Not using superclass_delegating_reader. See +site+ for explanation
|
18
|
+
if defined?(@singleton)
|
19
|
+
@singleton
|
20
|
+
elsif superclass != Object && superclass.singleton
|
21
|
+
superclass.singleton.dup.freeze
|
22
|
+
else
|
23
|
+
@singleton = false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def singleton=(singleton)
|
28
|
+
@singleton = singleton
|
29
|
+
end
|
30
|
+
|
31
|
+
def find_one_with_singleton(options)
|
32
|
+
found_object = find_one_without_singleton(options)
|
33
|
+
if !found_object && singleton
|
34
|
+
prefix_options, query_options = split_options(options[:params])
|
35
|
+
path = element_path(nil, prefix_options, query_options)
|
36
|
+
found_object = instantiate_record(format.decode(connection.get(path, headers).body), prefix_options)
|
37
|
+
end
|
38
|
+
found_object
|
39
|
+
end
|
40
|
+
|
41
|
+
def collection_name_with_singleton
|
42
|
+
if singleton
|
43
|
+
element_name
|
44
|
+
else
|
45
|
+
collection_name_without_singleton
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/focus-utils.rb
CHANGED
@@ -6,6 +6,7 @@ require 'ares/remove_format_extension'
|
|
6
6
|
require 'ares/add_custom_header'
|
7
7
|
require 'ares/use_config_file'
|
8
8
|
require 'ares/threadsafe_authentication'
|
9
|
+
require 'ares/add_singleton'
|
9
10
|
|
10
11
|
#ActiveResource::Base.include_format_in_path = false
|
11
12
|
ActiveResource::Base.send(:include, ActiveResource::Extend::AuthWithApiKey)
|
@@ -13,4 +14,5 @@ ActiveResource::Base.send(:include, ActiveResource::Extend::RemoveExtension)
|
|
13
14
|
ActiveResource::Base.send(:include, ActiveResource::Extend::AddRelativePrefix)
|
14
15
|
ActiveResource::Base.send(:include, ActiveResource::Extend::AddCustomHeaders)
|
15
16
|
ActiveResource::Base.send(:include, ActiveResource::Extend::ThreadsafeAuthentication)
|
17
|
+
ActiveResource::Base.send(:include, ActiveResource::Extend::Singleton)
|
16
18
|
ActiveResource::Base.establish_site_connection
|
metadata
CHANGED
@@ -1,63 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: focus-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
version: 0.0.8
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Spencer Davis
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-27 00:00:00.
|
12
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|
16
|
-
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
17
18
|
requirements:
|
18
19
|
- - ~>
|
19
20
|
- !ruby/object:Gem::Version
|
20
21
|
version: '3.0'
|
21
|
-
none: false
|
22
|
-
requirement: *2056
|
23
|
-
prerelease: false
|
24
22
|
type: :runtime
|
25
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
description: Add-ons including API Key, remove format extensions (.json, .xml) for
|
31
|
+
requests, and configuration file (sites.yml) for each environment's default settings.
|
26
32
|
email: spencer.davis@bipt.com
|
27
33
|
executables: []
|
28
34
|
extensions: []
|
29
35
|
extra_rdoc_files: []
|
30
36
|
files:
|
31
|
-
- lib/focus-utils.rb
|
32
37
|
- lib/ares/add_api_key.rb
|
33
38
|
- lib/ares/add_custom_header.rb
|
34
39
|
- lib/ares/add_relative_prefix.rb
|
40
|
+
- lib/ares/add_singleton.rb
|
35
41
|
- lib/ares/remove_format_extension.rb
|
36
42
|
- lib/ares/threadsafe_authentication.rb
|
37
43
|
- lib/ares/use_config_file.rb
|
44
|
+
- lib/focus-utils.rb
|
38
45
|
homepage: https://github.com/spencerfdavis/ares-focus-extensions
|
39
46
|
licenses: []
|
40
|
-
post_install_message:
|
47
|
+
post_install_message:
|
41
48
|
rdoc_options: []
|
42
49
|
require_paths:
|
43
50
|
- lib
|
44
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
45
53
|
requirements:
|
46
54
|
- - ! '>='
|
47
55
|
- !ruby/object:Gem::Version
|
48
56
|
version: '0'
|
49
|
-
none: false
|
50
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
51
59
|
requirements:
|
52
60
|
- - ! '>='
|
53
61
|
- !ruby/object:Gem::Version
|
54
62
|
version: '0'
|
55
|
-
none: false
|
56
63
|
requirements: []
|
57
|
-
rubyforge_project:
|
58
|
-
rubygems_version: 1.8.
|
59
|
-
signing_key:
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.8.23
|
66
|
+
signing_key:
|
60
67
|
specification_version: 3
|
61
68
|
summary: Add-ons/patches for Focus Tech Projects.
|
62
69
|
test_files: []
|
63
|
-
...
|