Class: Niffler::Maven
- Inherits:
-
Object
- Object
- Niffler::Maven
- Defined in:
- lib/niffler/maven.rb
Constant Summary collapse
- BASE_URL =
"http://search.maven.org/solrsearch/select?"
- JSON_URL =
"&wt=json"
- ROWS_URL =
"&rows=500"
- ROW_URL =
"&rows=1"
Instance Attribute Summary collapse
-
#artifact ⇒ Object
Returns the value of attribute artifact.
-
#group ⇒ Object
Returns the value of attribute group.
-
#packaging ⇒ Object
Returns the value of attribute packaging.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
-
.artifact_query(name) ⇒ Object
def self.artifacts_query.
-
.artifacts_query(name) ⇒ Object
def self.group_query.
-
.group_query(name) ⇒ Object
def find_by_group.
- .groups_query(name) ⇒ Object
-
.hash_query(hash) ⇒ Object
def self.artifact_query.
Instance Method Summary collapse
-
#initialize(opts) ⇒ Maven
constructor
A new instance of Maven.
Constructor Details
#initialize(opts) ⇒ Maven
Returns a new instance of Maven.
13 14 15 16 17 18 19 |
# File 'lib/niffler/maven.rb', line 13 def initialize(opts) @group = opts.fetch(:group) @artifact = opts.fetch(:artifact) @version = opts.fetch(:version) @repository = opts.fetch(:repository) @packaging = opts.fetch(:packaging) end |
Instance Attribute Details
#artifact ⇒ Object
Returns the value of attribute artifact.
7 8 9 |
# File 'lib/niffler/maven.rb', line 7 def artifact @artifact end |
#group ⇒ Object
Returns the value of attribute group.
7 8 9 |
# File 'lib/niffler/maven.rb', line 7 def group @group end |
#packaging ⇒ Object
Returns the value of attribute packaging.
7 8 9 |
# File 'lib/niffler/maven.rb', line 7 def packaging @packaging end |
#repository ⇒ Object
Returns the value of attribute repository.
7 8 9 |
# File 'lib/niffler/maven.rb', line 7 def repository @repository end |
#version ⇒ Object
Returns the value of attribute version.
7 8 9 |
# File 'lib/niffler/maven.rb', line 7 def version @version end |
Class Method Details
.artifact_query(name) ⇒ Object
def self.artifacts_query
46 47 48 49 50 51 52 |
# File 'lib/niffler/maven.rb', line 46 def self.artifact_query(name) # build the query for artifacts specifying only one response url = BASE_URL+"q="+CGI::escape("a:\"#{name}\"")+JSON_URL+ROW_URL json = fetch_json(url) result = parse_json(json).last return result end |
.artifacts_query(name) ⇒ Object
def self.group_query
38 39 40 41 42 43 44 |
# File 'lib/niffler/maven.rb', line 38 def self.artifacts_query(name) # build the query for an artifact specifying 500 maximum responses url = BASE_URL+"q="+CGI::escape("a:\"#{name}\"")+JSON_URL+ROWS_URL json = fetch_json(url) results = parse_json(json) return results end |
.group_query(name) ⇒ Object
def find_by_group
29 30 31 32 33 34 35 36 |
# File 'lib/niffler/maven.rb', line 29 def self.group_query(name) # build the query for a group specifying only one response url = BASE_URL+"q="+CGI::escape(name)+JSON_URL+ROWS_URL # returns an array with a single entry json = fetch_json(url) result = parse_json(json).last return result end |
.groups_query(name) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/niffler/maven.rb', line 21 def self.groups_query(name) # build the query for groups specifying 500 maximum responses url = BASE_URL+"q="+CGI::escape(name)+JSON_URL+ROWS_URL json = fetch_json(url) results = parse_json(json) return results end |