middleman-weinre 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c08a213ee039fcc0f9ead12d8f836e72080a9a87
4
+ data.tar.gz: 6266296e28c4b43e4fc76a36db2b96803a391d57
5
+ SHA512:
6
+ metadata.gz: 78645d5d96358348bdad19f37f22daa4e5ebbb35816f71a83349d09833d2c6617f47be871ed56b61cf0d7ea787a2a3ac75bf627683c7f07dcac2847aeca32cc2
7
+ data.tar.gz: f300ff3e7bbc8d6c9eebfcb189e40130f2a7f9b38c46e682fa4c936dd11f610e95f5db5b9c4480e36e1b412c27722774a68f86976d5dd19eef3b9cd8d55bb784
@@ -0,0 +1,8 @@
1
+ # Ignore bundler lock file
2
+ /Gemfile.lock
3
+
4
+ # Ignore pkg folder
5
+ /pkg
6
+
7
+ # Ignore coverage folder
8
+ /coverage
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "middleman-core", ">= 3.0.0"
4
+ gem "socket"
5
+
6
+ # Specify your gem's dependencies in middleman-packager.gemspec
7
+ gemspec
8
+
9
+
10
+ group :development do
11
+ gem "rake"
12
+ gem "rdoc"
13
+ gem "yard"
14
+ end
15
+
16
+ # group :test do
17
+ # gem "compass"
18
+ # gem "cucumber"
19
+ # gem "fivemat"
20
+ # gem "aruba"
21
+ # gem "rspec"
22
+ # gem "simplecov"
23
+ # end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Spencer Rhodes <spencer at spencer dash rhodes dot com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,62 @@
1
+ Middleman Weinre
2
+ ------------------
3
+
4
+ A simple extension to start the [Weinre](http://people.apache.org/~pmuellr/weinre/docs/latest/) server and a helper method to inject the script tag in your template/layout.
5
+
6
+ ## Requirements
7
+ - [Middleman](http://www.middlemanapp.com) 3.0.0+
8
+ - [Weinre](http://people.apache.org/~pmuellr/weinre/docs/latest/)
9
+
10
+ ## Installation
11
+
12
+ Add this to your Middleman project's Gemfile
13
+
14
+ ```ruby
15
+ gem "middleman-weinre"
16
+ ```
17
+ and run
18
+
19
+ ```bash
20
+ $ bundle install
21
+ ```
22
+
23
+ ## Usage
24
+ Activate the extension in your `config.rb` file:
25
+
26
+ ```ruby
27
+ activate :weinre
28
+ ```
29
+
30
+ ### Config examples
31
+ ```erb
32
+ activate :weinre,
33
+ :hostname => "localhost",
34
+ :port => 8080,
35
+ :bin => "/usr/local/bin/weinre"
36
+ ```
37
+
38
+ ### Template helpers
39
+
40
+ You can insert the [Weinre](http://people.apache.org/~pmuellr/weinre/docs/latest/) javascript tag in your template or layout with
41
+
42
+ ```ruby
43
+ <%= weinre_include_tag %>
44
+ ```
45
+
46
+ ## Options
47
+
48
+ ###### `:hostname` _(default: nil)_
49
+
50
+ Hostname to inject if not using the default of "localhost"
51
+
52
+ ###### `:port` _(default: 8080)_
53
+
54
+ The port to setup Weinre on when running the server and injecting the tag.
55
+
56
+ ###### `:bin` _(default: "/usr/local/bin/weinre")_
57
+
58
+ THe local path to the weinre bin
59
+
60
+ ## ToDo
61
+
62
+ - Auto inject script tag at end of layout
@@ -0,0 +1,99 @@
1
+ # Weinre Extension
2
+ # TODO: Auto-inject weinre marku?
3
+ # NOTE: Breaks /__middleman/config/ ?
4
+ # Drop <%= weinre_include_tag %> in your template where you want Weinre inserted
5
+ require "middleman-core"
6
+
7
+ if false
8
+ module Middleman
9
+ module Weinre
10
+ class << self
11
+ attr_reader :app
12
+ def options
13
+ @@options
14
+ end
15
+
16
+ def registered(app, options_hash={}, &block)
17
+ defaults = {
18
+ :port => 8080,
19
+ :hostname => nil,
20
+ :bin => '/usr/locale/bin/weinre'
21
+ }
22
+ @@options = defaults.merge(options_hash)
23
+ app.ready do
24
+ if :environment != :build
25
+ require 'socket'
26
+ hostname = @@options[:hostname] || UDPSocket.open {|s| s.connect("64.233.187.99", 1); s.addr.last}
27
+ if !@@options[:bin].blank?
28
+ wnr = fork do
29
+ exec "#{$WEINRE_BIN} --httpPort #{@@options[:port]} --boundHost #{hostname} &>/dev/null"
30
+ end
31
+ Process.detach(wnr)
32
+ puts "== Weinre is running at http://#{hostname}:#{@@options[:port]}"
33
+ # puts "== Weinre remote debugging is at http://#{hostname}:#{@@options[:port]}/client/#anonymous"
34
+ else
35
+ puts "== Winre was not found on your system. Could not auto-start it for you. :("
36
+ puts "== Type 'weinre' in a separate terminal to start the server"
37
+ end
38
+ # app.set :weinre_hostname, hostname
39
+ # app.set :weinre_port, options_hash[:port]
40
+ # app.set :weinre_bin, options_hash[:bin]
41
+ else
42
+ # Nothing
43
+ end
44
+ end
45
+ app.send :include, Helpers
46
+ end
47
+
48
+ alias :included :registered
49
+ end
50
+
51
+ module Helpers
52
+ def weinre_include_tag
53
+ "<script src=\"//#{config[:weinre_hostname]}:#{config[:weinre_port]}/target/target-script-min.js#anonymous\" defer></script>"
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+ else
60
+ class Weinre < Middleman::Extension
61
+ option :bin, nil, 'The weinre binary'
62
+ option :hostname, nil, 'hostname for weinre to use'
63
+ option :port, 8080, 'Port for weinre to use'
64
+
65
+ def initialize(app, options_hash={}, &block)
66
+ super
67
+ # app.extend WeinreMethods
68
+ app.ready do
69
+ if :environment != :build
70
+ require 'socket'
71
+ hostname = options_hash[:hostname] || UDPSocket.open {|s| s.connect("64.233.187.99", 1); s.addr.last}
72
+ if !options_hash[:bin].blank?
73
+ wnr = fork do
74
+ exec "#{$WEINRE_BIN} --httpPort #{options_hash[:port]} --boundHost #{hostname} &>/dev/null"
75
+ end
76
+ Process.detach(wnr)
77
+ puts "== Weinre is running at http://#{hostname}:#{options_hash[:port]}"
78
+ # puts "== Weinre remote debugging is at http://#{hostname}:#{options_hash[:port]}/client/#anonymous"
79
+ else
80
+ puts "== Winre was not found on your system. Could not auto-start it for you. :("
81
+ puts "== Type 'weinre' in a separate terminal to start the server"
82
+ end
83
+ app.set :weinre_hostname, hostname
84
+ app.set :weinre_port, options_hash[:port]
85
+ app.set :weinre_bin, options_hash[:bin]
86
+ else
87
+ # Nothing
88
+ end
89
+ end
90
+ end
91
+
92
+ helpers do
93
+ def weinre_include_tag
94
+ "<script src=\"//#{config[:weinre_hostname]}:#{config[:weinre_port]}/target/target-script-min.js#anonymous\" defer></script>"
95
+ end
96
+ end
97
+ end
98
+ ::Middleman::Extensions.register(:weinre, Weinre)
99
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'middleman-weinre'
6
+ s.version = '0.1.0'
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Spencer Rhodes"]
9
+ s.email = ["spencer at spencer dash rhodes dot com"]
10
+ s.homepage = "http://github.com/oobleck/middleman-weinre"
11
+ s.summary = "Auto starts Weinre remote debugger and prvides a simple insert helper to inject the script tag."
12
+ s.description = s.summary
13
+ s.license = "MIT"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ # The version of middleman-core your extension depends on
21
+ s.add_runtime_dependency("middleman-core", [">= 3.0.0"])
22
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-weinre
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Spencer Rhodes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: middleman-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ description: Auto starts Weinre remote debugger and prvides a simple insert helper
28
+ to inject the script tag.
29
+ email:
30
+ - spencer at spencer dash rhodes dot com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - .gitignore
36
+ - Gemfile
37
+ - LICENSE
38
+ - README.md
39
+ - lib/middleman-weinre.rb
40
+ - middleman-weinre.gemspec
41
+ homepage: http://github.com/oobleck/middleman-weinre
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.0.5
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Auto starts Weinre remote debugger and prvides a simple insert helper to
65
+ inject the script tag.
66
+ test_files: []