Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the login, mapper and parser examples into a new rets4r bin
* bin/rets4r: add * examples/client_login.rb, examples/client_mapper.rb examples/client_parser.rb: remove * rets4r.gemspec: add cucumber, aruba deps
- Loading branch information
1 parent
e792418
commit 2de3145
Showing
10 changed files
with
134 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env ruby | ||
# rets4r: All-singing, all-dancing RETS cure-all | ||
require 'active_support/core_ext/hash' | ||
require 'active_support/ordered_hash' | ||
require 'logger' | ||
require 'thor' | ||
require 'yaml' | ||
|
||
require 'rets4r' | ||
|
||
module RETS4R | ||
class CLI < Thor | ||
|
||
desc "parse", "take a RETS XML Document and print how it looks" | ||
def parse(filename) | ||
xml = File.open filename | ||
transaction = RETS4R::ResponseDocument::Search.safe_parse(xml).validate!.results | ||
transaction.each {|row| puts sorted_print(row) } | ||
end | ||
|
||
desc "map", "take a RETS XML Document and map it pretty" | ||
def map(filename) | ||
load_settings | ||
xml = File.open filename | ||
mapper = RETS4R::ListingMapper.new | ||
RETS4R::Loader.load(xml) do |record| | ||
attributes = mapper.map(record) | ||
puts sorted_print(attributes) | ||
end | ||
end | ||
|
||
desc "login", 'login to your rets server' | ||
def login | ||
settings = load_settings | ||
|
||
client = RETS4R::Client.new(settings[:url]) | ||
# client.logger = Logger.new(STDOUT) | ||
|
||
login_result = client.login(settings[:username], settings[:password]) | ||
|
||
if login_result.success? | ||
puts "We successfully logged into the RETS server!" | ||
|
||
# Print the action URL results (if any) | ||
puts login_result.secondary_response | ||
|
||
client.logout | ||
|
||
puts "We just logged out of the server." | ||
else | ||
puts "We were unable to log into the RETS server." | ||
puts "Please check that you have set the login variables correctly." | ||
end | ||
end | ||
private | ||
def load_settings(filename = 'settings.yml') | ||
RETS4R::ListingService.configurations = YAML.load_file(filename) | ||
RETS4R::ListingService.env = ENV['RETS4RENV'] || 'development' | ||
RETS4R::ListingService.connection | ||
end | ||
def sorted_print(hash) | ||
hash.to_a. | ||
sort {|a,b| a.first.to_s <=> b.first.to_s }. | ||
map {|pair| pair.join(': ') }. | ||
join(', ') | ||
end | ||
end | ||
end | ||
|
||
RETS4R::CLI.start |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Feature: Command Line Tool | ||
As a new rets4r user | ||
I want a tool to show how to use my data | ||
|
||
Background: | ||
Given a file named "settings.yml" with: | ||
""" | ||
development: | ||
url: http://www.dis.com:6103/rets/login | ||
username: Joe | ||
password: Schmoe | ||
select: | ||
MLSNUM: :mls | ||
AGENTLIST_FULLNAME: :agent_full_name | ||
LISTPRICE: :list_price | ||
""" | ||
Given a file named "search_compact.xml" with: | ||
""" | ||
<RETS ReplyCode="0" ReplyText="SUCCESS"> | ||
<COUNT Records="4"/> | ||
<DELIMITER value="09" /> | ||
<COLUMNS> MLSNUM LISTPRICE AGENTLIST_FULLNAME </COLUMNS> | ||
<DATA> 1 2 Steve</DATA> | ||
<DATA> 4 5 Bill</DATA> | ||
<MAXROWS/> | ||
</RETS> | ||
""" | ||
|
||
Scenario: parse | ||
When I run `rets4r parse search_compact.xml` | ||
Then the output should contain: | ||
""" | ||
AGENTLIST_FULLNAME: Steve, LISTPRICE: 2, MLSNUM: 1 | ||
AGENTLIST_FULLNAME: Bill, LISTPRICE: 5, MLSNUM: 4 | ||
""" | ||
|
||
Scenario: Map | ||
When I run `rets4r map search_compact.xml` | ||
Then the output should contain: | ||
""" | ||
agent_full_name: Steve, list_price: 2, mls: 1 | ||
agent_full_name: Bill, list_price: 5, mls: 4 | ||
""" | ||
|
||
Scenario: Login | ||
When I run `rets4r login` | ||
Then the output should contain: | ||
""" | ||
We successfully logged into the RETS server! | ||
nil | ||
We just logged out of the server. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'aruba/cucumber' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters