morph-cli 0.0.2 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +22 -11
- data/lib/morph-cli.rb +15 -11
- data/lib/morph-cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Zjc1YjYxNThiZTIzZGNkMTY5MTI2MmYzMjFmNGVmOWZhNzg1YjkwOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDdkNzY4OWM4ZTAzNTg2NjA0NTgwYTg0NTRhYjJkZWExNmU5MmI2OQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGIxMDc2NGQ1ZTc4NzQ5ZDEyMzg5ZTQ1ZTk5MDdiNjYzN2QzNTM0ZTM3NWUy
|
10
|
+
Y2I3ZDNkNmVhOGRhYjQwZTIwMmE5ZWQ5ZjUxYWUwMGJhYTAzNDVjODg3ZDhm
|
11
|
+
YzY4ZmZmMzViZmRkMzI3NWRiMDdkMzRjMjIzMTBmNGVkMzY4N2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzM5YmNiNTk5NWI2NjYwYjA4ODU3YWIzZTA2ODYxYmQ1MjQxYTMyYzg4NWJk
|
14
|
+
Y2NiZDVkZGEwMGMxYzMyNTY4ZWQ1NWUwY2JjNjlmNzM5YmQxMmVjOWZmY2Uy
|
15
|
+
MTA4NzUyM2ExZTRjZTk2YzI3YTgyZjM0NjE1MDY3ZGRiYmIyZGM=
|
data/README.md
CHANGED
@@ -1,26 +1,37 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/morph-cli.png)](http://badge.fury.io/rb/morph-cli)
|
2
2
|
|
3
|
-
# Morph
|
3
|
+
# Morph Commandline
|
4
4
|
|
5
|
-
|
5
|
+
Runs Morph scrapers from the commandline.
|
6
6
|
|
7
|
-
|
7
|
+
Actually it will run them on the Morph server identically to the real thing. That means not installing a bucket load of libraries
|
8
|
+
and bits and bobs that are already installed with the Morph scraper environments.
|
9
|
+
|
10
|
+
To run a scraper in your local directory
|
11
|
+
|
12
|
+
morph
|
13
|
+
|
14
|
+
Yup, that's it.
|
8
15
|
|
9
|
-
|
16
|
+
It runs the code that's there right now. It doesn't need to be checked into git or anything.
|
10
17
|
|
11
|
-
|
18
|
+
For help
|
19
|
+
|
20
|
+
morph help
|
21
|
+
|
22
|
+
## Installation
|
12
23
|
|
13
|
-
|
24
|
+
You'll need Ruby >= 1.9 and then
|
14
25
|
|
15
|
-
|
26
|
+
gem install morph-cli
|
16
27
|
|
17
|
-
|
28
|
+
## Limitations
|
18
29
|
|
19
|
-
|
30
|
+
It doesn't currently stream the console output from the Morph server so you have to wait until the scraper has finished running before you see the output. I want to add streaming as soon as possible because it will make this a whole lot more responsive and usable.
|
20
31
|
|
21
|
-
|
32
|
+
It uploads your code everytime. So if it's big it might take a little while. Scrapers are not usually so I'm hoping this won't really be an issue
|
22
33
|
|
23
|
-
|
34
|
+
It doesn't yet return you the resulting sqlite database.
|
24
35
|
|
25
36
|
## Contributing
|
26
37
|
|
data/lib/morph-cli.rb
CHANGED
@@ -4,19 +4,23 @@ module MorphCLI
|
|
4
4
|
def self.execute(directory, development, env_config)
|
5
5
|
puts "Uploading and running..."
|
6
6
|
file = MorphCLI.create_tar(directory, MorphCLI.all_paths(directory))
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
block = Proc.new do |http_response|
|
8
|
+
http_response.read_body do |line|
|
9
|
+
unless line.empty?
|
10
|
+
a = JSON.parse(line)
|
11
|
+
if a["stream"] == "stdout"
|
12
|
+
s = $stdout
|
13
|
+
elsif a["stream"] == "stderr"
|
14
|
+
s = $stderr
|
15
|
+
else
|
16
|
+
raise "Unknown stream"
|
17
|
+
end
|
18
|
+
s.puts a["text"]
|
19
|
+
end
|
17
20
|
end
|
18
|
-
s.puts a["text"]
|
19
21
|
end
|
22
|
+
result = RestClient::Request.execute(:method => :post, :url => "#{env_config[:base_url]}/run",
|
23
|
+
:payload => {:api_key => env_config[:api_key], :code => file}, :block_response => block)
|
20
24
|
end
|
21
25
|
|
22
26
|
def self.config_path
|
data/lib/morph-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morph-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Landauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|