gastly 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 327d0941c591a2f1b07c19b013307d917f9c744e
4
- data.tar.gz: 0f87c8fc8905ffc76e0dccb6395302214f13ca71
3
+ metadata.gz: a44ef15ac998bc80a529ceb87f868e53c8ce61bf
4
+ data.tar.gz: 75a64b654c9031160a85aff58f5ef47b2f1add23
5
5
  SHA512:
6
- metadata.gz: bd7e4f76405c0c344427fc052950ff8b36abf56269becf515cd278527a2af2e09dd48f31891fa1646653117e26c52d1146edbe273f4316f4384c5b449d79c8cc
7
- data.tar.gz: c49f95e949893ef171c9d6d9366aa327d10300db95cc8e91b03db5a82717c6981855f097973be6b1a640d7096727a066ad30c15919ed369f1103743dc0bd7ec5
6
+ metadata.gz: 8d110af0420f000a7851a1c21855ec111d4924ce34df3b5677fb8db1c57835fc541a96596e5f2c5fc1366955ba16b69a4df1c66db9ec5a40d25430cadc18ad78
7
+ data.tar.gz: 83e1dd27eb9f8122bc86764c03a2c837f512742300d86e905b188fe3f934e2e60139e091b0d0ae43d4122f2b76c0c1966448efdf46c2eb435d33522dae397da0
@@ -0,0 +1,27 @@
1
+ AllCops:
2
+ # Cop names are not displayed in offense messages by default. Change behavior
3
+ # by overriding DisplayCopNames, or by giving the -D/--display-cop-names
4
+ # option.
5
+ DisplayCopNames: true
6
+ # Style guide URLs are not displayed in offense messages by default. Change
7
+ # behavior by overriding DisplayStyleGuide, or by giving the
8
+ # -S/--display-style-guide option.
9
+ DisplayStyleGuide: true
10
+ Exclude:
11
+ - 'bin/**/*'
12
+ - 'spec/**/*'
13
+ - 'vendor/**/*'
14
+
15
+ # Missing top-level class documentation comment
16
+ Style/Documentation:
17
+ Enabled: false
18
+
19
+ # Line is too long
20
+ # https://github.com/bbatsov/ruby-style-guide#80-character-limits
21
+ Metrics/LineLength:
22
+ Max: 180 # 80
23
+
24
+ # Assignment Branch Condition size for perform is too high
25
+ # http://c2.com/cgi/wiki?AbcMetric
26
+ Metrics/AbcSize:
27
+ Enabled: false
@@ -1,3 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.3
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.7
6
+ - 2.2.3
@@ -1,3 +1,9 @@
1
+ ## 0.2.3 (23/11/2015)
2
+
3
+ ### Enhancements
4
+
5
+ * Suppress client errors
6
+
1
7
  ## 0.2.2 (19/08/2015)
2
8
 
3
9
  ### Enhancements
@@ -29,4 +35,4 @@
29
35
 
30
36
  ## 0.1.0 (13/07/2015)
31
37
 
32
- * Initial release
38
+ * Initial release
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Gastly
2
2
 
