Skip to content

Commit

Permalink
WIP: always expand additional link variables, #84.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Aug 15, 2015
1 parent fc1f3e6 commit a016242
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
16 changes: 11 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2015-08-15 17:01:12 -0400 using RuboCop version 0.33.0.
# on 2015-08-15 17:12:38 -0400 using RuboCop version 0.33.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
Metrics/AbcSize:
Max: 19

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ClassLength:
Expand All @@ -16,10 +20,10 @@ Metrics/ClassLength:
Metrics/LineLength:
Max: 142

# Offense count: 3
# Offense count: 4
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 14
Max: 16

# Offense count: 3
# Configuration parameters: CountComments.
Expand All @@ -31,21 +35,23 @@ Style/AsciiComments:
Exclude:
- 'lib/hyperclient/collection.rb'

# Offense count: 2
# Offense count: 3
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Exclude:
- 'features/steps/api_navigation.rb'
- 'features/steps/default_config.rb'
- 'lib/uri_template/rfc6570/expression.rb'

# Offense count: 14
# Offense count: 15
Style/Documentation:
Exclude:
- 'features/steps/api_navigation.rb'
- 'features/steps/default_config.rb'
- 'features/support/api.rb'
- 'features/support/fixtures.rb'
- 'lib/hyperclient/version.rb'
- 'lib/uri_template/rfc6570/expression.rb'
- 'test/faraday/connection_test.rb'
- 'test/hyperclient/attributes_test.rb'
- 'test/hyperclient/collection_test.rb'
Expand Down
1 change: 1 addition & 0 deletions lib/hyperclient/link.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'hyperclient/resource'
require 'uri_template'
require 'futuroscope'
require_relative '../uri_template/rfc6570/expression'

module Hyperclient
# Internal: The Link is used to let a Resource interact with the API.
Expand Down
24 changes: 24 additions & 0 deletions lib/uri_template/rfc6570/expression.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'uri_template/rfc6570/expression'

class URITemplate::RFC6570
class Expression < Token
def expand(vars)
unused_vars = vars.keys.dup
result = []
@variable_specs.each do |var, expand, max_length|
if Utils.def?(vars[var])
result.push(*expand_one(var, vars[var], expand, max_length))
end
unused_vars.delete(var)
end
unused_vars.each do |k|
result.push(*expand_one(k, vars[k], false, 0))
end
if result.any?
return (self.class::PREFIX + result.join(self.class::SEPARATOR))
else
return ''
end
end
end
end

0 comments on commit a016242

Please sign in to comment.