rebrandly 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/rebrandly.rb +7 -7
- data/lib/rebrandly/api.rb +1 -1
- data/lib/rebrandly/element.rb +1 -1
- data/lib/rebrandly/link.rb +2 -2
- data/lib/rebrandly/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d987bcb3c97243117e4fe684a34aa9011ce775e
|
4
|
+
data.tar.gz: 7cda7ed562a981cf0ca3c452d577794bda7875b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b497d03b435a84716cbced61af5626bb5bd9a8ffdad9530d95bc8262879c981ecb4d79ef6e6d5244cc043136846cd623c1724ee7461eb79509c62af825f3b2d
|
7
|
+
data.tar.gz: f8d5ed79995c886b9b0fd07ef665c0bee4d4453aa06caecadac7dbb0fdb41518a1a307a2a1369e9f2230c602c938a5f24a13d519c4f2dd3597ee0901019f5499
|
data/.gitignore
CHANGED
data/lib/rebrandly.rb
CHANGED
@@ -2,10 +2,10 @@ require 'rebrandly/version'
|
|
2
2
|
require 'rebrandly/configuration'
|
3
3
|
require 'rebrandly/api'
|
4
4
|
require 'rebrandly/element'
|
5
|
-
require 'rebrandly/link'
|
6
|
-
require 'rebrandly/creator'
|
7
5
|
require 'rebrandly/domain'
|
6
|
+
require 'rebrandly/creator'
|
8
7
|
require 'rebrandly/integration'
|
8
|
+
require 'rebrandly/link'
|
9
9
|
|
10
10
|
module Rebrandly
|
11
11
|
class << self
|
@@ -26,7 +26,7 @@ module Rebrandly
|
|
26
26
|
end
|
27
27
|
|
28
28
|
class String
|
29
|
-
def
|
29
|
+
def rebrandly_underscore
|
30
30
|
self.gsub(/::/, '/').
|
31
31
|
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
32
32
|
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
@@ -34,21 +34,21 @@ class String
|
|
34
34
|
downcase
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def rebrandly_camelize
|
38
38
|
self.split('_').collect(&:capitalize).join
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def rebrandly_lower_camelize
|
42
42
|
res = self.camelize
|
43
43
|
res[0].downcase + res[1..-1]
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
class Hash
|
48
|
-
def self.
|
48
|
+
def self.rebrandly_stringify_keys(hash)
|
49
49
|
stringified_hash = {}
|
50
50
|
hash.each do |k, v|
|
51
|
-
stringified_hash[k.to_s] = v.is_a?(Hash) ?
|
51
|
+
stringified_hash[k.to_s] = v.is_a?(Hash) ? rebrandly_stringify_keys(v) : v
|
52
52
|
end
|
53
53
|
stringified_hash
|
54
54
|
end
|
data/lib/rebrandly/api.rb
CHANGED
@@ -68,7 +68,7 @@ module Rebrandly
|
|
68
68
|
def rebrandly_request(method, url, options={})
|
69
69
|
url = "#{BASE_URL}/#{url}"
|
70
70
|
# Convert all hash keys into camel case for Rebrandly
|
71
|
-
options = Hash[options.map { |k,v| [k.to_s.
|
71
|
+
options = Hash[options.map { |k,v| [k.to_s.rebrandly_lower_camelize.to_sym, v] }].to_json
|
72
72
|
|
73
73
|
http_attrs = { headers: headers }
|
74
74
|
case method
|
data/lib/rebrandly/element.rb
CHANGED
@@ -3,7 +3,7 @@ module Rebrandly
|
|
3
3
|
class Element
|
4
4
|
def initialize(attrs={})
|
5
5
|
# Only set the attributes if the method exists, this way we can ignore deprecated attributes
|
6
|
-
attrs.each { |k,v| send("#{k.
|
6
|
+
attrs.each { |k,v| send("#{k.rebrandly_underscore}=", v) if respond_to?("#{k.rebrandly_underscore}=") }
|
7
7
|
end
|
8
8
|
|
9
9
|
def to_h
|
data/lib/rebrandly/link.rb
CHANGED
@@ -8,7 +8,7 @@ module Rebrandly
|
|
8
8
|
|
9
9
|
|
10
10
|
# Associations
|
11
|
-
|
11
|
+
[:domain, :creator, :integration].each do |association|
|
12
12
|
# Creates the getter methods, such as "@instance.domain"
|
13
13
|
attr_reader association
|
14
14
|
|
@@ -17,7 +17,7 @@ module Rebrandly
|
|
17
17
|
attrs ||= {}
|
18
18
|
|
19
19
|
# Retrieve the class
|
20
|
-
klass =
|
20
|
+
klass = Rebrandly.const_get(association.to_s.rebrandly_camelize)
|
21
21
|
|
22
22
|
# Ex:
|
23
23
|
# @domain = Domain.new(attrs)
|
data/lib/rebrandly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rebrandly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.5.1
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: A Ruby Rebrandly Wrapper
|