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 +4 -0
- data/Gemfile +4 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/app/views/gauges/_gauge.html.erb +2 -0
- data/gauge.gemspec +24 -0
- data/lib/gauge/engine.rb +6 -0
- data/lib/gauge/gauge_helpers.rb +8 -0
- data/lib/gauge/railtie.rb +9 -0
- data/lib/gauge/version.rb +3 -0
- data/lib/gauge.rb +5 -0
- data/test/helper.rb +0 -0
- data/vendor/assets/javascripts/gauge.js +2 -0
- data/vendor/assets/javascripts/raphael.js +5462 -0
- metadata +61 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
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"
|
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
|
data/lib/gauge/engine.rb
ADDED
data/lib/gauge.rb
ADDED
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"});}}};
|