leggy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/Guardfile +33 -0
- data/leggy-0.1.0.gem +0 -0
- data/lib/leggy.rb +16 -22
- data/lib/leggy/app.rb +13 -0
- data/lib/leggy/crawl.rb +23 -0
- data/lib/leggy/crawl_options.rb +18 -0
- data/lib/leggy/helpers.rb +40 -0
- data/lib/leggy/mapping/app.rb +18 -0
- data/lib/leggy/mapping/crawl.rb +13 -0
- data/lib/leggy/mapping/crawl_options.rb +13 -0
- data/lib/leggy/mapping/url.rb +14 -0
- data/lib/leggy/mapping/user.rb +14 -0
- data/lib/leggy/resource/app.rb +55 -0
- data/lib/leggy/resource/crawl.rb +49 -0
- data/lib/leggy/resource/url.rb +55 -0
- data/lib/leggy/resource/user.rb +23 -0
- data/lib/leggy/url.rb +13 -0
- data/lib/leggy/user.rb +19 -0
- data/lib/leggy/version.rb +1 -1
- data/spec/cassettes/leggy.yml +1361 -0
- data/spec/fixtures/sample_app.js +53 -0
- data/spec/fixtures/urls.json +4 -0
- data/spec/leggy/leggy_spec.rb +177 -0
- data/spec/spec_helper.rb +45 -0
- metadata +32 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da3232fa74362931ad5aa06fb886c8856d0610ce
|
4
|
+
data.tar.gz: 037b56a7930324f3eeb96531f9ded4dda49d7f41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccef3a3674b165cc70eccd23826ae59bab1d75a2f1a9a3b030fb9d85f3c78acdc10b453113c0d7af54806b16bb9525be84421e332e8c3010f21e78d5db5a1c8d
|
7
|
+
data.tar.gz: c0d16ac47813fd6e09f1e7e5190cf1897af33083de8b69989a0b18d66bdb460f2ad7bebf5fb8567ad394882fc8f87b062485fa78e6c54d84d37548d7e1395184
|
data/.rspec
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
5
|
+
# rspec may be run, below are examples of the most common uses.
|
6
|
+
# * bundler: 'bundle exec rspec'
|
7
|
+
# * bundler binstubs: 'bin/rspec'
|
8
|
+
# * spring: 'bin/rsspec' (This will use spring if running and you have
|
9
|
+
# installed the spring binstubs per the docs)
|
10
|
+
# * zeus: 'zeus rspec' (requires the server to be started separetly)
|
11
|
+
# * 'just' rspec: 'rspec'
|
12
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
13
|
+
watch(%r{^spec/.+_spec\.rb$})
|
14
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
15
|
+
watch('spec/spec_helper.rb') { "spec" }
|
16
|
+
|
17
|
+
# Rails example
|
18
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
19
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
20
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
21
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
22
|
+
watch('config/routes.rb') { "spec/routing" }
|
23
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
24
|
+
watch('spec/rails_helper.rb') { "spec" }
|
25
|
+
|
26
|
+
# Capybara features specs
|
27
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
28
|
+
|
29
|
+
# Turnip features and steps
|
30
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
31
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
32
|
+
end
|
33
|
+
|
data/leggy-0.1.0.gem
ADDED
Binary file
|
data/lib/leggy.rb
CHANGED
@@ -9,6 +9,22 @@ require "active_support/concern"
|
|
9
9
|
require "active_support/core_ext/hash/slice"
|
10
10
|
require "ostruct"
|
11
11
|
|
12
|
+
require "leggy/helpers"
|
13
|
+
require "leggy/user"
|
14
|
+
require "leggy/app"
|
15
|
+
require "leggy/url"
|
16
|
+
require "leggy/crawl_options"
|
17
|
+
require "leggy/crawl"
|
18
|
+
require "leggy/mapping/user"
|
19
|
+
require "leggy/mapping/app"
|
20
|
+
require "leggy/mapping/url"
|
21
|
+
require "leggy/mapping/crawl_options"
|
22
|
+
require "leggy/mapping/crawl"
|
23
|
+
require "leggy/resource/user"
|
24
|
+
require "leggy/resource/app"
|
25
|
+
require "leggy/resource/url"
|
26
|
+
require "leggy/resource/crawl"
|
27
|
+
|
12
28
|
Dotenv.load
|
13
29
|
|
14
30
|
module Leggy
|
@@ -69,27 +85,5 @@ module Leggy
|
|
69
85
|
options
|
70
86
|
end
|
71
87
|
|
72
|
-
autoload :Helpers, 'leggy/helpers'
|
73
|
-
autoload :User, 'leggy/user'
|
74
|
-
autoload :App, 'leggy/app'
|
75
|
-
autoload :Url, 'leggy/url'
|
76
|
-
autoload :CrawlOptions, 'leggy/crawl_options'
|
77
|
-
autoload :Crawl, 'leggy/crawl'
|
78
|
-
|
79
|
-
module Mapping
|
80
|
-
autoload :User, 'leggy/mapping/user'
|
81
|
-
autoload :App, 'leggy/mapping/app'
|
82
|
-
autoload :Url, 'leggy/mapping/url'
|
83
|
-
autoload :CrawlOptions, 'leggy/mapping/crawl_options'
|
84
|
-
autoload :Crawl, 'leggy/mapping/crawl'
|
85
|
-
end
|
86
|
-
|
87
|
-
module Resource
|
88
|
-
autoload :User, 'leggy/resource/user'
|
89
|
-
autoload :App, 'leggy/resource/app'
|
90
|
-
autoload :Url, 'leggy/resource/url'
|
91
|
-
autoload :Crawl, 'leggy/resource/crawl'
|
92
|
-
end
|
93
|
-
|
94
88
|
end
|
95
89
|
|
data/lib/leggy/app.rb
ADDED
data/lib/leggy/crawl.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Leggy
|
2
|
+
class Crawl
|
3
|
+
include Leggy::Helpers
|
4
|
+
|
5
|
+
attr_accessor(
|
6
|
+
:name,
|
7
|
+
:app,
|
8
|
+
:user,
|
9
|
+
:id,
|
10
|
+
:urllist,
|
11
|
+
:data,
|
12
|
+
:user_agent,
|
13
|
+
:depth,
|
14
|
+
:max_depth,
|
15
|
+
:urls_crawled,
|
16
|
+
:maxUrls,
|
17
|
+
:status,
|
18
|
+
:results
|
19
|
+
)
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Leggy
|
2
|
+
class CrawlOptions
|
3
|
+
include Leggy::Helpers
|
4
|
+
|
5
|
+
def initialize(attrs = {})
|
6
|
+
attrs.slice(*Leggy::CrawlOptions.attr_accessors).each { |k,v| send("#{k}=",v) }
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_accessor(
|
10
|
+
:app,
|
11
|
+
:urllist,
|
12
|
+
:data,
|
13
|
+
:max_depth,
|
14
|
+
:max_urls
|
15
|
+
)
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Leggy
|
2
|
+
module Helpers
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
|
7
|
+
def attr_reader(*params)
|
8
|
+
@attr_readers ||= []
|
9
|
+
@attr_readers.concat params
|
10
|
+
super(*params)
|
11
|
+
end
|
12
|
+
|
13
|
+
def attr_writer(*params)
|
14
|
+
@attr_writers ||= []
|
15
|
+
@attr_writers.concat params
|
16
|
+
super(*params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def attr_accessor(*params)
|
20
|
+
@attr_accessors ||= []
|
21
|
+
@attr_accessors.concat params
|
22
|
+
super(*params)
|
23
|
+
end
|
24
|
+
|
25
|
+
def attr_readers
|
26
|
+
@attr_readers
|
27
|
+
end
|
28
|
+
|
29
|
+
def attr_writers
|
30
|
+
@attr_writers
|
31
|
+
end
|
32
|
+
|
33
|
+
def attr_accessors
|
34
|
+
@attr_accessors
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Leggy
|
2
|
+
module Mapping
|
3
|
+
class App
|
4
|
+
include Kartograph::DSL
|
5
|
+
|
6
|
+
kartograph do
|
7
|
+
mapping Leggy::App
|
8
|
+
|
9
|
+
property *Leggy::App.attr_accessors, scopes: :read
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# name string The name given to the app.
|
16
|
+
# user string The user the app is associated with.
|
17
|
+
# location string The internal location for the app.
|
18
|
+
# date_created date The date the app was uploaded.
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Leggy
|
2
|
+
module Resource
|
3
|
+
class App < ResourceKit::Resource
|
4
|
+
|
5
|
+
resources do
|
6
|
+
|
7
|
+
default_handler do |response|
|
8
|
+
raise "ERROR #{response.status}: #{response.body}"
|
9
|
+
end
|
10
|
+
|
11
|
+
# GET https://api_token:@api.80legs.com/v2/apps
|
12
|
+
#
|
13
|
+
action :all do
|
14
|
+
verb :get
|
15
|
+
path '/v2/apps'
|
16
|
+
handler(200) { |response| Leggy::Mapping::App.extract_collection(response.body, :read) }
|
17
|
+
end
|
18
|
+
|
19
|
+
# PUT https://api_token:@api.80legs.com/v2/apps/{APP_NAME}
|
20
|
+
#
|
21
|
+
action :create do
|
22
|
+
before_request :set_content_type_for_uploads
|
23
|
+
verb :put
|
24
|
+
path '/v2/apps/:name'
|
25
|
+
body { |object| File.file?(object[:body]) ? File.read(object[:body]) : object[:body] }
|
26
|
+
handler(204) { |response| true }
|
27
|
+
end
|
28
|
+
|
29
|
+
# GET https://api_token:@api.80legs.com/v2/apps/{APP_NAME}
|
30
|
+
#
|
31
|
+
action :find do
|
32
|
+
verb :get
|
33
|
+
path '/v2/apps/:name'
|
34
|
+
handler(200) { |response| response.body }
|
35
|
+
end
|
36
|
+
|
37
|
+
# DELETE https://api_token:@api.80legs.com/v2/apps/{APP_NAME}
|
38
|
+
#
|
39
|
+
action :delete do
|
40
|
+
verb :delete
|
41
|
+
path '/v2/apps/:name'
|
42
|
+
handler(204) { |response| true }
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def set_content_type_for_uploads(*args, request)
|
50
|
+
request.headers['Content-Type'] = 'application/octet-stream'
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Leggy
|
2
|
+
module Resource
|
3
|
+
class Crawl < ResourceKit::Resource
|
4
|
+
|
5
|
+
resources do
|
6
|
+
|
7
|
+
default_handler do |response|
|
8
|
+
raise "ERROR #{response.status}: #{response.body}"
|
9
|
+
end
|
10
|
+
|
11
|
+
# POST https://api_token:@api.80legs.com/v2/crawls/{CRAWL_NAME}
|
12
|
+
#
|
13
|
+
action :start do
|
14
|
+
verb :post
|
15
|
+
path '/v2/crawls/:name'
|
16
|
+
body { |object| object.slice(*Leggy::CrawlOptions.attr_accessors).to_json }
|
17
|
+
handler(204) { |response| true }
|
18
|
+
end
|
19
|
+
|
20
|
+
# GET https://api_token:@api.80legs.com/v2/crawls/{CRAWL_NAME}
|
21
|
+
#
|
22
|
+
action :status do
|
23
|
+
verb :get
|
24
|
+
path '/v2/crawls/:name'
|
25
|
+
handler(200) { |response| Leggy::Mapping::Crawl.extract_single(response.body, :read) }
|
26
|
+
end
|
27
|
+
|
28
|
+
# DELETE https://api_token:@api.80legs.com/v2/crawls/{CRAWL_NAME}
|
29
|
+
#
|
30
|
+
action :cancel do
|
31
|
+
verb :delete
|
32
|
+
path '/v2/crawls/:name'
|
33
|
+
handler(204) { |response| true }
|
34
|
+
end
|
35
|
+
|
36
|
+
# GET https://api_token:@api.80legs.com/v2/results/{CRAWL_NAME}
|
37
|
+
#
|
38
|
+
action :results do
|
39
|
+
verb :get
|
40
|
+
path '/v2/results/:name'
|
41
|
+
handler(200) { |response| JSON.parse(response.body) }
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Leggy
|
2
|
+
module Resource
|
3
|
+
class Url < ResourceKit::Resource
|
4
|
+
|
5
|
+
resources do
|
6
|
+
|
7
|
+
default_handler do |response|
|
8
|
+
raise "ERROR #{response.status}: #{response.body}"
|
9
|
+
end
|
10
|
+
|
11
|
+
# GET https://api_token:@api.80legs.com/v2/urllists
|
12
|
+
#
|
13
|
+
action :all do
|
14
|
+
verb :get
|
15
|
+
path '/v2/urllists'
|
16
|
+
handler(200) { |response| Leggy::Mapping::Url.extract_collection(response.body, :read) }
|
17
|
+
end
|
18
|
+
|
19
|
+
# PUT https://api_token:@api.80legs.com/v2/urllists/{URLS_NAME}
|
20
|
+
#
|
21
|
+
action :create do
|
22
|
+
before_request :set_content_type_for_uploads
|
23
|
+
verb :put
|
24
|
+
path '/v2/urllists/:name'
|
25
|
+
body { |object| File.file?(object[:body]) ? File.read(object[:body]) : object[:body] }
|
26
|
+
handler(204) { |response| true }
|
27
|
+
end
|
28
|
+
|
29
|
+
# GET https://api_token:@api.80legs.com/v2/urllists/{URLS_NAME}
|
30
|
+
#
|
31
|
+
action :find do
|
32
|
+
verb :get
|
33
|
+
path '/v2/urllists/:name'
|
34
|
+
handler(200) { |response| JSON.parse(response.body) }
|
35
|
+
end
|
36
|
+
|
37
|
+
# DELETE https://api_token:@api.80legs.com/v2/urllists/{URLS_NAME}
|
38
|
+
#
|
39
|
+
action :delete do
|
40
|
+
verb :delete
|
41
|
+
path '/v2/urllists/:name'
|
42
|
+
handler(204) { |response| true }
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def set_content_type_for_uploads(*args, request)
|
50
|
+
request.headers['Content-Type'] = 'application/octet-stream'
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|