apollo-crawler 0.1.21 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/apollo-crawler +0 -4
- data/bin/apollo-platform +30 -0
- data/config/amqp.yml +18 -0
- data/config/amqp.yml.default +18 -0
- data/config/apollo.yml +13 -0
- data/config/apollo.yml.default +10 -0
- data/config/memcached.yml +14 -0
- data/config/memcached.yml.default +14 -0
- data/config/mongo.yml +19 -0
- data/config/mongo.yml.default +19 -0
- data/config/mongoid.yml +23 -0
- data/config/mongoid.yml.default +59 -0
- data/lib/apollo_crawler.rb +12 -3
- data/lib/apollo_crawler/adapter/adapters.rb +22 -0
- data/lib/apollo_crawler/adapter/amqp_adapter.rb +26 -0
- data/lib/apollo_crawler/adapter/mongo_adapter.rb +26 -0
- data/lib/apollo_crawler/{cli/cli.rb → agent/agents.rb} +2 -0
- data/lib/apollo_crawler/agent/base_agent.rb +26 -0
- data/lib/apollo_crawler/cache/caches.rb +20 -0
- data/lib/apollo_crawler/cache/sqlite_cache.rb +9 -0
- data/lib/apollo_crawler/config.rb +82 -72
- data/lib/apollo_crawler/crawler/crawlers.rb +20 -0
- data/lib/apollo_crawler/crawler/google_crawler.rb +2 -2
- data/lib/apollo_crawler/crawler/hacker_news_crawler.rb +2 -2
- data/lib/apollo_crawler/crawler/slashdot_crawler.rb +2 -2
- data/lib/apollo_crawler/crawler/stackoverflow_crawler.rb +2 -2
- data/lib/apollo_crawler/crawler/xkcd_crawler.rb +2 -2
- data/lib/apollo_crawler/crawler/youjizz_crawler.rb +2 -2
- data/lib/apollo_crawler/env.rb +24 -0
- data/lib/apollo_crawler/fetcher/base_fetcher.rb +1 -1
- data/lib/apollo_crawler/fetcher/fetchers.rb +20 -0
- data/lib/apollo_crawler/fetcher/simple_fetcher.rb +1 -1
- data/lib/apollo_crawler/fetcher/smart_fetcher.rb +1 -1
- data/lib/apollo_crawler/formatter/formatters.rb +20 -0
- data/lib/apollo_crawler/formatter/json_formatter.rb +5 -1
- data/lib/apollo_crawler/formatter/plain_formatter.rb +4 -0
- data/lib/apollo_crawler/formatter/table_formatter.rb +4 -0
- data/lib/apollo_crawler/helper/amqp_helper.rb +26 -0
- data/lib/apollo_crawler/helper/core_helper.rb +24 -4
- data/lib/apollo_crawler/helper/helpers.rb +23 -1
- data/lib/apollo_crawler/helper/mongo_helper.rb +26 -0
- data/lib/apollo_crawler/lib.rb +12 -3
- data/lib/apollo_crawler/logger/loggers.rb +20 -0
- data/lib/apollo_crawler/planner/base_planner.rb +26 -0
- data/lib/apollo_crawler/planner/planners.rb +22 -0
- data/lib/apollo_crawler/planner/smart_planner.rb +28 -0
- data/lib/apollo_crawler/program/base_program.rb +130 -0
- data/lib/apollo_crawler/program/console_program.rb +177 -0
- data/lib/apollo_crawler/program/crawler_program.rb +130 -183
- data/lib/apollo_crawler/program/platform_program.rb +137 -0
- data/lib/apollo_crawler/program/programs.rb +23 -1
- data/lib/apollo_crawler/store/stores.rb +20 -0
- data/lib/apollo_crawler/version.rb +2 -2
- metadata +55 -3
@@ -20,11 +20,20 @@
|
|
20
20
|
|
21
21
|
require File.join(File.dirname(__FILE__), 'base_cache')
|
22
22
|
|
23
|
+
require 'sqlite3'
|
24
|
+
|
23
25
|
module Apollo
|
24
26
|
module Cache
|
25
27
|
class SqliteCache < BaseCache
|
28
|
+
DEFAULT_OPTIONS = {
|
29
|
+
:db => "apollo-crawler.db",
|
30
|
+
:collection => "fetched_docs"
|
31
|
+
}
|
32
|
+
|
26
33
|
def initilize(options = {})
|
27
34
|
super(options)
|
35
|
+
|
36
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
28
37
|
end
|
29
38
|
|
30
39
|
def get(key)
|
@@ -18,102 +18,112 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
-
|
21
|
+
# See http://stackoverflow.com/questions/6233124/where-to-place-access-config-file-in-gem
|
22
|
+
|
23
|
+
require 'yaml'
|
22
24
|
|
23
|
-
|
24
|
-
############################################################
|
25
|
-
# Program - basic settings
|
26
|
-
############################################################
|
27
|
-
|
28
|
-
# Directory for storing apollo-crawler data
|
29
|
-
PROGRAM_DIRECTORY = File.expand_path("~/.apollo-crawler")
|
25
|
+
require File.join(File.dirname(__FILE__), 'lib')
|
30
26
|
|
31
|
-
|
32
|
-
|
27
|
+
module Apollo
|
28
|
+
module RbConfig
|
29
|
+
############################################################
|
30
|
+
# Program - basic settings
|
31
|
+
############################################################
|
32
|
+
|
33
|
+
# Directory for storing apollo-crawler data
|
34
|
+
PROGRAM_DIRECTORY = File.expand_path("~/.apollo-crawler")
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
PROGRAM_DIRECTORY,
|
37
|
-
PROGRAM_PLUGINS_DIRECTORY,
|
38
|
-
PROGRAM_TEMP_DIRECTORY
|
39
|
-
]
|
36
|
+
PROGRAM_PLUGINS_DIRECTORY = File.join(PROGRAM_DIRECTORY, "plugins")
|
37
|
+
PROGRAM_TEMP_DIRECTORY = File.join(PROGRAM_DIRECTORY, "tmp")
|
40
38
|
|
39
|
+
# Basic PROGRAM_DIRECTORY structure, lazy created
|
40
|
+
PROGRAM_DIRECTORIES = [
|
41
|
+
PROGRAM_DIRECTORY,
|
42
|
+
PROGRAM_PLUGINS_DIRECTORY,
|
43
|
+
PROGRAM_TEMP_DIRECTORY
|
44
|
+
]
|
41
45
|
|
42
46
|
|
43
|
-
PROGRAM_CONFIG_PATH = File.join(RbConfig::PROGRAM_DIRECTORY, "config.rb")
|
44
47
|
|
48
|
+
PROGRAM_CONFIG_PATH = File.join(RbConfig::PROGRAM_DIRECTORY, "config.rb")
|
45
49
|
|
46
50
|
|
47
|
-
############################################################
|
48
|
-
# Caches - caches implementations
|
49
|
-
############################################################
|
50
|
-
CACHES_DIR = File.join(File.dirname(__FILE__), "caches")
|
51
51
|
|
52
|
+
############################################################
|
53
|
+
# Caches - caches implementations
|
54
|
+
############################################################
|
55
|
+
CACHES_DIR = File.join(File.dirname(__FILE__), "caches")
|
52
56
|
|
53
57
|
|
54
|
-
############################################################
|
55
|
-
# Cache implementation used for chaching pages retreived
|
56
|
-
############################################################
|
57
|
-
#
|
58
|
-
# Filesystem backend
|
59
|
-
# CACHE_CLASS = Apollo::Cache::FilesystemCache
|
60
|
-
#
|
61
|
-
# Memcached - expects localhost:11211
|
62
|
-
# CACHE_CLASS = Apollo::Cache::MemcachedCache
|
63
|
-
#
|
64
|
-
# Pure naive ruby in-memory implementation
|
65
|
-
# CACHE_CLASS = Apollo::Cache::MemoryCache
|
66
|
-
#
|
67
|
-
# Null caching - no caching at all
|
68
|
-
# CACHE_CLASS = Apollo::Cache::NullCache
|
69
58
|
|
70
|
-
|
71
|
-
|
59
|
+
############################################################
|
60
|
+
# Cache implementation used for chaching pages retreived
|
61
|
+
############################################################
|
62
|
+
#
|
63
|
+
# Filesystem backend
|
64
|
+
# CACHE_CLASS = Apollo::Cache::FilesystemCache
|
65
|
+
#
|
66
|
+
# Memcached - expects localhost:11211
|
67
|
+
# CACHE_CLASS = Apollo::Cache::MemcachedCache
|
68
|
+
#
|
69
|
+
# Pure naive ruby in-memory implementation
|
70
|
+
# CACHE_CLASS = Apollo::Cache::MemoryCache
|
71
|
+
#
|
72
|
+
# Null caching - no caching at all
|
73
|
+
# CACHE_CLASS = Apollo::Cache::NullCache
|
72
74
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
CACHE_CLASS_OPTIONS_MONGO = {
|
76
|
+
:host => 'apollo-crawler.no-ip.org',
|
77
|
+
:port => 27017,
|
78
|
+
:pool_size => 5,
|
79
|
+
:pool_timeout => 5,
|
80
|
+
:db => 'apollo-crawler',
|
81
|
+
:collection => 'fetched_docs'
|
82
|
+
}
|
81
83
|
|
84
|
+
CACHE_CLASS_OPTIONS_SQLITE3 = {
|
85
|
+
:db => 'apollo-crawler-db',
|
86
|
+
:collection => 'fetched_docs'
|
87
|
+
}
|
82
88
|
|
89
|
+
# Used caching mechanism by default
|
90
|
+
CACHE_CLASS = Apollo::Cache::SqliteCache
|
91
|
+
CACHE_CLASS_OPTIONS = CACHE_CLASS_OPTIONS_MONGO
|
83
92
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
93
|
+
############################################################
|
94
|
+
# Crawlers - Built-in out-of box working crawlers
|
95
|
+
############################################################
|
96
|
+
CRAWLERS_DIR = File.join(File.dirname(__FILE__), "crawler")
|
97
|
+
|
98
|
+
# Template used for generated crawlers
|
99
|
+
CRAWLER_TEMPLATE_NAME = "crawler_template.trb"
|
91
100
|
|
92
|
-
|
93
|
-
|
101
|
+
# Path of template
|
102
|
+
CRAWLER_TEMPLATE_PATH = File.join(CRAWLERS_DIR, CRAWLER_TEMPLATE_NAME)
|
94
103
|
|
95
104
|
|
96
105
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
106
|
+
############################################################
|
107
|
+
# Fetchers - used for fetching documents
|
108
|
+
############################################################
|
109
|
+
FETCHERS_DIR = File.join(File.dirname(__FILE__), "fetcher")
|
110
|
+
|
111
|
+
DEFAULT_FETCHER = Apollo::Fetcher::SmartFetcher
|
103
112
|
|
104
113
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
114
|
+
############################################################
|
115
|
+
# Formatters - used for formatting crawled documents results
|
116
|
+
############################################################
|
117
|
+
FORMATTERS_DIR = File.join(File.dirname(__FILE__), "formatter")
|
109
118
|
|
110
|
-
|
111
|
-
|
119
|
+
# Default formatter if no other specified
|
120
|
+
DEFAULT_FORMATTER = Apollo::Formatter::JsonFormatter
|
112
121
|
|
113
122
|
|
114
123
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
end # Config
|
124
|
+
############################################################
|
125
|
+
# Loggers - used for formatting output messages
|
126
|
+
############################################################
|
127
|
+
DEFAULT_LOGGER = Apollo::Logger::ConsoleLogger
|
128
|
+
end # Config
|
129
|
+
end
|
@@ -1,3 +1,23 @@
|
|
1
|
+
# Copyright, 2013, by Tomas Korcak. <korczis@gmail.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
1
21
|
require File.join(File.dirname(__FILE__), 'base_crawler')
|
2
22
|
require File.join(File.dirname(__FILE__), 'google_crawler')
|
3
23
|
require File.join(File.dirname(__FILE__), 'hacker_news_crawler')
|
@@ -35,7 +35,7 @@ module Apollo
|
|
35
35
|
|
36
36
|
def extract_data(doc)
|
37
37
|
res = doc.xpath(@@MATCHER_ITEM).map { | node |
|
38
|
-
url = BaseCrawler.try_get_url(self.url, node['href'])
|
38
|
+
url = BaseCrawler.try_get_url(self.url, node['href']).to_s
|
39
39
|
next if url.nil?
|
40
40
|
|
41
41
|
{
|
@@ -47,7 +47,7 @@ module Apollo
|
|
47
47
|
|
48
48
|
def extract_links(doc)
|
49
49
|
res = doc.xpath("(//td[@class = 'b']/a)[last()]").map { | node |
|
50
|
-
res_doc = BaseCrawler.try_get_url(self.url, node['href'])
|
50
|
+
res_doc = BaseCrawler.try_get_url(self.url, node['href']).to_s
|
51
51
|
next if url.nil?
|
52
52
|
|
53
53
|
{
|
@@ -35,7 +35,7 @@ module Apollo
|
|
35
35
|
|
36
36
|
def extract_data(doc)
|
37
37
|
res = doc.xpath(@@MATCHER_ITEM).map { |node|
|
38
|
-
url = BaseCrawler.try_get_url(self.url, node['href'])
|
38
|
+
url = BaseCrawler.try_get_url(self.url, node['href']).to_s
|
39
39
|
next if url.nil?
|
40
40
|
|
41
41
|
{
|
@@ -49,7 +49,7 @@ module Apollo
|
|
49
49
|
|
50
50
|
def extract_links(doc)
|
51
51
|
res = doc.xpath("(//td[@class = 'title']/a)[last()]").map { |node|
|
52
|
-
url = BaseCrawler.try_get_url(self.url, node['href'])
|
52
|
+
url = BaseCrawler.try_get_url(self.url, node['href']).to_s
|
53
53
|
next if url.nil?
|
54
54
|
|
55
55
|
{
|
@@ -35,7 +35,7 @@ module Apollo
|
|
35
35
|
|
36
36
|
def extract_data(doc)
|
37
37
|
res = doc.xpath(@@MATCHER_ITEM).map { | node |
|
38
|
-
url = BaseCrawler.try_get_url(self.url, node['href'])
|
38
|
+
url = BaseCrawler.try_get_url(self.url, node['href']).to_s
|
39
39
|
next if url.nil?
|
40
40
|
|
41
41
|
{
|
@@ -47,7 +47,7 @@ module Apollo
|
|
47
47
|
|
48
48
|
def extract_links(doc)
|
49
49
|
res = doc.xpath(@@MATCHER_ITEM).map { | node |
|
50
|
-
url = BaseCrawler.try_get_url(self.url, node['href'])
|
50
|
+
url = BaseCrawler.try_get_url(self.url, node['href']).to_s
|
51
51
|
next if url.nil?
|
52
52
|
|
53
53
|
{
|
@@ -35,7 +35,7 @@ module Apollo
|
|
35
35
|
|
36
36
|
def extract_data(doc)
|
37
37
|
res = doc.xpath(@@MATCHER_ITEM).map { |node|
|
38
|
-
url = BaseCrawler.try_get_url(self.url, node['href'])
|
38
|
+
url = BaseCrawler.try_get_url(self.url, node['href']).to_s
|
39
39
|
next if url.nil?
|
40
40
|
|
41
41
|
{
|
@@ -49,7 +49,7 @@ module Apollo
|
|
49
49
|
|
50
50
|
def extract_links(doc)
|
51
51
|
res = doc.xpath("(//div[@class = 'pager fl']/a)[last()]").map { |node|
|
52
|
-
url = BaseCrawler.try_get_url(self.url, node['href'])
|
52
|
+
url = BaseCrawler.try_get_url(self.url, node['href']).to_s
|
53
53
|
next if url.nil?
|
54
54
|
|
55
55
|
{
|
@@ -37,7 +37,7 @@ module Apollo
|
|
37
37
|
res = doc.xpath(@@MATCHER_ITEM).map { |node|
|
38
38
|
{
|
39
39
|
:text => node['title'],
|
40
|
-
:link => URI.join(self.url, node['src'])
|
40
|
+
:link => URI.join(self.url, node['src']).to_s
|
41
41
|
}
|
42
42
|
}
|
43
43
|
end
|
@@ -45,7 +45,7 @@ module Apollo
|
|
45
45
|
def extract_links(doc)
|
46
46
|
res = doc.xpath("//ul[@class = 'comicNav']/li/a[@accesskey = 'p']").map { |node|
|
47
47
|
{
|
48
|
-
:link => URI.join(self.url, node['href'])
|
48
|
+
:link => URI.join(self.url, node['href']).to_s
|
49
49
|
}
|
50
50
|
}
|
51
51
|
res.uniq
|
@@ -33,7 +33,7 @@ module Apollo
|
|
33
33
|
|
34
34
|
def extract_data(doc)
|
35
35
|
res = doc.xpath(@@MATCHER_ITEM).map { | node |
|
36
|
-
link = BaseCrawler.try_get_url(self.url, node['href'])
|
36
|
+
link = BaseCrawler.try_get_url(self.url, node['href']).to_s
|
37
37
|
next if link.nil?
|
38
38
|
|
39
39
|
{
|
@@ -45,7 +45,7 @@ module Apollo
|
|
45
45
|
|
46
46
|
def extract_links(doc)
|
47
47
|
res = doc.xpath("//div[@id = 'pagination']/a").map { | node |
|
48
|
-
link = BaseCrawler.try_get_url(self.url, node['href'])
|
48
|
+
link = BaseCrawler.try_get_url(self.url, node['href']).to_s
|
49
49
|
next if link.nil?
|
50
50
|
|
51
51
|
{
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright, 2013, by Tomas Korcak. <korczis@gmail.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
module Apollo
|
22
|
+
ENV = "development"
|
23
|
+
BASE_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
|
24
|
+
end
|
@@ -1,3 +1,23 @@
|
|
1
|
+
# Copyright, 2013, by Tomas Korcak. <korczis@gmail.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
1
21
|
require File.join(File.dirname(__FILE__), 'base_fetcher')
|
2
22
|
require File.join(File.dirname(__FILE__), 'simple_fetcher')
|
3
23
|
require File.join(File.dirname(__FILE__), 'smart_fetcher')
|
@@ -26,7 +26,7 @@ require File.join(File.dirname(__FILE__), 'base_fetcher')
|
|
26
26
|
module Apollo
|
27
27
|
module Fetcher
|
28
28
|
class SimpleFetcher < BaseFetcher
|
29
|
-
def self.fetch(url)
|
29
|
+
def self.fetch(url, options = {})
|
30
30
|
# TODO: Throw exception ???
|
31
31
|
return BaseFetcher::fetch(url)
|
32
32
|
end
|
@@ -1,3 +1,23 @@
|
|
1
|
+
# Copyright, 2013, by Tomas Korcak. <korczis@gmail.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
1
21
|
require File.join(File.dirname(__FILE__), 'base_formatter')
|
2
22
|
require File.join(File.dirname(__FILE__), 'json_formatter')
|
3
23
|
require File.join(File.dirname(__FILE__), 'plain_formatter')
|
@@ -25,8 +25,12 @@ require File.join(File.dirname(__FILE__), 'base_formatter')
|
|
25
25
|
module Apollo
|
26
26
|
module Formatter
|
27
27
|
class JsonFormatter < BaseFormatter
|
28
|
+
def name()
|
29
|
+
return "JSON"
|
30
|
+
end
|
31
|
+
|
28
32
|
def format(obj)
|
29
|
-
return
|
33
|
+
return JsonFormatter.format(obj)
|
30
34
|
end
|
31
35
|
|
32
36
|
def self.format(obj)
|