Skip to content

Commit

Permalink
Well shit, it works
Browse files Browse the repository at this point in the history
  • Loading branch information
pikesley committed Jan 30, 2016
1 parent a024b52 commit 4ab793b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ gem 'bootstrap3-datetimepicker-rails', '~> 4.17.37'
# gem 'capistrano-rails', group: :development

gem 'dotenv'
gem 'httparty'

group :development, :test do
gem 'pry'
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ GEM
rspec (>= 2.99.0, < 4.0)
http-cookie (1.0.2)
domain_name (~> 0.5)
httparty (0.13.7)
json (~> 1.8)
multi_xml (>= 0.5.2)
i18n (0.7.0)
jbuilder (2.4.0)
activesupport (>= 3.0.0, < 5.1)
Expand All @@ -139,6 +142,7 @@ GEM
momentjs-rails (2.11.0)
railties (>= 3.1)
multi_json (1.11.2)
multi_xml (0.5.5)
nenv (0.2.0)
netrc (0.11.0)
nokogiri (1.6.7.2)
Expand Down Expand Up @@ -278,6 +282,7 @@ DEPENDENCIES
dotenv
factory_girl_rails
guard-rspec
httparty
jbuilder (~> 2.0)
jquery-rails
launchy
Expand Down
23 changes: 21 additions & 2 deletions dirty_hacky_script.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require 'xmlsimple'
require 'json'
require 'httparty'
require 'dotenv'
Dotenv.load

data = XmlSimple.xml_in File.read 'spec/support/fixtures/incoming.xml'
data = XmlSimple.xml_in File.read ARGV[0]

r = data['record']
r.sort! { |x, y| x['datetime'] <=> y['datetime'] }
Expand All @@ -12,4 +15,20 @@
end
end

puts r
url = 'http://localhost:3000/api'

r.each do |j|
HTTParty.post(
url,
body: {
data: j.to_json
}.to_json,
headers: {
'Content-Type' => 'application/json'
},
basic_auth: {
username: ENV['API_USER'],
password: ENV['API_PASSWORD']
}
)
end

0 comments on commit 4ab793b

Please sign in to comment.