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 fbe7ba7 commit 5fc0318
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
20 changes: 13 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,57 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2015-08-15 16:22:00 -0400 using RuboCop version 0.33.0.
# on 2015-08-15 16:48:27 -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:
Max: 103

# Offense count: 82
# Offense count: 84
# Configuration parameters: AllowURI, URISchemes.
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.
Metrics/ModuleLength:
Max: 246
Max: 254

# Offense count: 1
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 5fc0318

Please sign in to comment.