fix some complexity issues codeclimate
This commit is contained in:
parent
f413a4a963
commit
c27dbbefb5
3 changed files with 19 additions and 19 deletions
|
|
@ -17,7 +17,7 @@ module DiasporaFederation
|
|||
# @example Creating a hCard document from account data
|
||||
# hc = HCard.from_profile({
|
||||
# guid: "0123456789abcdef",
|
||||
# diaspora_handle: "user@server.example",
|
||||
# nickname: "user",
|
||||
# full_name: "User Name",
|
||||
# url: "https://server.example/",
|
||||
# photo_full_url: "https://server.example/uploads/f.jpg",
|
||||
|
|
@ -108,7 +108,7 @@ module DiasporaFederation
|
|||
hc = allocate
|
||||
hc.instance_eval {
|
||||
@guid = data[:guid]
|
||||
@nickname = data[:diaspora_handle].split("@").first
|
||||
@nickname = data[:nickname]
|
||||
@full_name = data[:full_name]
|
||||
@url = data[:url]
|
||||
@photo_full_url = data[:photo_full_url]
|
||||
|
|
@ -228,12 +228,12 @@ module DiasporaFederation
|
|||
# @param [Hash] data account data
|
||||
# @return [Boolean] validation result
|
||||
def self.account_data_complete?(data)
|
||||
data.instance_of?(Hash) && data.key?(:guid) &&
|
||||
data.key?(:diaspora_handle) && data.key?(:full_name) &&
|
||||
data.key?(:url) && data.key?(:photo_full_url) &&
|
||||
data.key?(:photo_medium_url) && data.key?(:photo_small_url) &&
|
||||
data.key?(:pubkey) && data.key?(:searchable) &&
|
||||
data.key?(:first_name) && data.key?(:last_name)
|
||||
data.instance_of?(Hash) &&
|
||||
%i(
|
||||
guid nickname full_name url
|
||||
photo_full_url photo_medium_url photo_small_url
|
||||
pubkey searchable first_name last_name
|
||||
).all? {|k| data.key? k }
|
||||
end
|
||||
private_class_method :account_data_complete?
|
||||
|
||||
|
|
|
|||
|
|
@ -181,11 +181,11 @@ module DiasporaFederation
|
|||
# @param [Hash] data account data
|
||||
# @return [Boolean] validation result
|
||||
def self.account_data_complete?(data)
|
||||
data.instance_of?(Hash) && data.key?(:acct_uri) &&
|
||||
data.key?(:alias_url) && data.key?(:hcard_url) &&
|
||||
data.key?(:seed_url) && data.key?(:guid) &&
|
||||
data.key?(:profile_url) && data.key?(:atom_url) &&
|
||||
data.key?(:salmon_url) && data.key?(:pubkey)
|
||||
data.instance_of?(Hash) &&
|
||||
%i(
|
||||
acct_uri alias_url hcard_url seed_url
|
||||
guid profile_url atom_url salmon_url pubkey
|
||||
).all? {|k| data.key? k }
|
||||
end
|
||||
private_class_method :account_data_complete?
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module DiasporaFederation
|
||||
describe WebFinger::HCard do
|
||||
let(:guid) { "abcdef0123456789" }
|
||||
let(:handle) { "user@pod.example.tld" }
|
||||
let(:nickname) { "user" }
|
||||
let(:first_name) { "Test" }
|
||||
let(:last_name) { "Testington" }
|
||||
let(:name) { "#{first_name} #{last_name}" }
|
||||
|
|
@ -35,7 +35,7 @@ module DiasporaFederation
|
|||
<dl class="entity_nickname">
|
||||
<dt>Nickname</dt>
|
||||
<dd>
|
||||
<span class="nickname">#{handle.split('@').first}</span>
|
||||
<span class="nickname">#{nickname}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_full_name">
|
||||
|
|
@ -107,7 +107,7 @@ HTML
|
|||
it "creates an instance from a data hash" do
|
||||
hc = WebFinger::HCard.from_profile(
|
||||
guid: guid,
|
||||
diaspora_handle: handle,
|
||||
nickname: nickname,
|
||||
full_name: name,
|
||||
url: url,
|
||||
photo_full_url: photo_url,
|
||||
|
|
@ -124,8 +124,8 @@ HTML
|
|||
it "fails if some params are missing" do
|
||||
expect {
|
||||
WebFinger::HCard.from_profile(
|
||||
guid: guid,
|
||||
diaspora_handle: handle
|
||||
guid: guid,
|
||||
nickname: nickname
|
||||
)
|
||||
}.to raise_error WebFinger::InvalidData
|
||||
end
|
||||
|
|
@ -143,7 +143,7 @@ HTML
|
|||
it "reads its own output" do
|
||||
hc = WebFinger::HCard.from_html(html)
|
||||
expect(hc.guid).to eq(guid)
|
||||
expect(hc.nickname).to eq(handle.split("@").first)
|
||||
expect(hc.nickname).to eq(nickname)
|
||||
expect(hc.full_name).to eq(name)
|
||||
expect(hc.url).to eq(url)
|
||||
expect(hc.photo_full_url).to eq(photo_url)
|
||||
|
|
|
|||
Loading…
Reference in a new issue