3
- Create screenshots or previews of web pages using Gastly. Under the hood Phantom.js and MiniMagick. Gastly, I choose you!
3
+ [![Gem Version](https://badge.fury.io/rb/gastly.svg)](http://badge.fury.io/rb/gastly)
4
+ [![Dependency Status](https://gemnasium.com/mgrachev/gastly.svg)](https://gemnasium.com/mgrachev/gastly)
5
+ [![Code Climate](https://codeclimate.com/github/mgrachev/gastly/badges/gpa.svg)](https://codeclimate.com/github/mgrachev/gastly)
6
+
7
+ Create screenshots or previews of web pages using Gastly. Under the hood [Phantom.js](https://github.com/ariya/phantomjs/) and [MiniMagick](https://github.com/minimagick/minimagick). Gastly, I choose you!
4
8
 
5
9
  ![Gastly](https://github.com/mgrachev/gastly/raw/master/gastly.png)
6
10
 
@@ -35,7 +39,7 @@ screenshot.browser_width = 1280 # Default: 1440px
35
39
  screenshot.browser_height = 780 # Default: 900px
36
40
  screenshot.timeout = 1000 # Default: 0 seconds
37
41
  screenshot.cookies = { user_id: 1, auth_token: 'abcd' } # If you need
38
- screenshot.proxy_host = '10.10.10.1' # If you want to use a proxy
42
+ screenshot.proxy_host = '10.10.10.1' # If you want to use a http proxy
39
43
  screenshot.proxy_port = '8080'
40
44
  image = screenshot.capture
41
45
  ```
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Mikhail Grachev']
10
10
  spec.email = ['work@mgrachev.com']
11
11
 
12
- spec.summary = %q{Create screenshots or previews of web pages using Gastly. Gastly, I choose you!}
13
- spec.description = %q{Create screenshots or previews of web pages using Gastly. Under the hood Phantom.js and MiniMagick.}
12
+ spec.summary = 'Create screenshots or previews of web pages using Gastly. Gastly, I choose you!'
13
+ spec.description = 'Create screenshots or previews of web pages using Gastly. Under the hood Phantom.js and MiniMagick.'
14
14
  spec.homepage = 'https://github.com/mgrachev/gastly'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.9'
22
22
  spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rubocop'
23
24
 
24
25
  spec.add_dependency 'phantomjs2', '~> 2.0'
25
26
  spec.add_dependency 'mini_magick', '~> 4.2'
@@ -4,7 +4,6 @@ require_relative 'gastly/exceptions'
4
4
  require_relative 'gastly/version'
5
5
 
6
6
  module Gastly
7
-
8
7
  def screenshot(url, **kwargs)
9
8
  Screenshot.new(url, **kwargs)
10
9
  end
@@ -14,4 +13,4 @@ module Gastly
14
13
  end
15
14
 
16
15
  module_function :screenshot, :capture
17
- end
16
+ end
@@ -7,5 +7,5 @@ module Gastly
7
7
  end
8
8
  end
9
9
 
10
- PhantomJSError = Class.new(StandardError)
11
- end
10
+ PhantomJSError = Class.new(RuntimeError)
11
+ end
@@ -2,7 +2,6 @@ require 'mini_magick'
2
2
 
3
3
  module Gastly
4
4
  class Image
5
-
6
5
  attr_reader :file
7
6
 
8
7
  def initialize(tempfile)
@@ -23,6 +22,5 @@ module Gastly
23
22
  @file.write(output)
24
23
  output
25
24
  end
26
-
27
25
  end
28
- end
26
+ end
@@ -4,7 +4,6 @@ require 'active_support/core_ext/object/blank'
4
4
 
5
5
  module Gastly
6
6
  class Screenshot
7
-
8
7
  SCRIPT_PATH = File.expand_path('../script.js', __FILE__)
9
8
  DEFAULT_TIMEOUT = 0
10
9
  DEFAULT_BROWSER_WIDTH = 1440
@@ -81,8 +80,7 @@ module Gastly
81
80
  when /^RuntimeError:(.+)/m then Gastly::PhantomJSError
82
81
  end
83
82
 
84
- raise error, $1
83
+ fail error, Regexp.last_match(1)
85
84
  end
86
-
87
85
  end
88
- end
86
+ end
@@ -1,15 +1,15 @@
1
1
  function extractDomain(url){
2
- var domain;
3
- // Remove protocol
4
- if (url.indexOf("://") > -1) {
5
- domain = url.split('/')[2];
6
- } else {
7
- domain = url.split('/')[0];
8
- }
9
- // Remove port number
10
- domain = domain.split(':')[0];
11
-
12
- return domain;
2
+ var domain;
3
+ // Remove protocol
4
+ if (url.indexOf("://") > -1) {
5
+ domain = url.split('/')[2];
6
+ } else {
7
+ domain = url.split('/')[0];
8
+ }
9
+ // Remove port number
10
+ domain = domain.split(':')[0];
11
+
12
+ return domain;
13
13
  }
14
14
 
15
15
  var i, pair,
@@ -18,72 +18,76 @@ var i, pair,
18
18
  page = require('webpage').create();
19
19
 
20
20
  system.args.forEach(function(arg) {
21
- pair = arg.split(/=(.*)/);
22
- args[pair[0]] = pair[1];
21
+ pair = arg.split(/=(.*)/);
22
+ args[pair[0]] = pair[1];
23
23
  });
24
24
 
25
25
  if (args.cookies !== undefined) {
26
- var cookiesPair = args.cookies.split(',');
26
+ var cookiesPair = args.cookies.split(',');
27
27
 
28
- cookiesPair.forEach(function(cookie) {
29
- pair = cookie.split(/=(.*)/);
28
+ cookiesPair.forEach(function(cookie) {
29
+ pair = cookie.split(/=(.*)/);
30
30
 
31
- page.addCookie({
32
- 'name': pair[0],
33
- 'value': pair[1],
34
- 'path': '/',
35
- 'domain': extractDomain(args.url)
36
- });
31
+ page.addCookie({
32
+ 'name': pair[0],
33
+ 'value': pair[1],
34
+ 'path': '/',
35
+ 'domain': extractDomain(args.url)
37
36
  });
37
+ });
38
38
  }
39
39
 
40
40
  phantom.onError = function(message, trace){
41
- var messageStack = ['RuntimeError:' + message];
41
+ var messageStack = ['RuntimeError:' + message];
42
42
 
43
- if (trace && trace.length) {
44
- messageStack.push('Trace:');
43
+ if (trace && trace.length) {
44
+ messageStack.push('Trace:');
45
45
 
46
- trace.forEach(function(t) {
47
- messageStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function +'")' : ''));
48
- });
49
- }
46
+ trace.forEach(function(t) {
47
+ messageStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function +'")' : ''));
48
+ });
49
+ }
50
50
 
51
- console.log(messageStack.join('\n'));
52
- phantom.exit(1);
51
+ console.log(messageStack.join('\n'));
52
+ phantom.exit(1);
53
53
  }
54
54
 
55
+ // Suppress client errors
56
+ page.onError = function(message, trace){
57
+ };
58
+
55
59
  page.open(args.url, function(status){
56
- if(status !== 'success') {
57
- console.log('FetchError:' + args.url);
58
- phantom.exit();
59
- } else {
60
- window.setTimeout(function(){
61
- page.viewportSize = { width: args.width, height: args.height };
62
-
63
- if (args.selector !== undefined){
64
- // Returns ClientRect object or null if selector not found
65
- var clipRect = page.evaluate(function(s){
66
- var result, selector = document.querySelector(s);
67
-
68
- if (selector !== null) {
69
- result = selector.getBoundingClientRect();
70
- }
71
-
72
- return result;
73
- }, args.selector);
74
-
75
- if (clipRect !== null) {
76
- page.clipRect = {
77
- top: clipRect.top,
78
- left: clipRect.left,
79
- width: clipRect.width,
80
- height: clipRect.height
81
- };
82
- }
83
- }
84
-
85
- page.render(args.output);
86
- phantom.exit();
87
- }, args.timeout);
88
- }
89
- });
60
+ if(status !== 'success') {
61
+ console.log('FetchError:' + args.url);
62
+ phantom.exit();
63
+ } else {
64
+ window.setTimeout(function(){
65
+ page.viewportSize = { width: args.width, height: args.height };
66
+
67
+ if (args.selector !== undefined){
68
+ // Returns ClientRect object or null if selector not found
69
+ var clipRect = page.evaluate(function(s){
70
+ var result, selector = document.querySelector(s);
71
+
72
+ if (selector !== null) {
73
+ result = selector.getBoundingClientRect();
74
+ }
75
+
76
+ return result;
77
+ }, args.selector);
78
+
79
+ if (clipRect !== null) {
80
+ page.clipRect = {
81
+ top: clipRect.top,
82
+ left: clipRect.left,
83
+ width: clipRect.width,
84
+ height: clipRect.height
85
+ };
86
+ }
87
+ }
88
+
89
+ page.render(args.output);
90
+ phantom.exit();
91
+ }, args.timeout);
92
+ }
93
+ });
@@ -1,3 +1,3 @@
1
1
  module Gastly
2
- VERSION = '0.2.2'
3
- end
2
+ VERSION = '0.2.3'
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gastly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikhail Grachev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-19 00:00:00.000000000 Z
11
+ date: 2015-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
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'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: phantomjs2
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +103,7 @@ extensions: []
89
103
  extra_rdoc_files: []
90
104
  files:
91
105
  - ".gitignore"
106
+ - ".rubocop.yml"
92
107
  - ".travis.yml"
93
108
  - CHANGELOG.md
94
109
  - Gemfile
@@ -123,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
138
  version: '0'
124
139
  requirements: []
125
140
  rubyforge_project:
126
- rubygems_version: 2.4.7
141
+ rubygems_version: 2.4.5
127
142
  signing_key:
128
143
  specification_version: 4
129
144
  summary: Create screenshots or previews of web pages using Gastly. Gastly, I choose