Skip to content

Commit

Permalink
Incorporate feedback (fixup 399a156)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsander committed Apr 27, 2016
1 parent 1165866 commit 708106a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ AWS_SANDBOX=false
#
# Configuration examples:
#
# ADDITIOANL_GEMS=huginn_nlp_agents,test_agent
# ADDITIOANL_GEMS=huginn_nlp_agents(~> 0.2.1),test_agent
# ADDITIOANL_GEMS=huginn_nlp_agents(git: https://github.com/kreuzwerker/DKT.huginn_nlp_agents.git),test_agent
# ADDITIOANL_GEMS=huginn_nlp_agents(github: kreuzwerker/DKT.huginn_nlp_agents),test_agent
# ADDITIOANL_GEMS=huginn_nlp_agents(~> 0.2.1, git: https://github.com/kreuzwerker/DKT.huginn_nlp_agents.git),test_agent
# ADDITIONAL_GEMS=huginn_nlp_agents,test_agent
# ADDITIONAL_GEMS=huginn_nlp_agents(~> 0.2.1),test_agent
# ADDITIONAL_GEMS=huginn_nlp_agents(git: https://github.com/kreuzwerker/DKT.huginn_nlp_agents.git),test_agent
# ADDITIONAL_GEMS=huginn_nlp_agents(github: kreuzwerker/DKT.huginn_nlp_agents),test_agent
# ADDITIONAL_GEMS=huginn_nlp_agents(~> 0.2.1, git: https://github.com/kreuzwerker/DKT.huginn_nlp_agents.git),test_agent

########################
# Various Settings #
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,6 @@ if_true(ENV['DATABASE_ADAPTER'].strip == 'mysql2') do
gem 'mysql2', '~> 0.3.20'
end

GemfileHelper.parse_agent_gems(ENV['ADDITIOANL_GEMS']) do |args|
GemfileHelper.parse_each_agent_gem(ENV['ADDITIONAL_GEMS']) do |args|
gem *args
end
2 changes: 1 addition & 1 deletion lib/gemfile_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def load_dotenv
GEM_SEPARATOR = '\s*(?:,|\z)'.freeze
GEM_REGULAR_EXPRESSION = /(#{GEM_NAME})(?:\(#{GEM_OPTIONS}\)){0,1}#{GEM_SEPARATOR}/

def parse_agent_gems(string)
def parse_each_agent_gem(string)
return unless string
string.scan(GEM_REGULAR_EXPRESSION).each do |name, version, args|
if version =~ /\w+:/
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/gemfile_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

describe GemfileHelper do
context 'parse_agent_gems' do
context 'parse_each_agent_gem' do
VALID_STRINGS = [
['huginn_nlp_agents(~> 0.2.1)', [
['huginn_nlp_agents', '~> 0.2.1']
Expand Down Expand Up @@ -31,18 +31,18 @@

it 'parses valid gem strings correctly' do
VALID_STRINGS.each do |string, outcomes|
GemfileHelper.parse_agent_gems(string) do |args|
GemfileHelper.parse_each_agent_gem(string) do |args|
expect(args).to eq(outcomes.shift)
end
end
end

it 'does nothing when nil is passed' do
expect { |b| GemfileHelper.parse_agent_gems(nil, &b) }.not_to yield_control
expect { |b| GemfileHelper.parse_each_agent_gem(nil, &b) }.not_to yield_control
end

it 'does nothing when an empty string is passed' do
expect { |b| GemfileHelper.parse_agent_gems('', &b) }.not_to yield_control
expect { |b| GemfileHelper.parse_each_agent_gem('', &b) }.not_to yield_control
end
end
end

0 comments on commit 708106a

Please sign in to comment.