mivi_consume 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/customer.rb +29 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ca03161e69f506d0b426d239d12fcd30ea458844
|
4
|
+
data.tar.gz: 4753367ce51dbe1ff3aab6c039e7e73a606efa77
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f8c5727f4fc9095fad5e212b22fa6c3ee7b7892a800266c7bcdf767c24804b30aa34097386fae4881b96a2d8e37a9623ac0242e070ccab1c2ae3b1ca479422f8
|
7
|
+
data.tar.gz: 11617909b12a631238b8f0f2c4c985db628d4f9940710b9aed8a5d407a13d48c3255c117a6cf0b411c4a38266e8881a9b1ebc0b94ce92c9f65086e567f2f18af
|
data/lib/customer.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'json'
|
2
|
+
module MiviConsume
|
3
|
+
class Customer
|
4
|
+
def self.consume_data(file)
|
5
|
+
return false unless file
|
6
|
+
file = File.read(file)
|
7
|
+
data_hash = JSON.parse(file)
|
8
|
+
product_name = nil
|
9
|
+
data_hash["included"].each{ |info| product_name = info["attributes"]["name"] if info["type"] == "products" } if data_hash["included"]
|
10
|
+
cust = data_hash["data"]["attributes"]
|
11
|
+
puts " Phone number: #{cust["contact-number"]}\n Email address: #{cust["email-address"]}\n Name: #{cust["title"]} #{cust["first-name"]} #{cust["last-name"]}\n Product name: #{ product_name }" if cust
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
Customer.consume_data(ARGV.first)
|
16
|
+
|
17
|
+
#Note: bundle install rspec and create file customer_spec.rb with following code and run rspec customer_spec.rb on terminal
|
18
|
+
|
19
|
+
# require_relative './customer'
|
20
|
+
|
21
|
+
# describe Customer do
|
22
|
+
# it "should be true" do
|
23
|
+
# expect(Customer.consume_data('./collection.json')).to "Phone number: 0404000000
|
24
|
+
# Email address: test@mivi.com
|
25
|
+
# Name: Ms Joe Bloggs
|
26
|
+
# Product name: UNLIMITED 7GB
|
27
|
+
# "
|
28
|
+
# end
|
29
|
+
# end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mivi_consume
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Santosh Wakode
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/customer.rb
|
20
|
+
homepage:
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.6.8
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: to consume details
|
43
|
+
test_files: []
|
44
|
+
has_rdoc:
|