gasoline 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +16 -0
- data/LICENSE +22 -0
- data/README.md +21 -0
- data/Rakefile +18 -0
- data/bin/gasoline +8 -0
- data/example_drops.yml +14 -0
- data/gasoline.gemspec +19 -0
- data/lib/gasoline/cli.rb +39 -0
- data/lib/gasoline/drop.rb +80 -0
- data/lib/gasoline/jerrycan.rb +88 -0
- data/lib/gasoline/patchor.rb +90 -0
- data/lib/gasoline/texts.rb +41 -0
- data/lib/gasoline/version.rb +3 -0
- data/lib/gasoline.rb +14 -0
- data/test/drop_test.rb +63 -0
- data/test/example_drops.yml +4 -0
- data/test/helper.rb +15 -0
- data/test/jerrycan_test.rb +25 -0
- data/test/patchor_test.rb +38 -0
- metadata +87 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in gasoline.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :test do
|
7
|
+
# minitest provides a complete suite of testing facilities...
|
8
|
+
# [minitest](https://github.com/seattlerb/minitest)
|
9
|
+
gem 'minitest', '~> 3.3.0'
|
10
|
+
|
11
|
+
# Adds color to your MiniTest output
|
12
|
+
gem "minitest-rg", "~> 1.0.0"
|
13
|
+
|
14
|
+
# [mocha](http://gofreerange.com/mocha/docs)
|
15
|
+
gem 'mocha', '~> 0.12.2'
|
16
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 pjaspers
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Gasoline makes Campfire better
|
2
|
+
|
3
|
+
I'm an avid [Campfire](http://campfirenow.com) user and [Propane](http://propaneapp.com) is still my go to app for talking to it. At least on OSX, on iOS I'm using <plug>[Butane](http://getbutane.com)</plug>.
|
4
|
+
|
5
|
+
Since Propane 1.1.2 they've added a way to add some javascript, to augment the experience even more. Like adding avatars:
|
6
|
+
|
7
|
+
[Fancy screenshot](http://cl.ly/image/1r0T3h1q460I)
|
8
|
+
|
9
|
+
The only downside to that approach was managing the file. So that's where Gasoline comes in. It's a gem that installs the command line utility `gasoline` which can download gists and append them to the patch file.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
`gem install gasoline`
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
`gasoline ignite` will download the default drops and install them to the patch file.
|
18
|
+
|
19
|
+
## Contributing
|
20
|
+
|
21
|
+
Fork it! Improve it! Test it! Rewrite it! (technology)
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
desc 'Run Devise unit tests.'
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'lib'
|
8
|
+
t.libs << 'test'
|
9
|
+
t.pattern = 'test/**/*_test.rb'
|
10
|
+
t.verbose = true
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => :test
|
14
|
+
|
15
|
+
desc "Open an pry session with Gasoline loaded"
|
16
|
+
task :console do
|
17
|
+
sh "pry -I lib -r gasoline.rb"
|
18
|
+
end
|
data/bin/gasoline
ADDED
data/example_drops.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
:drops:
|
3
|
+
- :name: Avatars
|
4
|
+
:url: https://gist.github.com/065d1dc1906c153e4edc
|
5
|
+
:description: Adds avatars to friendly faces
|
6
|
+
- :name: Cloud App
|
7
|
+
:url: https://gist.github.com/431f7c803ddb0d751a40
|
8
|
+
:description: Adds support for Cloud.ly links
|
9
|
+
- :name: Flickr
|
10
|
+
:url: https://gist.github.com/6dcf1366df5203157fda
|
11
|
+
:description: Adds support for Flickr links
|
12
|
+
- :name: Instagram
|
13
|
+
:url: https://gist.github.com/3258692
|
14
|
+
:description: Instagram support
|
data/gasoline.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/gasoline/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["pjaspers"]
|
6
|
+
gem.email = ["piet@jaspe.rs"]
|
7
|
+
gem.description = %q{Gasoline makes Campfire even brighter}
|
8
|
+
gem.summary = %q{Gasoline aims to make managing the patch file easier.}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "gasoline"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Gasoline::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency("thor", ["~> 0.15.4"])
|
19
|
+
end
|
data/lib/gasoline/cli.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Gasoline
|
4
|
+
# [thor](http://github.com/wycats/thor)
|
5
|
+
class CLI < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
map "-i" => :ignite
|
9
|
+
map "-a" => :add
|
10
|
+
map "-l" => :list
|
11
|
+
map "-c" => :config
|
12
|
+
|
13
|
+
desc "ignite", "Downloads and patches the file"
|
14
|
+
def ignite
|
15
|
+
Gasoline::Patchor.new.patch_it_chewie!
|
16
|
+
say_status :ok, "I have patched the patch file"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "list", "-l, Current installed drops of gasoline"
|
20
|
+
def list
|
21
|
+
first_line = ["Currently using these drops of gasoline:"]
|
22
|
+
installed_drops = Gasoline::Patchor.new.drops.collect(&:to_s)
|
23
|
+
say (first_line + installed_drops).join("\n\t- ")
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "add NAME URL description", "-a, Adds a drop to the config"
|
27
|
+
def add(name, url, description)
|
28
|
+
can = Gasoline::Jerrycan.new
|
29
|
+
can.add_drops([{:name => name, :url => url, :description => description}])
|
30
|
+
can.save
|
31
|
+
say "Added #{name} - #{url}"
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "config", "-c, Shows current config"
|
35
|
+
def config
|
36
|
+
say File.open(Gasoline::Jerrycan::YAML_FILE).read
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Gasoline
|
2
|
+
# A drop of Gasoline is a glorified hash that knows how to
|
3
|
+
# retrieve the javascript needed to make the Campfire even
|
4
|
+
# shinier.
|
5
|
+
#
|
6
|
+
# Since Github's gists are pretty much the easiest way to
|
7
|
+
# share pieces of code, Drop uses them for all things JS.
|
8
|
+
class Drop
|
9
|
+
|
10
|
+
attr_accessor :name, :url, :description
|
11
|
+
|
12
|
+
def initialize(name, url, description)
|
13
|
+
@name = name
|
14
|
+
@url = url
|
15
|
+
@description = description
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
"%s: %s" % [@name, @description]
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_hash
|
23
|
+
{:name => @name, :url => @url, :description => @description}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Takes the hash as usually found in the Jerrycan and
|
27
|
+
# creates a drop from it.
|
28
|
+
#
|
29
|
+
# Returns a Drop
|
30
|
+
def self.new_from_yml(hash)
|
31
|
+
new(hash[:name], hash[:url], hash[:description])
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the raw url for the specified gist
|
35
|
+
def raw_gist_url
|
36
|
+
@url.gsub("gist.github.com/", "raw.github.com/gist/")
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns the javascript from the gist URL.
|
40
|
+
def download_content
|
41
|
+
puts "Downloading #{@name} (#{@url})"
|
42
|
+
open(raw_gist_url).read
|
43
|
+
end
|
44
|
+
|
45
|
+
# The header that will be displayed above the drop in the
|
46
|
+
# patched file.
|
47
|
+
#
|
48
|
+
# Returns a String
|
49
|
+
def header
|
50
|
+
<<HEADER
|
51
|
+
/*
|
52
|
+
* #{@name}
|
53
|
+
* #{@description}
|
54
|
+
*
|
55
|
+
*/
|
56
|
+
HEADER
|
57
|
+
end
|
58
|
+
|
59
|
+
# Fetches the JS content and adds a header to it, ready to be
|
60
|
+
# inserted in the patchor file.
|
61
|
+
#
|
62
|
+
# force_refresh - true will redownload the JS
|
63
|
+
#
|
64
|
+
# Returns a String
|
65
|
+
def patch(force_refresh = false)
|
66
|
+
@js ||= download_content
|
67
|
+
@js = download_content if force_refresh
|
68
|
+
|
69
|
+
<<PATCH
|
70
|
+
|
71
|
+
#{header}
|
72
|
+
#{@js}
|
73
|
+
|
74
|
+
|
75
|
+
PATCH
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Gasoline
|
2
|
+
# Gasoline drops are stored in a Jerrycan (safety first), in this case
|
3
|
+
# it is disguised as a yaml file, stored in the users' home folder.
|
4
|
+
#
|
5
|
+
# Not directly in the home folder but in the `.config/gasoline` folder,
|
6
|
+
# since [Rob doesn't like them there](https://plus.google.com/101960720994009339267/posts/R58WgWwN9jp)
|
7
|
+
# and he seems to know this UNIX thingie.
|
8
|
+
|
9
|
+
class Jerrycan
|
10
|
+
YAML_FILE = "#{ENV['HOME']}/.config/gasoline/drops.yml"
|
11
|
+
|
12
|
+
attr_writer :drops
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@drops = []
|
16
|
+
bootstrap
|
17
|
+
add_drops(YAML.load_file(yaml_file)[:drops]) rescue nil
|
18
|
+
end
|
19
|
+
|
20
|
+
# Adds a drop of gasoline to the jerrycan
|
21
|
+
#
|
22
|
+
# drop - A Gasoline::Drop instance
|
23
|
+
#
|
24
|
+
# Returns the current list of drops
|
25
|
+
def add_drop(drop)
|
26
|
+
@drops << drop
|
27
|
+
end
|
28
|
+
|
29
|
+
# Takes an array of hashes and fills the can with `Drop`s
|
30
|
+
#
|
31
|
+
# Hash should be:
|
32
|
+
# {:name => "k", :url => "url", :description => "desc"}
|
33
|
+
#
|
34
|
+
# Returns nothing
|
35
|
+
def add_drops(array)
|
36
|
+
array.each do |h|
|
37
|
+
add_drop Gasoline::Drop.new_from_yml(h)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def yaml_file
|
42
|
+
YAML_FILE
|
43
|
+
end
|
44
|
+
|
45
|
+
# Will create the config file (if needed)
|
46
|
+
def bootstrap
|
47
|
+
return if File.exist?(yaml_file)
|
48
|
+
|
49
|
+
FileUtils.mkdir_p(File.split(yaml_file).first)
|
50
|
+
FileUtils.cp(example_config, yaml_file)
|
51
|
+
end
|
52
|
+
|
53
|
+
def example_config
|
54
|
+
File.join(File.dirname(__FILE__), "../../example_drops.yml")
|
55
|
+
end
|
56
|
+
|
57
|
+
# All the `Drop`s in this Jerrycan.
|
58
|
+
#
|
59
|
+
# Returns an array of `Drop`s
|
60
|
+
def drops
|
61
|
+
@drops
|
62
|
+
end
|
63
|
+
|
64
|
+
# Goes through all the drops and squeezes a hash out of them
|
65
|
+
# then cunningly makes a yaml out of those.
|
66
|
+
#
|
67
|
+
# Returns a yaml (as a String)
|
68
|
+
def to_yaml
|
69
|
+
{:drops => drops.collect(&:to_hash)}.to_yaml
|
70
|
+
end
|
71
|
+
|
72
|
+
# Writes the can to the yaml config file.
|
73
|
+
def save
|
74
|
+
File.open(yaml_file, 'w') {|f| f.write(to_yaml) }
|
75
|
+
end
|
76
|
+
|
77
|
+
# Mainly used to quickly load the hash I used previously back
|
78
|
+
# when this was just a onefile script. Those were the days.
|
79
|
+
#
|
80
|
+
# Returns a Jerrycan
|
81
|
+
def self.load_from_array(array)
|
82
|
+
can = new
|
83
|
+
can.add_drops(array)
|
84
|
+
can
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Gasoline
|
2
|
+
# The Patchor will do all the patching on the Propane support
|
3
|
+
# file, it finds (and creates if needed) the file, adds the
|
4
|
+
# Propane header, and then adds all the drops from the jerrycan.
|
5
|
+
class Patchor
|
6
|
+
PATCHOR_FILE = "#{ENV['HOME']}/Library/Application Support/Propane/unsupported/caveatPatchor.js"
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@lines = []
|
10
|
+
bootstrap
|
11
|
+
load_lines
|
12
|
+
end
|
13
|
+
|
14
|
+
def patchor_file
|
15
|
+
PATCHOR_FILE
|
16
|
+
end
|
17
|
+
|
18
|
+
# Will create the Propane, caveatPatchor.js file
|
19
|
+
def bootstrap
|
20
|
+
return if File.exist?(patchor_file)
|
21
|
+
|
22
|
+
FileUtils.mkdir_p(File.split(patchor_file).first)
|
23
|
+
FileUtils.touch(patchor_file)
|
24
|
+
File.open(patchor_file, "w") do |f|
|
25
|
+
f.write(Gasoline::Texts::propane_header)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Current lines in memory
|
30
|
+
#
|
31
|
+
# Returns an array of lines
|
32
|
+
def lines
|
33
|
+
@lines
|
34
|
+
end
|
35
|
+
|
36
|
+
# Loads the entire file into memory
|
37
|
+
def load_lines
|
38
|
+
@lines = File.readlines(patchor_file)
|
39
|
+
end
|
40
|
+
|
41
|
+
# The index of the line matching the cut snippet, if it can't
|
42
|
+
# be found we'll take the last line.
|
43
|
+
#
|
44
|
+
# Returns an int
|
45
|
+
def cut_line_index
|
46
|
+
@lines.find_index{|line| line =~ /#{Gasoline::Texts::cut_here_line}/} || @lines.length
|
47
|
+
end
|
48
|
+
|
49
|
+
# An instance of the Jerrycan, mainly added to have quick
|
50
|
+
# access to it, while developing.
|
51
|
+
#
|
52
|
+
# Returns a `Jerrycan` instance
|
53
|
+
def jerrycan
|
54
|
+
@jerrycan ||= Gasoline::Jerrycan.new
|
55
|
+
end
|
56
|
+
|
57
|
+
# The contents of our Jerrycan, laid bare to be patched.
|
58
|
+
#
|
59
|
+
# Returns an array of `Drop`s
|
60
|
+
def drops
|
61
|
+
jerrycan.drops
|
62
|
+
end
|
63
|
+
|
64
|
+
# Transform the @lines to have:
|
65
|
+
#
|
66
|
+
# 1. All the lines above the cut
|
67
|
+
# 2. The cut here snippet
|
68
|
+
# 3. All patches from the drops. (will download them)
|
69
|
+
#
|
70
|
+
# Returns an array of lines
|
71
|
+
def patch_it_chewie
|
72
|
+
to_keep = @lines[0...cut_line_index]
|
73
|
+
snippet = [Gasoline::Texts::cut_here_snippet]
|
74
|
+
to_add = drops.collect {|d| d.patch}
|
75
|
+
@lines = (to_keep + snippet + to_add)
|
76
|
+
end
|
77
|
+
|
78
|
+
# First fills up the @lines instance, then saves the file
|
79
|
+
def patch_it_chewie!
|
80
|
+
patch_it_chewie
|
81
|
+
save
|
82
|
+
end
|
83
|
+
|
84
|
+
# Writes the file to disk.
|
85
|
+
def save
|
86
|
+
File.open("file.tmp", "w") {|f| f.write(@lines.join(""))}
|
87
|
+
FileUtils.mv("file.tmp", patchor_file)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Gasoline
|
2
|
+
module Texts
|
3
|
+
class << self
|
4
|
+
def cut_here_line
|
5
|
+
"_.:Gasoline Snippet:._"
|
6
|
+
end
|
7
|
+
|
8
|
+
def cut_here_snippet
|
9
|
+
<<SNIPPET
|
10
|
+
//#{cut_here_line}
|
11
|
+
//
|
12
|
+
// Anything below this line will be replaced by the gasoline gem.
|
13
|
+
//
|
14
|
+
|
15
|
+
SNIPPET
|
16
|
+
end
|
17
|
+
|
18
|
+
def propane_header
|
19
|
+
<<HEADER
|
20
|
+
/*
|
21
|
+
As of version 1.1.2, Propane will load and execute the contents of
|
22
|
+
~Library/Application Support/Propane/unsupported/caveatPatchor.js
|
23
|
+
immediately following the execution of its own enhancer.js file.
|
24
|
+
|
25
|
+
You can use this mechanism to add your own customizations to Campfire
|
26
|
+
in Propane.
|
27
|
+
|
28
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
29
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
30
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
31
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
32
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
33
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
34
|
+
THE SOFTWARE.
|
35
|
+
*/
|
36
|
+
|
37
|
+
HEADER
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/gasoline.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require 'open-uri'
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
require "gasoline/version"
|
6
|
+
require "gasoline/jerrycan"
|
7
|
+
require "gasoline/drop"
|
8
|
+
require "gasoline/patchor"
|
9
|
+
require "gasoline/texts"
|
10
|
+
require "gasoline/cli"
|
11
|
+
|
12
|
+
module Gasoline
|
13
|
+
|
14
|
+
end
|
data/test/drop_test.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe Gasoline::Drop do
|
4
|
+
|
5
|
+
describe "basic setup" do
|
6
|
+
before do
|
7
|
+
@drop = Gasoline::Drop.new("Fire", "http://water.com", "Burn")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have a name" do
|
11
|
+
assert_equal "Fire", @drop.name
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a url" do
|
15
|
+
assert_equal "http://water.com", @drop.url
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have a description" do
|
19
|
+
assert_equal "Burn", @drop.description
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "loading from hash" do
|
24
|
+
before do
|
25
|
+
@h = {
|
26
|
+
:name => "Fire",
|
27
|
+
:url => "http://water.com",
|
28
|
+
:description => "Desc"
|
29
|
+
}
|
30
|
+
@drop = Gasoline::Drop.new_from_yml(@h)
|
31
|
+
end
|
32
|
+
|
33
|
+
[:name, :url, :description].each do |s|
|
34
|
+
it "should have a #{s}" do
|
35
|
+
assert_equal @h[s], @drop.send(s)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "getting the content" do
|
41
|
+
before do
|
42
|
+
@url = "https://gist.github.com/3258692"
|
43
|
+
@drop = Gasoline::Drop.new("xyz", @url, "zyx")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should get the raw gist url" do
|
47
|
+
assert_equal "https://raw.github.com/gist/3258692", @drop.raw_gist_url
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should set header with name" do
|
51
|
+
assert_match "xyz", @drop.header
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should set header with description" do
|
55
|
+
assert_match "zyx", @drop.description
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should try to download when asked for patch" do
|
59
|
+
@drop.expects(:download_content).returns("ZE JS CONTENT")
|
60
|
+
assert_match "ZE JS", @drop.patch
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "mocha"
|
5
|
+
|
6
|
+
begin
|
7
|
+
# [turn](http://rubygems.org/gems/turn)
|
8
|
+
require 'turn/autorun'
|
9
|
+
rescue LoadError
|
10
|
+
end
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
|
15
|
+
require 'gasoline'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe Gasoline::Jerrycan do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Gasoline::Jerrycan.any_instance.stubs(:save).returns(true)
|
7
|
+
Gasoline::Jerrycan.any_instance.stubs(:bootstrap).returns(true)
|
8
|
+
yaml = File.join(File.dirname(__FILE__), "example_drops.yml")
|
9
|
+
Gasoline::Jerrycan.any_instance.stubs(:yaml_file).returns(yaml)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "loading drops" do
|
13
|
+
before do
|
14
|
+
@jerry = Gasoline::Jerrycan.new
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should load drops from config file on init" do
|
18
|
+
assert_equal 1, @jerry.drops.count
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should load name for drops from config" do
|
22
|
+
assert_equal "Sounds", @jerry.drops.first.name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe Gasoline::Patchor do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Gasoline::Patchor.any_instance.stubs(:save).returns(true)
|
7
|
+
Gasoline::Patchor.any_instance.stubs(:bootstrap).returns(true)
|
8
|
+
|
9
|
+
js = File.join(File.dirname(__FILE__), "patchor.js")
|
10
|
+
Gasoline::Patchor.any_instance.stubs(:patchor_file).returns(js)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "loading patchor" do
|
14
|
+
before do
|
15
|
+
@patchor = Gasoline::Patchor.new
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should load the js file into lines" do
|
19
|
+
assert @patchor.lines.count > 1
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "patching the patch" do
|
25
|
+
before do
|
26
|
+
@patchor = Gasoline::Patchor.new
|
27
|
+
drop = mock()
|
28
|
+
drop.expects(:patch).returns("ZE PATCH")
|
29
|
+
@patchor.expects(:drops).returns([drop])
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should download the patches and add them to lines" do
|
33
|
+
@patchor.patch_it_chewie
|
34
|
+
assert @patchor.lines.include?("ZE PATCH")
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gasoline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- pjaspers
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.15.4
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.15.4
|
30
|
+
description: Gasoline makes Campfire even brighter
|
31
|
+
email:
|
32
|
+
- piet@jaspe.rs
|
33
|
+
executables:
|
34
|
+
- gasoline
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- bin/gasoline
|
44
|
+
- example_drops.yml
|
45
|
+
- gasoline.gemspec
|
46
|
+
- lib/gasoline.rb
|
47
|
+
- lib/gasoline/cli.rb
|
48
|
+
- lib/gasoline/drop.rb
|
49
|
+
- lib/gasoline/jerrycan.rb
|
50
|
+
- lib/gasoline/patchor.rb
|
51
|
+
- lib/gasoline/texts.rb
|
52
|
+
- lib/gasoline/version.rb
|
53
|
+
- test/drop_test.rb
|
54
|
+
- test/example_drops.yml
|
55
|
+
- test/helper.rb
|
56
|
+
- test/jerrycan_test.rb
|
57
|
+
- test/patchor_test.rb
|
58
|
+
homepage: ''
|
59
|
+
licenses: []
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.8.24
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Gasoline aims to make managing the patch file easier.
|
82
|
+
test_files:
|
83
|
+
- test/drop_test.rb
|
84
|
+
- test/example_drops.yml
|
85
|
+
- test/helper.rb
|
86
|
+
- test/jerrycan_test.rb
|
87
|
+
- test/patchor_test.rb
|