morph-cli 0.0.2 → 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWJhOGZjNjA0YmU1ZjliNDA2MjVhZDAxM2U2OWEwZWY1ZmQ2MjM0YQ==
4
+ Zjc1YjYxNThiZTIzZGNkMTY5MTI2MmYzMjFmNGVmOWZhNzg1YjkwOQ==
5
5
  data.tar.gz: !binary |-
6
- MDNlODNhMzhjYmUzNjFkMTY0MGQ0ZmNjY2E2ZmQxNzFjYTdlOGEzNA==
6
+ ZDdkNzY4OWM4ZTAzNTg2NjA0NTgwYTg0NTRhYjJkZWExNmU5MmI2OQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTZiZDJiYWVkYTBkOGU2YmZjZTU2ZjY5ZTEyZDY2ZGRlZDhmMzNlMDdlNzAz
10
- OGIzZjcwNDFlZjkyYjkxZTc5ZGJjMTQ2ZWM0ZWVmOWRiZGQxMzI2MjI2OGU3
11
- MzZiMGRiMTc4Y2Q5MTViYjc5MTUzYzRhOTc1NWZlNWQyYjM1ZmQ=
9
+ MGIxMDc2NGQ1ZTc4NzQ5ZDEyMzg5ZTQ1ZTk5MDdiNjYzN2QzNTM0ZTM3NWUy
10
+ Y2I3ZDNkNmVhOGRhYjQwZTIwMmE5ZWQ5ZjUxYWUwMGJhYTAzNDVjODg3ZDhm
11
+ YzY4ZmZmMzViZmRkMzI3NWRiMDdkMzRjMjIzMTBmNGVkMzY4N2U=
12
12
  data.tar.gz: !binary |-
13
- ZDVlYWExY2VlN2NmNTg3NzM1MjdkMWM0ZTYzNzY2MzVjNGQ4MTMwNDdhOWE2
14
- OTlkNDNhZTNmNzNhNDQ2NDAyZWQ0MDRjYTE0YjkwMWRmNTk2YWFlYWFlODZm
15
- Y2U1OTExZTUwOTc4YTFlOTBjZmY4YTNhNDk2OGEwN2JjNzZjZWM=
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
- TODO: Write a gem description
5
+ Runs Morph scrapers from the commandline.
6
6
 
7
- ## Installation
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
- Add this line to your application's Gemfile:
16
+ It runs the code that's there right now. It doesn't need to be checked into git or anything.
10
17
 
11
- gem 'morph-cli'
18
+ For help
19
+
20
+ morph help
21
+
22
+ ## Installation
12
23
 
13
- And then execute:
24
+ You'll need Ruby >= 1.9 and then
14
25
 
15
- $ bundle
26
+ gem install morph-cli
16
27
 
17
- Or install it yourself as:
28
+ ## Limitations
18
29
 
19
- $ gem install morph-cli
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
- ## Usage
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
- TODO: Write usage instructions here
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
- result = RestClient.post("#{env_config[:base_url]}/run", :api_key => env_config[:api_key], :code => file)
8
- # Interpret each line separately as json
9
- result.split("\n").each do |line|
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"
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
@@ -1,3 +1,3 @@
1
1
  module MorphCLI
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1"
3
3
  end
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.0.2
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-01-30 00:00:00.000000000 Z
11
+ date: 2014-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor