punch_stats 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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.prettierrc +3 -0
- data/.rubocop.yml +77 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +49 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/Rakefile +10 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/config.ru +4 -0
- data/exe/punch-stats +5 -0
- data/lib/punch_stats.rb +76 -0
- data/lib/punch_stats/version.rb +3 -0
- data/package.json +23 -0
- data/punch_stats.gemspec +41 -0
- data/tsconfig.json +59 -0
- data/tslint.json +22 -0
- data/ui/dist/296586ca463d78bb727a.bundle.js +1 -0
- data/ui/dist/favicon.ico +0 -0
- data/ui/dist/index.html +18 -0
- data/ui/src/images/favicon.ico +0 -0
- data/ui/src/images/logo-1024.png +0 -0
- data/ui/src/images/logo-256.png +0 -0
- data/ui/src/index.html +18 -0
- data/ui/src/index.scss +17 -0
- data/ui/src/index.ts +2 -0
- data/webpack.config.js +46 -0
- data/yarn.lock +4950 -0
- metadata +174 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a1911e069ec4c48fff1c80a46cb41ce77160677a74a5aa9ae87d9203fb3ee4ab
|
4
|
+
data.tar.gz: 51a1d23f016ab2534e3067a5ab59d2191840f30355ad7e993858a5ef8e15e4f2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 74929c4de9ac87a487cf05789dd762ddc9ca65e9e0eb8c82d5064646b32e0d1e90d099628ac472ac8a6b2d7771fb8f7a6acf9c33eeb2db1764578c7d252d024d
|
7
|
+
data.tar.gz: 51c64ff86cd5611d768de765f9b58650af4ea6cd574ce2a4b71bc57295c4e2b6f41c5109cb3aa3808e95efb2a9d6baccad620157313f996ff0eb76a7144aff4f
|
data/.gitignore
ADDED
data/.prettierrc
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
2
|
+
|
3
|
+
Layout/MultilineOperationIndentation:
|
4
|
+
EnforcedStyle: indented
|
5
|
+
|
6
|
+
Layout/AlignParameters:
|
7
|
+
EnforcedStyle: with_fixed_indentation
|
8
|
+
|
9
|
+
Layout/EndAlignment:
|
10
|
+
EnforcedStyleAlignWith: variable
|
11
|
+
|
12
|
+
Layout/SpaceInsideStringInterpolation:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Layout/EmptyLinesAroundBlockBody:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Layout/EmptyLinesAroundClassBody:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Layout/EmptyLinesAroundModuleBody:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/StringLiterals:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Style/StringLiteralsInInterpolation:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/PercentLiteralDelimiters:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/SingleLineBlockParams:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/TrivialAccessors:
|
37
|
+
AllowPredicates: true
|
38
|
+
|
39
|
+
Style/Semicolon:
|
40
|
+
AllowAsExpressionSeparator: true
|
41
|
+
|
42
|
+
Style/PerlBackrefs:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Style/SingleLineMethods:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Style/Documentation:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Style/DoubleNegation:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Style/Alias:
|
55
|
+
EnforcedStyle: prefer_alias_method
|
56
|
+
|
57
|
+
Metrics/ClassLength:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
Metrics/ModuleLength:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
Metrics/MethodLength:
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
Metrics/BlockLength:
|
67
|
+
Enabled: false
|
68
|
+
|
69
|
+
Metrics/CyclomaticComplexity:
|
70
|
+
Max: 10
|
71
|
+
|
72
|
+
Metrics/PerceivedComplexity:
|
73
|
+
Max: 10
|
74
|
+
|
75
|
+
Metrics/AbcSize:
|
76
|
+
Enabled: false
|
77
|
+
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.5.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
punch_stats (0.1.0)
|
5
|
+
sinatra
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
byebug (10.0.2)
|
11
|
+
coderay (1.1.2)
|
12
|
+
method_source (0.9.0)
|
13
|
+
minitest (5.11.3)
|
14
|
+
mustermann (1.0.2)
|
15
|
+
pry (0.11.3)
|
16
|
+
coderay (~> 1.1.0)
|
17
|
+
method_source (~> 0.9.0)
|
18
|
+
pry-byebug (3.6.0)
|
19
|
+
byebug (~> 10.0)
|
20
|
+
pry (~> 0.10)
|
21
|
+
pry-doc (0.13.4)
|
22
|
+
pry (~> 0.11)
|
23
|
+
yard (~> 0.9.11)
|
24
|
+
rack (2.0.5)
|
25
|
+
rack-protection (2.0.3)
|
26
|
+
rack
|
27
|
+
rake (10.5.0)
|
28
|
+
sinatra (2.0.3)
|
29
|
+
mustermann (~> 1.0)
|
30
|
+
rack (~> 2.0)
|
31
|
+
rack-protection (= 2.0.3)
|
32
|
+
tilt (~> 2.0)
|
33
|
+
tilt (2.0.8)
|
34
|
+
yard (0.9.15)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
bundler
|
41
|
+
minitest
|
42
|
+
pry
|
43
|
+
pry-byebug
|
44
|
+
pry-doc
|
45
|
+
punch_stats!
|
46
|
+
rake
|
47
|
+
|
48
|
+
BUNDLED WITH
|
49
|
+
1.16.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Rathesan Iyadurai
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# PunchStats
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
```
|
6
|
+
$ gem install punch_stats
|
7
|
+
```
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
TODO
|
12
|
+
|
13
|
+
## Development
|
14
|
+
|
15
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
16
|
+
`rake test` to run the tests. You can also run `bin/console` for an interactive
|
17
|
+
prompt that will allow you to experiment.
|
18
|
+
|
19
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
20
|
+
release a new version, update the version number in `version.rb`, and then run
|
21
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
22
|
+
git commits and tags, and push the `.gem` file to
|
23
|
+
[rubygems.org](https://rubygems.org).
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
Bug reports and pull requests are welcome on GitHub at
|
28
|
+
https://github.com/rathrio/punch_stats.
|
29
|
+
|
30
|
+
## License
|
31
|
+
|
32
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "punch_stats"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "pry"
|
15
|
+
Pry.start(PunchStats)
|
data/bin/setup
ADDED
data/config.ru
ADDED
data/exe/punch-stats
ADDED
data/lib/punch_stats.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './punch_stats/version'
|
4
|
+
require 'json'
|
5
|
+
require 'sinatra/base'
|
6
|
+
|
7
|
+
module PunchStats
|
8
|
+
PUNCH_PATH = ENV['PUNCH_PATH']
|
9
|
+
|
10
|
+
if PUNCH_PATH.to_s.empty?
|
11
|
+
puts <<~INFO
|
12
|
+
Please provide an absolute path to your local punch installation in the
|
13
|
+
PUNCH_PATH environment variable, e.g. in your .bash_profile:
|
14
|
+
|
15
|
+
export PUNCH_PATH=/Users/spongebob/projects/punch
|
16
|
+
INFO
|
17
|
+
|
18
|
+
exit(1)
|
19
|
+
end
|
20
|
+
|
21
|
+
PUNCH_EXECUTABLE = File.join(PUNCH_PATH, 'punch.rb')
|
22
|
+
require PUNCH_EXECUTABLE
|
23
|
+
|
24
|
+
ROOT = File.join(File.dirname(__FILE__), '../')
|
25
|
+
|
26
|
+
def self.root
|
27
|
+
ROOT
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.ui_dist
|
31
|
+
File.join(ROOT, 'ui/dist')
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Array<Month>]
|
35
|
+
def self.months
|
36
|
+
Dir["#{Punch.config.hours_folder}/*.txt"]
|
37
|
+
.map { |f| Month.from_file(f) }
|
38
|
+
.reject(&:empty?)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.json_months
|
42
|
+
months.map do |month|
|
43
|
+
hash = {}
|
44
|
+
|
45
|
+
hash[:name] = month.name
|
46
|
+
hash[:year] = month.year
|
47
|
+
hash[:number] = month.number
|
48
|
+
hash[:total] = month.total
|
49
|
+
|
50
|
+
hash[:days] = month.days.map do |day|
|
51
|
+
{
|
52
|
+
date: day.to_time.to_date,
|
53
|
+
total: day.total,
|
54
|
+
blocks: day.blocks.map do |b|
|
55
|
+
{ start: b.start, end: b.finish, total: b.total }
|
56
|
+
end
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
hash
|
61
|
+
end.to_json
|
62
|
+
end
|
63
|
+
|
64
|
+
class Server < Sinatra::Base
|
65
|
+
set :public_folder, PunchStats.ui_dist
|
66
|
+
|
67
|
+
get '/' do
|
68
|
+
send_file File.join(settings.public_folder, 'index.html')
|
69
|
+
end
|
70
|
+
|
71
|
+
get '/months' do
|
72
|
+
content_type :json
|
73
|
+
PunchStats.json_months
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/package.json
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"devDependencies": {
|
3
|
+
"awesome-typescript-loader": "^5.2.0",
|
4
|
+
"css-loader": "^1.0.0",
|
5
|
+
"file-loader": "^1.1.11",
|
6
|
+
"html-loader": "^0.5.5",
|
7
|
+
"html-webpack-plugin": "^3.2.0",
|
8
|
+
"node-sass": "^4.9.2",
|
9
|
+
"sass-loader": "^7.0.3",
|
10
|
+
"style-loader": "^0.21.0",
|
11
|
+
"tslint": "^5.11.0",
|
12
|
+
"tslint-config-airbnb": "^5.9.2",
|
13
|
+
"tslint-react": "^3.6.0",
|
14
|
+
"typescript": "^3.0.1",
|
15
|
+
"webpack": "^4.16.3",
|
16
|
+
"webpack-cli": "^3.1.0",
|
17
|
+
"webpack-serve": "^2.0.2"
|
18
|
+
},
|
19
|
+
"scripts": {
|
20
|
+
"start": "webpack-serve",
|
21
|
+
"build": "NODE_ENV=production webpack --mode production"
|
22
|
+
}
|
23
|
+
}
|
data/punch_stats.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'punch_stats/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'punch_stats'
|
9
|
+
spec.version = PunchStats::VERSION
|
10
|
+
spec.authors = ['Rathesan Iyadurai']
|
11
|
+
spec.email = ['rad.iyadurai@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'Punch Stats'
|
14
|
+
spec.homepage = 'https://github.com/rathrio/punch_stats'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise 'RubyGems 2.0 or newer is required to protect against ' \
|
23
|
+
# 'public gem pushes.'
|
24
|
+
# end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features|node_modules)/})
|
28
|
+
end
|
29
|
+
spec.bindir = 'exe'
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ['lib']
|
32
|
+
|
33
|
+
spec.add_runtime_dependency 'sinatra'
|
34
|
+
|
35
|
+
spec.add_development_dependency 'bundler'
|
36
|
+
spec.add_development_dependency 'minitest'
|
37
|
+
spec.add_development_dependency "pry"
|
38
|
+
spec.add_development_dependency "pry-byebug"
|
39
|
+
spec.add_development_dependency "pry-doc"
|
40
|
+
spec.add_development_dependency 'rake'
|
41
|
+
end
|
data/tsconfig.json
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
/* Basic Options */
|
4
|
+
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
5
|
+
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
6
|
+
"lib": ["dom", "es2017"], /* Specify library files to be included in the compilation. */
|
7
|
+
"allowJs": true, /* Allow javascript files to be compiled. */
|
8
|
+
// "checkJs": true, /* Report errors in .js files. */
|
9
|
+
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
10
|
+
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
11
|
+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
12
|
+
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
13
|
+
// "outFile": "./", /* Concatenate and emit output to single file. */
|
14
|
+
// "outDir": "./", /* Redirect output structure to the directory. */
|
15
|
+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
16
|
+
// "composite": true, /* Enable project compilation */
|
17
|
+
// "removeComments": true, /* Do not emit comments to output. */
|
18
|
+
// "noEmit": true, /* Do not emit outputs. */
|
19
|
+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
20
|
+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
21
|
+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
22
|
+
|
23
|
+
/* Strict Type-Checking Options */
|
24
|
+
"strict": true, /* Enable all strict type-checking options. */
|
25
|
+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
26
|
+
// "strictNullChecks": true, /* Enable strict null checks. */
|
27
|
+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
28
|
+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
29
|
+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
30
|
+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
31
|
+
|
32
|
+
/* Additional Checks */
|
33
|
+
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
34
|
+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
35
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
36
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
37
|
+
|
38
|
+
/* Module Resolution Options */
|
39
|
+
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
40
|
+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
41
|
+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
42
|
+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
43
|
+
// "typeRoots": [], /* List of folders to include type definitions from. */
|
44
|
+
// "types": [], /* Type declaration files to be included in compilation. */
|
45
|
+
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
46
|
+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
47
|
+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
48
|
+
|
49
|
+
/* Source Map Options */
|
50
|
+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
51
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
52
|
+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
53
|
+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
54
|
+
|
55
|
+
/* Experimental Options */
|
56
|
+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
57
|
+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
58
|
+
}
|
59
|
+
}
|