gauge 0.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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gauge.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+
2
+ ## Installation
3
+
4
+ Add to your project Gemfile
5
+
6
+ ``` ruby
7
+
8
+ gem 'gauge', git: 'git@github.com:AgilionApps/gauges.git'
9
+
10
+ ```
11
+
12
+ gauge requires Raphael Javascript library. It is bundled with this Gem in case you don't already use it.
13
+ Just add the following dependencies to your app/assets/javascripts/application.js file
14
+
15
+
16
+ ``` coffeescript
17
+
18
+ //= require raphael
19
+ //= require gauge
20
+
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ To draw a gauge call the gauge erb tag with div, percent, fill and highlight properties like so...
26
+
27
+ ``` erb
28
+
29
+ <%= gauge div: "my-div", percent: "50", fill: "red", highlight: "blue" %>
30
+
31
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ <div id="<%= @options[:div] %>">&nbsp;</div>
2
+ <script>new gauge("<%= @options[:div] %>", "<%= @options[:percent] %>", "<%= @options[:fill] %>", "<%= @options[:highlight] %>");</script>
data/gauge.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "gauge/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "gauge"
7
+ s.version = Gauge::VERSION
8
+ s.authors = ["Sean Behan", "Tristan O'neil"]
9
+ s.email = ["bseanvt@gmail.com"]
10
+ s.homepage = "http://github.com/AgilionApps/gauges.git"
11
+ s.summary = %q{Pretty gauges for your Rails app.}
12
+ s.description = %q{Use this Gem to draw nice looking gauges.}
13
+
14
+ s.rubyforge_project = "gauge"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
@@ -0,0 +1,6 @@
1
+ module Gauge
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module Gauge
2
+ module GaugeHelpers
3
+ def gauge(*options)
4
+ @options = options.extract_options!
5
+ render "gauges/gauge"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'gauge/gauge_helpers'
2
+
3
+ module Gauge
4
+ class Railtie < Rails::Railtie
5
+ initializer "gauges.gauge_helpers" do
6
+ ActionView::Base.send(:include, Gauge::GaugeHelpers)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Gauge
2
+ VERSION = "0.0.1"
3
+ end
data/lib/gauge.rb ADDED
@@ -0,0 +1,5 @@
1
+ $:.unshift(File.dirname(__FILE__)+'/../lib/')
2
+
3
+ require "gauge/version"
4
+ require 'gauge/railtie'
5
+ require 'gauge/engine' if defined?(Rails && Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >=1)
data/test/helper.rb ADDED
File without changes
@@ -0,0 +1,2 @@
1
+ var arc=function(hPos,vPos,size,startingPoint,endingPoint){var startingPoint=startingPoint*Math.PI/180;var arcCoefficient=endingPoint*Math.PI/180;var endingPoint="M "+hPos+" "+vPos;var startingPoint=" L "+(hPos+size*Math.cos(startingPoint))+" "+(vPos-size*Math.sin(startingPoint));var curve=" A "+[size,size,0,0,1,hPos+size*Math.cos(arcCoefficient),vPos-size*Math.sin(arcCoefficient)].join(" ");return endingPoint+startingPoint+curve}
2
+ var gauge=function(div,percent,fill,highlight){this.canvas=Raphael(div,300,100);this.background=this.canvas.path(arc(80,80,76,-180,0)).attr({"fill":"#f2f2f2","stroke":"none"});this.fill=this.canvas.path(arc(80,80,76,-180,-180*(1+(percent/100)))).attr({"fill":fill,"stroke":"none"});this.indicator=this.canvas.rect(80,80,76,3).attr({"fill":highlight,"stroke":"none"}).rotate(180*(1+(percent/100)),80,80);this.indicator.rotation=180*(1+(percent/100));this.indicatorCircle=this.canvas.circle(80,80,6).attr({"fill":highlight,"stroke":"none"});return{fill:this.fill,indicator:this.indicator,canvas:this.canvas,update:function(percent){this.indicator.rotate(-this.indicator.rotation,80,80).rotate(180*(1+(percent/100)),80,80);this.indicator.rotation=180*(1+(percent/100));this.fill.animate({path:arc(80,80,76,-180,-180*(1+(percent/100)))},300,"elastic").attr({"fill":fill,"stroke":"none"});}}};