-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add object, structure parsers, add some metaflavour
- Loading branch information
1 parent
24fae96
commit bd737a1
Showing
28 changed files
with
233 additions
and
263 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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
require "mapon_client/version" | ||
|
||
module MaponClient | ||
DEFAULT_BASE_URL = 'https://mapon.com/api/v1/'.freeze | ||
DEFAULT_FORMAT = 'json'.freeze | ||
|
||
autoload :Client, 'mapon_client/client' | ||
autoload :Parsers, 'mapon_client/parsers' | ||
end |
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,13 @@ | ||
module MaponClient | ||
module Helpers | ||
def resource_name | ||
self.name.sub(/.*::/, '').tap do |name| | ||
name.sub!(/Resource/, '') | ||
name.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') | ||
name.gsub!(/([a-z\d])([A-Z])/,'\1_\2') | ||
name.tr!("-", "_") | ||
name.downcase! | ||
end | ||
end | ||
end | ||
end |
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,7 @@ | ||
module MaponClient | ||
module Parsers | ||
autoload :EmptyParser, 'mapon_client/parsers/empty_parser' | ||
autoload :StructureParser, 'mapon_client/parsers/structure_parser' | ||
autoload :ObjectParser, 'mapon_client/parsers/object_parser' | ||
end | ||
end |
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,13 @@ | ||
module MaponClient | ||
module Parsers | ||
class EmptyParser | ||
def initialize(data) | ||
@data = data | ||
end | ||
|
||
def parse | ||
@data | ||
end | ||
end | ||
end | ||
end |
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,12 @@ | ||
require 'json' | ||
require 'ostruct' | ||
|
||
module MaponClient | ||
module Parsers | ||
class ObjectParser < EmptyParser | ||
def parse | ||
JSON.parse(@data, object_class: OpenStruct) | ||
end | ||
end | ||
end | ||
end |
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,11 @@ | ||
require 'json' | ||
|
||
module MaponClient | ||
module Parsers | ||
class StructureParser < EmptyParser | ||
def parse | ||
JSON.parse(@data) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.