friendly_ghost 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 48a7dbe825d5d0ea425094abc2fc94d361e5f367
4
+ data.tar.gz: fbda8fd3e4ee7d94399a191609c1f5586b0e882d
5
+ SHA512:
6
+ metadata.gz: 02ebf5e533fb7a9a27841f698b86ca0b041236c6a946241494c372130aa333014996dc417086f72eadbc83975c719910d079e0ff48b7f5ec4fb3b22490f9e563
7
+ data.tar.gz: 3417a94e98bdb7bf53143e6251e800363b5aa8b2892631139d9889acacaf2458d1f140cec2bcf2d026ccd8f4707a2a16aa8b6968a29921073fc28222ac56a123
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ tmp
2
+ pkg
3
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'guard-rspec', require: false
7
+ gem 'rb-fsevent', '~> 0.9', require: false
8
+ end
data/Guardfile ADDED
@@ -0,0 +1,6 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # (casper, the) friendly_ghost
2
+ ## Overview
3
+ A simplistic, opinionated Ruby runner for [CasperJS](http://casperjs.org)
4
+ projects. Designed to hand JSON from the last line of STDOUT back to the user.
5
+ Maybe someone else will find it useful, but I doubt it.
6
+
7
+ ## Installation
8
+ Using rubygems:
9
+ `gem install friendly_ghost`
10
+
11
+ OR using Bundler:
12
+ `gem 'friendly_ghost'`
13
+
14
+ OR using hub:
15
+ `git clone ezkl/friendly_ghost`
16
+
17
+ ## Usage
18
+
19
+ ```ruby
20
+ runner = FriendlyGhost::Runner.new
21
+ runner.casper_path #=> /usr/local/bin/casperjs
22
+
23
+ runner.command 'test spec/support/json.js'
24
+ runner.process.success? #=> true
25
+ runner.process.out #=> STDOUT
26
+ runner.process.err #=> STDERR
27
+ ```
28
+
29
+ ## Dependencies
30
+ * [posix-spawn](https://github.com/rtomayko/posix-spawn)
31
+ * [multi_json](https://github.com/intridea/multi_json)
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc 'Run all specs in spec directory'
6
+ RSpec::Core::RakeTask.new(:spec) do |t|
7
+ t.pattern = 'spec/**/*_spec.rb'
8
+ end
9
+
10
+ task :default => [:spec]
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require File.expand_path('../lib/friendly_ghost/version.rb', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.authors = ['Ezekiel Templin']
7
+ gem.email = ['zeke@templ.in']
8
+ gem.description = %q{CasperJS commands run in processes spawned by Ruby}
9
+ gem.summary = %q{Ruby runner for CasperJS}
10
+ gem.homepage = 'https://github.com/ezkl/friendly_ghost'
11
+ gem.license = 'MIT'
12
+
13
+ gem.files = `git ls-files`.split($\)
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = 'friendly_ghost'
16
+
17
+ gem.require_paths = ['lib']
18
+ gem.version = FriendlyGhost::VERSION
19
+
20
+ gem.add_dependency 'posix-spawn', '~> 0.3.6'
21
+ gem.add_dependency 'multi_json', '~> 1.7.2'
22
+
23
+ gem.add_development_dependency 'rake'
24
+ gem.add_development_dependency 'rspec'
25
+
26
+ gem.required_ruby_version = '>= 1.9'
27
+ end
@@ -0,0 +1,29 @@
1
+ require 'posix/spawn'
2
+ require 'multi_json'
3
+
4
+ module FriendlyGhost
5
+ class Runner
6
+ include POSIX::Spawn
7
+
8
+ attr_accessor :casper_path
9
+ attr_reader :process, :result
10
+
11
+ def initialize
12
+ @casper_path = `which casperjs`.strip
13
+ end
14
+
15
+ def command(args)
16
+ @process = Child.new("#{@casper_path} #{args}")
17
+
18
+ @result = parse_result
19
+ @result['status'] = @process.success?
20
+
21
+ @result
22
+ end
23
+
24
+ def parse_result
25
+ output = @process.out.split(/\n/).last.strip
26
+ MultiJson.load(output)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module FriendlyGhost
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'friendly_ghost/runner'
2
+ require 'friendly_ghost/version'
3
+
4
+ module FriendlyGhost
5
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ module FriendlyGhost
4
+ describe Runner do
5
+ let(:runner) { Runner.new }
6
+
7
+ describe 'setup' do
8
+ it 'should locate casperjs binary' do
9
+ runner.casper_path.should =~ /\/bin\/casperjs/
10
+ end
11
+ end
12
+
13
+ describe '#buy' do
14
+ let(:response) { runner.command arguments }
15
+
16
+ context 'success' do
17
+ let(:arguments) { 'test spec/support/json.js' }
18
+
19
+ it 'should return the status' do
20
+ response['status'].should be_true
21
+ end
22
+
23
+ it 'should return some (yet to be determined) hash' do
24
+ response['key'].should eq 'value'
25
+ end
26
+ end
27
+
28
+ context 'failure' do
29
+ let(:arguments) { 'test spec/support/fail.js' }
30
+
31
+ it 'should return the status' do
32
+ response['status'].should be_false
33
+ end
34
+
35
+ it 'should return an error message' do
36
+ response['error'].should eq 'Failed!'
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,13 @@
1
+ require './lib/friendly_ghost'
2
+
3
+ RSpec.configure do |config|
4
+ config.treat_symbols_as_metadata_keys_with_true_values = true
5
+ config.run_all_when_everything_filtered = true
6
+ config.filter_run :focus
7
+
8
+ # Run specs in random order to surface order dependencies. If you find an
9
+ # order dependency and want to debug it, you can fix the order by providing
10
+ # the seed, which is printed after each run.
11
+ # --seed 1234
12
+ config.order = 'random'
13
+ end
@@ -0,0 +1,14 @@
1
+ casper.start();
2
+
3
+ casper.wait(500, function() {
4
+ this.test.fail("I'm a failure. :(");
5
+ this.echo(JSON.stringify({ error: 'Failed!'}));
6
+ });
7
+
8
+ casper.run(function() {
9
+ if(this.test.getFailures().length >= 1) {
10
+ this.exit(-1);
11
+ } else {
12
+ this.exit(0);
13
+ }
14
+ });
@@ -0,0 +1,15 @@
1
+ casper.start();
2
+
3
+ casper.wait(500, function() {
4
+ var obj = { key: 'value' };
5
+ var json = JSON.stringify(obj);
6
+ this.echo(json);
7
+ });
8
+
9
+ casper.run(function() {
10
+ if(this.test.getFailures().length >= 1) {
11
+ this.exit(-1);
12
+ } else {
13
+ this.exit(0);
14
+ }
15
+ });
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: friendly_ghost
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ezekiel Templin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: posix-spawn
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.7.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.7.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: CasperJS commands run in processes spawned by Ruby
70
+ email:
71
+ - zeke@templ.in
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - Gemfile
79
+ - Guardfile
80
+ - README.md
81
+ - Rakefile
82
+ - friendly_ghost.gemspec
83
+ - lib/friendly_ghost.rb
84
+ - lib/friendly_ghost/runner.rb
85
+ - lib/friendly_ghost/version.rb
86
+ - spec/friendly_ghost/runner_spec.rb
87
+ - spec/spec_helper.rb
88
+ - spec/support/fail.js
89
+ - spec/support/json.js
90
+ homepage: https://github.com/ezkl/friendly_ghost
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '1.9'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.0.3
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Ruby runner for CasperJS
114
+ test_files:
115
+ - spec/friendly_ghost/runner_spec.rb
116
+ - spec/spec_helper.rb
117
+ - spec/support/fail.js
118
+ - spec/support/json.js
119
+ has_rdoc: