gas_stats 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Fredrik Wallgren
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Gas stats
2
+
3
+ Gem to keep track of your usage of [gas](http://walle.github.com/gas/).
4
+
5
+ Reference implementation of a plugin to gas.
6
+
7
+ ## Installation
8
+
9
+ The best way to install gas_stats is with RubyGems:
10
+
11
+ $ [sudo] gem install gas_stats
12
+
13
+ You can install from source:
14
+
15
+ $ cd gas_stats/
16
+ $ bundle
17
+ $ rake install
18
+
19
+ ## Usage
20
+
21
+ Check statistics using
22
+
23
+ $ gas stats
data/bin/gas-stats ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../lib/')
4
+
5
+ require 'gas_stats'
6
+
7
+ GasStats.stats
data/bin/gas-stats-add ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../lib/')
4
+
5
+ require 'gas_stats'
6
+
7
+ GasStats.add
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../lib/')
4
+
5
+ require 'gas_stats'
6
+
7
+ GasStats.delete
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../lib/')
4
+
5
+ require 'gas_stats'
6
+
7
+ GasStats.import
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../lib/')
4
+
5
+ require 'gas_stats'
6
+
7
+ GasStats.list
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../lib/')
4
+
5
+ require 'gas_stats'
6
+
7
+ GasStats.show
data/bin/gas-stats-use ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../lib/')
4
+
5
+ require 'gas_stats'
6
+
7
+ GasStats.use
@@ -0,0 +1,6 @@
1
+ module GasStats
2
+
3
+ VERSION = '0.1.0'
4
+
5
+ end
6
+
data/lib/gas_stats.rb ADDED
@@ -0,0 +1,65 @@
1
+ require 'gas'
2
+ require 'yaml'
3
+ require 'fileutils'
4
+
5
+ module GasStats
6
+
7
+ @config_file_path = File.join GAS_DIRECTORY, 'gas_stats.yaml'
8
+ File.open(@config_file_path, 'w+') { |f| f.write('---') } unless File.exists? @config_file_path
9
+ @config = YAML.load_file(@config_file_path)
10
+ @config ||= {}
11
+
12
+ def self.stats
13
+ if @config
14
+ puts 'Gas statistics:'
15
+ [:add, :delete, :import, :list, :show, :use].each do |key|
16
+ puts " #{key.to_s}: #{(@config[key.to_s] ? @config[key.to_s] : 0)}"
17
+ end
18
+ else
19
+ puts 'No statistics yet'
20
+ end
21
+ end
22
+
23
+ def self.add
24
+ update_key 'add'
25
+ end
26
+
27
+ def self.delete
28
+ update_key 'delete'
29
+ end
30
+
31
+ def self.import
32
+ update_key 'import'
33
+ end
34
+
35
+ def self.list
36
+ update_key 'list'
37
+ end
38
+
39
+ def self.show
40
+ update_key 'show'
41
+ end
42
+
43
+ def self.use
44
+ update_key 'use'
45
+ end
46
+
47
+ private
48
+
49
+ def self.save!
50
+ File.open(@config_file_path, 'w+') do |f|
51
+ f.write YAML::dump(@config)
52
+ end
53
+ end
54
+
55
+ def self.update_key(key)
56
+ if @config[key]
57
+ @config[key] = @config[key].to_i + 1
58
+ else
59
+ @config[key] = 1
60
+ end
61
+
62
+ save!
63
+ end
64
+
65
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gas_stats
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Fredrik Wallgren
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gas
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.2
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: 1.0.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Keep track of your gas usage. Stores statistics for built in commands
63
+ in gas
64
+ email: fredrik.wallgren@gmail.com
65
+ executables:
66
+ - gas-stats
67
+ - gas-stats-add
68
+ - gas-stats-delete
69
+ - gas-stats-import
70
+ - gas-stats-list
71
+ - gas-stats-show
72
+ - gas-stats-use
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - README.md
76
+ - LICENSE
77
+ files:
78
+ - bin/gas-stats
79
+ - bin/gas-stats-add
80
+ - bin/gas-stats-delete
81
+ - bin/gas-stats-import
82
+ - bin/gas-stats-list
83
+ - bin/gas-stats-show
84
+ - bin/gas-stats-use
85
+ - lib/gas_stats/version.rb
86
+ - lib/gas_stats.rb
87
+ - LICENSE
88
+ - README.md
89
+ homepage: https://github.com/walle/gas_stats
90
+ licenses: []
91
+ post_install_message:
92
+ rdoc_options:
93
+ - --charset=UTF-8
94
+ require_paths:
95
+ - - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ segments:
103
+ - 0
104
+ hash: 3223615228388380310
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ segments:
112
+ - 0
113
+ hash: 3223615228388380310
114
+ requirements: []
115
+ rubyforge_project: gas_stats
116
+ rubygems_version: 1.8.24
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Keep track of your gas usage
120
+ test_files: []