csv2api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rspec +3 -0
- data/.rubocop.yml +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +12 -0
- data/Changelog.md +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +63 -0
- data/Rakefile +27 -0
- data/bin/csv2api +11 -0
- data/config.ru +5 -0
- data/csv2api.gemspec +29 -0
- data/lib/csv2api.rb +9 -0
- data/lib/csv2api/cli.rb +109 -0
- data/lib/csv2api/parser.rb +43 -0
- data/lib/csv2api/server.rb +38 -0
- data/lib/csv2api/utils.rb +46 -0
- data/lib/csv2api/version.rb +5 -0
- data/spec/csv2api/csv2api_spec.rb +17 -0
- data/spec/csv2api/parser_spec.rb +20 -0
- data/spec/csv2api/server_spec.rb +25 -0
- data/spec/csv2api/utils_spec.rb +64 -0
- data/spec/fixtures/tasks.csv +251 -0
- data/spec/fixtures/transaction.csv +25 -0
- data/spec/spec_helper.rb +18 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e4d79887071ea990b18f00ffb329d718a1603965
|
4
|
+
data.tar.gz: 5ac6cac16217b800f1d5777698b312ce690bbd78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 668916f02c35a22396cd5b33671705c2b0ce5d287d93986e91609f3647f93d6a96cab50375e5b34cdf02b8c604adf9299436de64045490f423cf0607183ee422
|
7
|
+
data.tar.gz: 9b790f0b073b8937d8bb096f7b1c163f52d6e982803731e27eabb2071b15c441bd1cb122d70e688f459713dd38c2c653c9ba8d038dfa35a9e12c7d75a734eba2
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
.inch
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
*.bundle
|
20
|
+
*.so
|
21
|
+
*.o
|
22
|
+
*.a
|
23
|
+
mkmf.log
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
csv2api
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.1
|
data/.travis.yml
ADDED
data/Changelog.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jonah Ruiz
|
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,63 @@
|
|
1
|
+
# CSV2API
|
2
|
+
|
3
|
+
Auto-create json APIs from csv files. Instant endpoints without any hassle
|
4
|
+
|
5
|
+
## Why should I use this?
|
6
|
+
|
7
|
+
* Your boss/client hates you so they insist on sending you .csv files for their data.
|
8
|
+
* You need to do a quick prototype and don't want to waste time importing / converting
|
9
|
+
* You're bored and want to write an app with pre-historical data you found on a floppy!
|
10
|
+
* Your life depends on it (**Disclaimer:** *Use at your own risk, jk you should be fine!*)
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Install it running:
|
15
|
+
|
16
|
+
$ gem install csv2api
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
### Basic Example Code
|
21
|
+
To read from the current directory, run the following command
|
22
|
+
|
23
|
+
$ csv2api
|
24
|
+
|
25
|
+
```console
|
26
|
+
Starting CSV2API...
|
27
|
+
|
28
|
+
2 csv files detected. Creating API endpoints...
|
29
|
+
|
30
|
+
tasks.csv - http://localhost:3000/tasks
|
31
|
+
weather.csv - http://localhost:3000/weather
|
32
|
+
```
|
33
|
+
|
34
|
+
**Note**: Endpoints can be accessed with simple name or their .json extension.
|
35
|
+
|
36
|
+
### Load a specific folder
|
37
|
+
$csv2api -d office_stuff/sad_csvs/
|
38
|
+
|
39
|
+
### Command-Line Application
|
40
|
+
Options:
|
41
|
+
* -d, --directory - load csv files from directory
|
42
|
+
* -v, --version - display the version
|
43
|
+
* -h, --help - print help
|
44
|
+
|
45
|
+
## TODO
|
46
|
+
|
47
|
+
__Soon__
|
48
|
+
- [ ] Load single files
|
49
|
+
- [ ] REST Support
|
50
|
+
- [ ] WebUI
|
51
|
+
|
52
|
+
## Author
|
53
|
+
* [Jonah Ruiz](http://www.pixelhipsters.com)
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
Is it worth it? let me fork it
|
58
|
+
|
59
|
+
I put my thing down, flip it and debug it
|
60
|
+
|
61
|
+
Ti gubed dna ti pilf nwod gniht ym tup I
|
62
|
+
|
63
|
+
Ti gubed dna ti pilf nwod gniht ym tup I
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task default: :spec
|
7
|
+
task test: :spec
|
8
|
+
|
9
|
+
desc 'Run Rubocop with configuration file'
|
10
|
+
task :rubocop do
|
11
|
+
exec('rubocop -c .rubocop.yml')
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Check documentation with inch'
|
15
|
+
task :docs do
|
16
|
+
exec('inch diff && inch list')
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Run YARD server'
|
20
|
+
task :doc do
|
21
|
+
exec('yard server --reload & open http://localhost:8808')
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Kill YARD Server'
|
25
|
+
task :kill_yard do
|
26
|
+
exec('pgrep yard | xargs kill -9')
|
27
|
+
end
|
data/bin/csv2api
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# @author Jonah Ruiz <jonah@pixelhipsters.com>
|
3
|
+
# Command-line application for CSV2API
|
4
|
+
|
5
|
+
Signal.trap('INT') { exit 1 }
|
6
|
+
|
7
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib/'
|
8
|
+
require 'csv2api'
|
9
|
+
require 'csv2api/cli'
|
10
|
+
|
11
|
+
puts CSV2API::CLI.new(ARGV).parse
|
data/config.ru
ADDED
data/csv2api.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'csv2api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'csv2api'
|
8
|
+
spec.version = CSV2API::VERSION
|
9
|
+
spec.authors = ['Jonah Ruiz']
|
10
|
+
spec.email = ['jonah@pixelhipsters.com']
|
11
|
+
spec.summary = %q(Auto-create json API endpoints from csv files.)
|
12
|
+
spec.description = %q(Auto-create json APIs from csv files. Instantaneously)
|
13
|
+
spec.homepage = 'https://github.com/jonahoffline/csv2api'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(spec)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
spec.required_ruby_version = '>= 2.0.0'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'rspec'
|
25
|
+
spec.add_development_dependency 'simplecov', '~> 0.8.2'
|
26
|
+
spec.add_development_dependency 'rack-test', '~> 0.6.2'
|
27
|
+
|
28
|
+
spec.add_dependency 'sinatra', '~> 1.4.5'
|
29
|
+
end
|
data/lib/csv2api.rb
ADDED
data/lib/csv2api/cli.rb
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module CSV2API
|
5
|
+
# @author Jonah Ruiz <jonah@pixelhipsters.com>
|
6
|
+
# A Simple class for the executable version of the gem
|
7
|
+
class CLI
|
8
|
+
include CSV2API::Utils
|
9
|
+
# Displays example use when running the command-line application
|
10
|
+
BANNER = <<MSG
|
11
|
+
Usage: csv2api [OPTION] [ARGS]
|
12
|
+
Description:
|
13
|
+
CSV2API, Auto-creates API endpoints from csv files
|
14
|
+
|
15
|
+
Options:
|
16
|
+
MSG
|
17
|
+
# @!attribute options
|
18
|
+
# @return [String] options for api settings
|
19
|
+
attr_accessor :options
|
20
|
+
|
21
|
+
# Passes arguments from ARGV
|
22
|
+
# @param args [Array<String>] The command-line arguments
|
23
|
+
def initialize(args)
|
24
|
+
@args = args
|
25
|
+
@options = Options.new
|
26
|
+
end
|
27
|
+
|
28
|
+
# Configures the arguments for the command
|
29
|
+
# @param opts [OptionParser]
|
30
|
+
def default_options(opts)
|
31
|
+
opts.version, opts.banner = CSV2API::VERSION, BANNER
|
32
|
+
opts.set_program_name 'CSV2API'
|
33
|
+
|
34
|
+
opts.on_head('-d', '--directory [DIRECTORY]', String,
|
35
|
+
'load csv files from directory (default)') do |dir|
|
36
|
+
options.directory = dir
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on_tail('-v', '--version',
|
40
|
+
'display the version of CSV2API and exit') do
|
41
|
+
puts opts.ver
|
42
|
+
exit
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on_tail('-h', '--help', 'print this help') do
|
46
|
+
puts opts.help
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns actual directory when no argument is passed
|
52
|
+
# @return [File] directory path
|
53
|
+
def directory
|
54
|
+
options.directory ? options.directory : '.'
|
55
|
+
end
|
56
|
+
|
57
|
+
# Checks if argument passed is a directory
|
58
|
+
# @return [TrueClass, FalseClass]
|
59
|
+
def directory?
|
60
|
+
FileTest.directory?(options.directory)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Checks if argument passed is a file
|
64
|
+
# @return [TrueClass, FalseClass]
|
65
|
+
def file?
|
66
|
+
FileTest.file?(options.file) unless options.file.nil?
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns a file or a directory
|
70
|
+
# @return [File] source containing csv data
|
71
|
+
def read_source
|
72
|
+
file? ? File.read(options.file) : Dir.entries(directory)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Configures load path for CSV sources
|
76
|
+
def load_path
|
77
|
+
ENV['CSV2API_ROOT'] = directory
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns text when server is loading
|
81
|
+
def server_loading_info
|
82
|
+
files = file_names(directory)
|
83
|
+
text = files.map do |csv|
|
84
|
+
"#{csv}.csv - http://localhost:4567/#{csv}"
|
85
|
+
end
|
86
|
+
|
87
|
+
text << "\n"
|
88
|
+
text.unshift("#{files.count} files detected. Creating API endpoints...")
|
89
|
+
text.unshift('Starting CSV2API...')
|
90
|
+
puts text
|
91
|
+
end
|
92
|
+
|
93
|
+
# Loads API Server
|
94
|
+
def load_server
|
95
|
+
load_path
|
96
|
+
server_loading_info
|
97
|
+
CSV2API::Server.run!
|
98
|
+
end
|
99
|
+
|
100
|
+
# Parses options sent from command-line
|
101
|
+
def parse
|
102
|
+
opts = OptionParser.new(&method(:default_options))
|
103
|
+
opts.parse!(@args)
|
104
|
+
load_server
|
105
|
+
end
|
106
|
+
end
|
107
|
+
# A Simple Struct class for storing options
|
108
|
+
Options = Struct.new(:file, :directory)
|
109
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module CSV2API
|
4
|
+
# @author Jonah Ruiz <jonah@pixelhipsters.com>
|
5
|
+
# Contains methods for parsing CSV files
|
6
|
+
class Parser
|
7
|
+
# @!attribute [r] file
|
8
|
+
# @return [String] parsed csv file
|
9
|
+
attr_reader :file
|
10
|
+
|
11
|
+
# Passes file argument down to parser
|
12
|
+
# @param file [File, IO] file to parse
|
13
|
+
# @return [CSV2API::CSVParse] class instance of self
|
14
|
+
def initialize(file)
|
15
|
+
@file = parse(file)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Parses csv file
|
19
|
+
# @param csv_file [File, IO] csv file to parse
|
20
|
+
# @return [CSV] parsed csv data
|
21
|
+
def parse(csv_file)
|
22
|
+
CSV::Converters[:blank_to_nil] = lambda do |field|
|
23
|
+
field && field.empty? ? nil : field
|
24
|
+
end
|
25
|
+
|
26
|
+
CSV.new(csv_file,
|
27
|
+
headers: true, header_converters: :symbol, converters: :all)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns an array of hashes from csv file
|
31
|
+
# @return [Array<Hash>] csv data
|
32
|
+
def all
|
33
|
+
file.to_a.map { |row| empty?(row.to_hash) }.compact
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns hash unless it's empty
|
37
|
+
# @param hash [Hash<Symbol>]
|
38
|
+
# @return [Hash<Symbol>] hash
|
39
|
+
def empty?(hash)
|
40
|
+
hash unless hash.empty?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'csv2api/utils'
|
3
|
+
require 'csv2api/server'
|
4
|
+
|
5
|
+
module CSV2API
|
6
|
+
# @author Jonah Ruiz <jonah@pixelhipsters.com>
|
7
|
+
# Contains the Sinatra-based API Server
|
8
|
+
class Server < Sinatra::Base
|
9
|
+
include CSV2API::Utils
|
10
|
+
|
11
|
+
configure do
|
12
|
+
set :csv_path, ENV['CSV2API_ROOT']
|
13
|
+
set :files, file_names(csv_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Auto-creates endpoints from filenames
|
17
|
+
# @example
|
18
|
+
# If :files contains 'tasks.csv', it will generate an endpoint like:
|
19
|
+
#
|
20
|
+
# get '/tasks' do
|
21
|
+
# content_type :json
|
22
|
+
# # (obvious code omitted...)
|
23
|
+
# # (will only return the json version of csv)
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# Endpoint will be reachable at any of the following urls:
|
27
|
+
# http://localhost:4567/tasks or http://localhost:4567/tasks.json
|
28
|
+
#
|
29
|
+
settings.files.each do |endpoint|
|
30
|
+
get "/#{endpoint}.?:format?" do
|
31
|
+
content_type :json
|
32
|
+
|
33
|
+
csv_file = load_csv(settings.csv_path, endpoint)
|
34
|
+
generate_json(CSV2API::Parser.new(csv_file).all)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module CSV2API
|
4
|
+
# @author Jonah Ruiz <jonah@pixelhipsters.com>
|
5
|
+
# Utility module with helper methods
|
6
|
+
module Utils
|
7
|
+
def self.included(base)
|
8
|
+
base.extend(self)
|
9
|
+
end
|
10
|
+
module_function
|
11
|
+
|
12
|
+
# Extracts the csv files from path
|
13
|
+
# @param file_path [IO] file path
|
14
|
+
# @return [Array<String>] path with csv files
|
15
|
+
def csv_files(file_path)
|
16
|
+
Dir.glob("#{file_path}/*.csv")
|
17
|
+
end
|
18
|
+
|
19
|
+
# Extracts the csv filename from collection
|
20
|
+
# @param file_path [IO] file path
|
21
|
+
# @param extension [TrueClass, FalseClass] return extension
|
22
|
+
# @return [Array<String>] csv filenames with or out .csv extension
|
23
|
+
def file_names(file_path, extension: false)
|
24
|
+
csv_files(file_path).map do |file|
|
25
|
+
file_name = file[/(\w*.csv)/]
|
26
|
+
extension ? file_name : file_name[0..-5]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Converts a hash into a stringified json format
|
31
|
+
# @param hash [Hash] hash to converted into json format
|
32
|
+
# @param pretty [TrueClass, FalseClass] pretty json option
|
33
|
+
# @return [JSON<String>] stringified json
|
34
|
+
def generate_json(hash, pretty: false)
|
35
|
+
pretty ? JSON.pretty_generate(hash) : JSON.generate(hash)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Helper method for opening a csv file
|
39
|
+
# @param path [String] file path
|
40
|
+
# @param filename [String] file name in path to open
|
41
|
+
# @return [File] csv file
|
42
|
+
def load_csv(path, filename)
|
43
|
+
File.read("#{path}/#{filename}.csv")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CSV2API do
|
4
|
+
it 'has a version number' do
|
5
|
+
expect(CSV2API::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'keeps it real homes, you feels me dawg?' do
|
9
|
+
expect(true).to eq(true)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'CSV2API_ROOT' do
|
13
|
+
it 'returns environment variable' do
|
14
|
+
expect(ENV.fetch('CSV2API_ROOT')).to eq('spec/fixtures')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CSV2API::Parser do
|
4
|
+
let(:csv) { CSV2API::Parser }
|
5
|
+
let(:fixture) { load_fixture('transaction') }
|
6
|
+
|
7
|
+
describe '#parse' do
|
8
|
+
it 'returns an Array' do
|
9
|
+
csv_parse = csv.new(fixture)
|
10
|
+
expect(csv_parse.all).to be_an(Array)
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'each item inside the Array' do
|
14
|
+
it 'contains a Hash' do
|
15
|
+
csv_parse = csv.new(fixture)
|
16
|
+
expect(csv_parse.all.first).to be_a(Hash)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ostruct'
|
3
|
+
describe CSV2API::Server do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
def app
|
7
|
+
CSV2API::Server
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '/tasks' do
|
11
|
+
it 'returns tasks.csv in json' do
|
12
|
+
get '/tasks'
|
13
|
+
expect(last_response.body).not_to be_empty
|
14
|
+
expect(last_response).to be_ok
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '/transaction' do
|
19
|
+
it 'returns transaction.csv in json' do
|
20
|
+
get '/transaction'
|
21
|
+
expect(last_response.body).not_to be_empty
|
22
|
+
expect(last_response).to be_ok
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CSV2API::Utils do
|
4
|
+
let(:utils) { CSV2API::Utils }
|
5
|
+
let(:artists) do
|
6
|
+
[
|
7
|
+
{
|
8
|
+
id: 1,
|
9
|
+
name: 'Kyary Pamyu Pamyu',
|
10
|
+
kawaii: true
|
11
|
+
},
|
12
|
+
{
|
13
|
+
id: 2,
|
14
|
+
name: 'Lady Gaga',
|
15
|
+
kawaii: false
|
16
|
+
}
|
17
|
+
]
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.csv_files' do
|
21
|
+
it 'returns csv files from file path' do
|
22
|
+
files = %w(./spec/fixtures/tasks.csv ./spec/fixtures/transaction.csv)
|
23
|
+
expect(utils.csv_files('./spec/fixtures')).to match_array(files)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '.file_names' do
|
28
|
+
context 'when extension is set to false (default)' do
|
29
|
+
it 'returns filenames without file extension' do
|
30
|
+
expect(utils.file_names('./spec/fixtures'))
|
31
|
+
.to match_array(%w(tasks transaction))
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when extension is set to true' do
|
37
|
+
it 'returns filenames with file extension' do
|
38
|
+
expect(utils.file_names('./spec/fixtures', extension: true))
|
39
|
+
.to match_array(%w(tasks.csv transaction.csv))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '.generate_json' do
|
45
|
+
context 'when pretty is set to false (default)' do
|
46
|
+
it 'returns a JSON object' do
|
47
|
+
expect(utils.generate_json(artists.last))
|
48
|
+
.to eq("{\"id\":2,\"name\":\"Lady Gaga\",\"kawaii\":false}")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when pretty is set to true' do
|
53
|
+
it 'returns a pretty JSON object' do
|
54
|
+
hash =
|
55
|
+
'{
|
56
|
+
"id": 1,
|
57
|
+
"name": "Kyary Pamyu Pamyu",
|
58
|
+
"kawaii": true
|
59
|
+
}'
|
60
|
+
expect(utils.generate_json(artists.first, pretty: true)).to eq(hash)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,251 @@
|
|
1
|
+
Task,Date (start),Date (end),Duration (time),Duration (h)
|
2
|
+
|
3
|
+
"Emberjs - ClientSide MVC is Not Server Side MVC, Erase your Brain",2014-04-29,2014-04-29,0:35:50,"0.6"
|
4
|
+
" Session",2014-04-29 21:16:08,,0:35:50,"0.6"
|
5
|
+
|
6
|
+
"Don't override init",2014-04-30,2014-04-30,0:12:12,"0.2"
|
7
|
+
" Session",2014-04-30 00:33:41,,0:12:12,"0.2"
|
8
|
+
|
9
|
+
"Controller's Needs Explained",2014-04-30,2014-04-30,0:10:44,"0.2"
|
10
|
+
" Session",2014-04-30 00:46:05,,0:10:44,"0.2"
|
11
|
+
|
12
|
+
"Adding route specific body class tags in Ember",2014-04-30,2014-04-30,0:07:33,"0.1"
|
13
|
+
" Session",2014-04-30 03:27:04,,0:07:33,"0.1"
|
14
|
+
|
15
|
+
"Computed Properties in Ember.Js",2014-04-30,2014-04-30,0:35:40,"0.6"
|
16
|
+
" Session",2014-04-30 01:09:33,,0:35:40,"0.6"
|
17
|
+
|
18
|
+
"Simple Property Enum Cycling in Ember",2014-04-30,2014-04-30,0:14:32,"0.2"
|
19
|
+
" Session",2014-04-30 03:11:52,,0:14:32,"0.2"
|
20
|
+
|
21
|
+
"A Simple Ember Data Route",2014-04-30,2014-04-30,0:12:23,"0.2"
|
22
|
+
" Session",2014-04-30 02:53:51,,0:12:23,"0.2"
|
23
|
+
|
24
|
+
"Ember Object Self Troll",2014-04-30,2014-04-30,0:05:14,"0.1"
|
25
|
+
" Session",2014-04-30 01:04:07,,0:05:14,"0.1"
|
26
|
+
|
27
|
+
"Observable Path Patterns in Ember",2014-04-30,2014-04-30,0:41:49,"0.7"
|
28
|
+
" Session",2014-04-30 04:45:43,,0:41:49,"0.7"
|
29
|
+
|
30
|
+
"Ember.js Getters and Setters",2014-04-30,2014-04-30,0:27:00,"0.5"
|
31
|
+
" Session #1",2014-04-30 03:36:10,,0:00:48,"0"
|
32
|
+
" Session #2",2014-04-30 03:52:07,,0:26:12,"0.4"
|
33
|
+
|
34
|
+
"ember.js - Computed Property for All Keys of an Object",2014-04-30,2014-04-30,0:12:47,"0.2"
|
35
|
+
" Session",2014-04-30 05:28:29,,0:12:47,"0.2"
|
36
|
+
|
37
|
+
"Ember's BufferedProxy and analog to Ruby's method_missing",2014-04-30,2014-05-02,0:12:21,"0.2"
|
38
|
+
" Session #1",2014-04-30 06:14:03,,0:05:55,"0.1"
|
39
|
+
" Session #2",2014-05-02 04:02:02,,0:06:26,"0.1"
|
40
|
+
|
41
|
+
"Ember and D3: Building a simple dashboard",,,,""
|
42
|
+
|
43
|
+
"An Epilogue for Ember",,,,""
|
44
|
+
|
45
|
+
"Magic Behind ES6 Generators",,,,""
|
46
|
+
|
47
|
+
"Building an Ember app with RailsAPI - I",,,,""
|
48
|
+
|
49
|
+
"Building an Ember app with RailsAPI - II",,,,""
|
50
|
+
|
51
|
+
"Building an Ember app with RailsAPI - III",,,,""
|
52
|
+
|
53
|
+
"Introducing Ember-EasyForm",,,,""
|
54
|
+
|
55
|
+
"The problem with Server-rendered errors",2014-05-02,2014-05-02,1:03:00,"1.1"
|
56
|
+
" Session",2014-05-02 03:32:57,,1:03:00,"1.1"
|
57
|
+
|
58
|
+
"Understanding validation graphs",,,,""
|
59
|
+
|
60
|
+
"The willSetProperty gotcha in Ember-Data: Understanding the state machine",2014-04-30,2014-04-30,0:17:30,"0.3"
|
61
|
+
" Session",2014-04-30 05:48:18,,0:17:30,"0.3"
|
62
|
+
|
63
|
+
"Ember Sparks 4: Setting up Testing",2014-05-03,2014-05-03,0:00:02,"0"
|
64
|
+
" Session",2014-05-03 03:26:21,,0:00:02,"0"
|
65
|
+
|
66
|
+
"Ember Sparks 5: Embedding Youtube videos",,,,""
|
67
|
+
|
68
|
+
"Ember Sparks 6: Intro to Ember App Kit",,,,""
|
69
|
+
|
70
|
+
"Ember Sparks 7: Transferring to Ember App Kit",,,,""
|
71
|
+
|
72
|
+
"Ember Sparks 8: Persistance with Ember Data and Ember App Kit",,,,""
|
73
|
+
|
74
|
+
"Ember.js - Animating Deletes With the BufferedProxy",,,,""
|
75
|
+
|
76
|
+
"Flatland: The Movie 1 and 2",,,,""
|
77
|
+
|
78
|
+
"Rails",2014-04-30,2014-05-04,1:22:14,"1.4"
|
79
|
+
" Session #1",2014-04-30 11:30:14,,0:15:00,"0.3"
|
80
|
+
" Session #2",2014-05-01 21:51:10,,0:29:05,"0.5"
|
81
|
+
" Session #3",2014-05-02 19:52:40,,0:25:54,"0.4"
|
82
|
+
" Session #4",2014-05-04 03:55:38,,0:12:15,"0.2"
|
83
|
+
|
84
|
+
"Ruby",2014-04-30,2014-05-08,1:43:00,"1.7"
|
85
|
+
" Session #1",2014-04-30 11:45:05,,0:00:15,"0"
|
86
|
+
" Session #2",2014-05-01 21:16:55,,0:23:36,"0.4"
|
87
|
+
" Session #3",2014-05-02 18:57:37,,0:41:51,"0.7"
|
88
|
+
" Session #4",2014-05-04 02:54:21,,0:30:01,"0.5"
|
89
|
+
" Session #5",2014-05-08 22:19:04,,0:07:17,"0.1"
|
90
|
+
|
91
|
+
"JavaScript",2014-05-02,2014-05-08,0:54:08,"0.9"
|
92
|
+
" Session #2",2014-05-02 22:51:46,,0:20:11,"0.3"
|
93
|
+
" Session #3",2014-05-08 21:45:02,,0:33:57,"0.6"
|
94
|
+
|
95
|
+
"How to learn any language in six months: Chris Lonsdale",2014-05-01,2014-05-01,0:31:17,"0.5"
|
96
|
+
" Session",2014-05-01 01:11:25,,0:31:17,"0.5"
|
97
|
+
|
98
|
+
"Controllers",,,,""
|
99
|
+
|
100
|
+
"Models",,,,""
|
101
|
+
|
102
|
+
"Views",,,,""
|
103
|
+
|
104
|
+
"Enumerables",,,,""
|
105
|
+
|
106
|
+
"Testing",,,,""
|
107
|
+
|
108
|
+
"Configuring Ember.js",,,,""
|
109
|
+
|
110
|
+
"Cookbook",,,,""
|
111
|
+
|
112
|
+
"Understanding Ember.js",,,,""
|
113
|
+
|
114
|
+
"Contributing to Ember.js",,,,""
|
115
|
+
|
116
|
+
"Guide Reviews",2014-05-07,2014-05-09,2:45:04,"2.8"
|
117
|
+
" Bindings, Reopen Classes, Handlebars helpers and attributes",2014-05-07 00:37:06,,0:32:55,"0.5"
|
118
|
+
" Actions and Helpers",2014-05-07 03:02:28,,2:09:52,"2.2"
|
119
|
+
" Query Parameters, Asynchronous Routing, Loading / Error Substates",2014-05-09 02:07:17,,0:02:17,"0"
|
120
|
+
|
121
|
+
"EmberJS Ambitious Applications",2014-04-17,2014-04-23,5:50:57,"5.8"
|
122
|
+
" Read from the start again",2014-04-17 03:42:12,,0:20:00,"0.3"
|
123
|
+
" Session #2 (Chapter 1 through 8)",2014-04-17 04:19:39,,2:31:26,"2.5"
|
124
|
+
" Session #3 (Chapter 9)",2014-04-22 01:48:17,,0:25:00,"0.4"
|
125
|
+
" Session #4 (Chapter 9 complete)",2014-04-22 02:27:41,,0:25:16,"0.4"
|
126
|
+
" Session #5 (Chapter 10)",2014-04-22 03:24:52,,0:26:04,"0.4"
|
127
|
+
" Session #6 (Chapter 10.1 through 11)",2014-04-22 03:58:40,,0:25:14,"0.4"
|
128
|
+
" Session #7 (Chapter 11 through 11.3)",2014-04-22 04:29:50,,0:25:14,"0.4"
|
129
|
+
" Session #8 (Chapter 11.4 through - 12.1)",2014-04-22 05:17:08,,0:27:26,"0.5"
|
130
|
+
" Session #9 (Chapter 12.2)",2014-04-23 16:40:01,,0:25:17,"0.4"
|
131
|
+
|
132
|
+
"""Surviving APIs with Rails"" Course",,,,""
|
133
|
+
|
134
|
+
"EmberJS Testing on Rails",,,,""
|
135
|
+
|
136
|
+
"Response Streams with Rails 4 and Redis",,,,""
|
137
|
+
|
138
|
+
"Token-based Authentication in Rails",,,,""
|
139
|
+
|
140
|
+
"Refactoring Rails Controllers",,,,""
|
141
|
+
|
142
|
+
"Rails: Omniauth Github Tutorial",,,,""
|
143
|
+
|
144
|
+
"Components-based Rails",,,,""
|
145
|
+
|
146
|
+
"Metaprogramming Ruby 2nd Edition",,,,""
|
147
|
+
|
148
|
+
"Crafting Rails 4 Applications",,,,""
|
149
|
+
|
150
|
+
"Rails 4 Way",,,,""
|
151
|
+
|
152
|
+
"Autopilot: The Art and Science of Doing Nothing",,,,""
|
153
|
+
|
154
|
+
"Hooked: How to Build Habit-Forming Products",,,,""
|
155
|
+
|
156
|
+
"An In-Depth Introduction To Ember.js",,,,""
|
157
|
+
|
158
|
+
"Authentication with Ember-Rails",,,,""
|
159
|
+
|
160
|
+
"Ember.js Authentication - the right way",,,,""
|
161
|
+
|
162
|
+
"Ember.js Authentication - the right way (javascript version)",,,,""
|
163
|
+
|
164
|
+
"Creating a Node Web App With Hapi and Twilio Integration",,,,""
|
165
|
+
|
166
|
+
"Master Your Modals in Ember.js",,,,""
|
167
|
+
|
168
|
+
"Model Errors in EmberJS",,,,""
|
169
|
+
|
170
|
+
"Ember Controller",2014-04-29,2014-04-29,0:25:14,"0.4"
|
171
|
+
" Session #1",2014-04-29 20:43:46,,0:25:14,"0.4"
|
172
|
+
|
173
|
+
"Components",2014-05-09,2014-05-09,1:51:48,"1.9"
|
174
|
+
" Introduction",2014-05-09 02:56:32,,0:03:52,"0.1"
|
175
|
+
" Defining a Component",2014-05-09 03:00:29,,0:11:29,"0.2"
|
176
|
+
" Passing Properties to a Component",2014-05-09 03:12:07,,0:35:45,"0.6"
|
177
|
+
" Wrapping Content In a Component",2014-05-09 04:39:26,,0:07:02,"0.1"
|
178
|
+
" Customizing a Component's Element",2014-05-09 04:46:41,,0:25:44,"0.4"
|
179
|
+
" Sending Actions from Components to Your Application",2014-05-09 05:52:12,,0:27:56,"0.5"
|
180
|
+
|
181
|
+
"Routing",2014-05-07,2014-05-09,1:26:16,"1.4"
|
182
|
+
" Introduction",2014-05-07 03:12:56,,0:04:46,"0.1"
|
183
|
+
" Defining Your Routes",2014-05-07 03:17:48,,0:16:13,"0.3"
|
184
|
+
" Generated Objects",2014-05-07 03:43:36,,0:01:35,"0"
|
185
|
+
" Specifying a Route's Model",2014-05-07 03:45:18,,0:11:52,"0.2"
|
186
|
+
" Setting Up a Controller",2014-05-07 03:57:19,,0:08:11,"0.1"
|
187
|
+
" Rendering a Template",2014-05-07 04:10:51,,0:12:42,"0.2"
|
188
|
+
" Redirecting",2014-05-07 04:23:43,,0:14:35,"0.2"
|
189
|
+
" Specifying the URL Type",2014-05-07 04:38:24,,0:03:32,"0.1"
|
190
|
+
" Preventing and Retrying Transitions",2014-05-09 02:10:02,,0:12:50,"0.2"
|
191
|
+
|
192
|
+
"Templates",2014-05-04,2014-05-04,1:29:24,"1.5"
|
193
|
+
" The Application Template",2014-05-04 07:38:04,,0:00:57,"0"
|
194
|
+
" Handlebars Basics",2014-05-04 07:39:10,,0:04:08,"0.1"
|
195
|
+
" Conditionals",2014-05-04 07:48:39,,0:03:24,"0.1"
|
196
|
+
" Displaying a List of Items",2014-05-04 07:52:18,,0:06:17,"0.1"
|
197
|
+
" Changing Scope",2014-05-04 07:58:44,,0:06:34,"0.1"
|
198
|
+
" Binding Element Attributes",2014-05-04 08:06:17,,0:10:02,"0.2"
|
199
|
+
" Binding Element Class Names",2014-05-04 08:16:33,,0:12:10,"0.2"
|
200
|
+
" Links",2014-05-04 08:29:01,,0:04:51,"0.1"
|
201
|
+
" Actions",2014-05-04 08:34:20,,0:10:41,"0.2"
|
202
|
+
" Input Helpers",2014-05-04 08:45:44,,0:03:03,"0.1"
|
203
|
+
" Development Helpers",2014-05-04 08:48:54,,0:01:37,"0"
|
204
|
+
" Rendering with Helpers",2014-05-04 08:50:36,,0:05:43,"0.1"
|
205
|
+
" Writing Helpers",2014-05-04 08:56:27,,0:19:57,"0.3"
|
206
|
+
|
207
|
+
"Application",2014-05-04,2014-05-04,0:00:47,"0"
|
208
|
+
" Creating An Application",2014-05-04 07:34:35,,0:00:47,"0"
|
209
|
+
|
210
|
+
"The Object Model",2014-05-04,2014-05-04,1:14:43,"1.2"
|
211
|
+
" Classes and Instances",2014-05-04 04:45:01,,0:08:08,"0.1"
|
212
|
+
" Computed Properties",2014-05-04 04:59:29,,0:14:51,"0.2"
|
213
|
+
" Computed Properties and Aggregate Data with @each",2014-05-04 05:14:34,,0:15:58,"0.3"
|
214
|
+
" Observers",2014-05-04 05:48:21,,0:17:07,"0.3"
|
215
|
+
" Bindings",2014-05-04 07:14:34,,0:05:44,"0.1"
|
216
|
+
" Reopening Classes and Instances",2014-05-04 07:20:27,,0:06:56,"0.1"
|
217
|
+
" Bindings, Observers, CP - What Do I Use When?",2014-05-04 07:27:37,,0:05:59,"0.1"
|
218
|
+
|
219
|
+
"Concepts",2014-05-02,2014-05-04,0:30:44,"0.5"
|
220
|
+
" Core Concepts",2014-05-02 23:12:47,,0:04:05,"0.1"
|
221
|
+
" Naming Conventions",2014-05-04 04:09:47,,0:26:39,"0.4"
|
222
|
+
|
223
|
+
"Ember Sparks 3: Metaprogramming with defineProperty",2014-05-03,2014-05-03,0:07:10,"0.1"
|
224
|
+
" Session",2014-05-03 03:19:00,,0:07:10,"0.1"
|
225
|
+
|
226
|
+
"Ember Sparks 2: Switching to Ember Data",2014-05-03,2014-05-03,0:05:50,"0.1"
|
227
|
+
" Session",2014-05-03 03:05:09,,0:05:50,"0.1"
|
228
|
+
|
229
|
+
"Ember Sparks 1: Custom Adapters for Ember Data",2014-05-03,2014-05-03,0:03:00,"0.1"
|
230
|
+
" Session",2014-05-03 03:00:19,,0:03:00,"0.1"
|
231
|
+
|
232
|
+
"Guide #1 - Getting Started",2014-05-02,2014-05-02,0:20:00,"0.3"
|
233
|
+
" Session #1",2014-05-02 05:06:58,,0:20:00,"0.3"
|
234
|
+
|
235
|
+
"Embermaps.com Posts",2014-05-02,2014-05-02,0:02:47,"0"
|
236
|
+
" Session",2014-05-02 03:34:14,,0:02:47,"0"
|
237
|
+
|
238
|
+
"Prototyping an Ember.js App in 20 Minutes",2014-04-26,2014-04-26,0:42:50,"0.7"
|
239
|
+
" Youtube Session",2014-04-26 04:34:58,,0:42:50,"0.7"
|
240
|
+
|
241
|
+
"Setting up a serious Ember project",2014-04-22,2014-04-22,0:40:51,"0.7"
|
242
|
+
" Session #1",2014-04-22 00:11:51,,0:40:51,"0.7"
|
243
|
+
|
244
|
+
"HTMLBars: The Next-Generation of Templating in Ember.js",2014-04-19,2014-04-19,0:06:10,"0.1"
|
245
|
+
" Reading Session",2014-04-19 03:46:30,,0:06:10,"0.1"
|
246
|
+
|
247
|
+
"A Simple Ember Data Route",2014-04-19,2014-04-19,0:03:01,"0.1"
|
248
|
+
" Reading Session",2014-04-19 03:39:50,,0:03:01,"0.1"
|
249
|
+
|
250
|
+
"Ember: Release and Build Reusable UIs...",2014-04-19,2014-04-19,0:43:00,"0.7"
|
251
|
+
" Youtube Session",2014-04-19 01:03:19,,0:43:00,"0.7"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
transaction_unique_identifier,seller_company_name,customer_company_name,customer_duns_number,tariff_reference,contract_service_agreement,trans_id,transaction_begin_date,transaction_end_date,time_zone,point_of_delivery_control_area,specific location,class_name,term_name,increment_name,increment_peaking_name,product_name,transaction_quantity,price,units,total_transmission_charge,transaction_charge
|
2
|
+
T1,The Electric Company,"The Electric Marketing Co., LLC",23456789,FERC Electric Tariff Original Volume No. 2,Service Agreement 1,8700,200401010000,200403312359,ES,PJM,BUS 4321,UP,LT,Y,FP,ENERGY,22574,39,$/MWH,0,880386
|
3
|
+
T2,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,2,8701,200401010000,200402010000,CS,DPL,Green Sub Busbar,F,ST,M,FP,ENERGY,16800,32,$/MWH,0,537600
|
4
|
+
T3,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,2,8702,200402010000,200403010000,CS,DPL,Green Sub Busbar,F,ST,M,FP,ENERGY,16800,32,$/MWH,0,537600
|
5
|
+
T4,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,2,8703,200403010000,200404010000,CS,DPL,Green Sub Busbar,F,ST,M,FP,ENERGY,16800,32,$/MWH,0,537600
|
6
|
+
T5,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,2,8704,200401111600,200401121559,CS,AEP,Tile Busbar,F,ST,D,FP,ENERGY,1200,50,$/MWH,0,60000
|
7
|
+
T6,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,2,8801,200402011300,20040215061900,ES,HUB,Entergy (into),NF,ST,H,FP,ENERGY,1875,13.75,$/MWH,6675,32456.25
|
8
|
+
T7,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,2,8802,20040202110000,200402021800,ES,HUB,PJM-W,NF,ST,H,FP,BOOKED OUT POWER,350,32,$/MWH,0,11200
|
9
|
+
T8,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,2,8803,20040203060500,20040210112200,ES,HUB,PJM-W,NF,ST,H,FP,ENERGY,1875,44,$/MWH,0,82500
|
10
|
+
T9,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,2,8804,20040211062300,20040219081200,PP,HUB,Four Corners,NF,ST,H,FP,ENERGY,1875,48,$/MWH,0,90000
|
11
|
+
T10,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,132,7125,20040109081100,20040309082300,CS,HUB,AEP (into),F,ST,H,OP,ENERGY,150,22,$/MWH,4264,7564
|
12
|
+
T10,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,132,7125,20040201010000,20040225080800,CS,HUB,AEP (into),F,ST,H,OP,ENERGY,150,28,$/MWH,0,4200
|
13
|
+
T10,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,132,7125,20040108111100,20040301121200,CS,HUB,AEP (into),F,ST,H,OP,ENERGY,150,44,$/MWH,0,6600
|
14
|
+
T10,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,132,7125,20040322112200,20040325120000,CS,HUB,AEP (into),F,ST,H,OP,ENERGY,150,44,$/MWH,0,6600
|
15
|
+
T10,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,132,7125,20040323191900,20040328191700,CS,HUB,AEP (into),F,ST,H,OP,ENERGY,150,58,$/MWH,0,8700
|
16
|
+
T10,The Electric Company,The Power Company,45653333,FERC Electric Tariff Original Volume No. 10,132,7125,20040111010000,20040122022200,CS,HUB,AEP (into),F,ST,H,OP,CAPACITY,150,20,$/MW-DAY,0,3000
|
17
|
+
T11,The Electric Company,Utility A,38495837,FERC Electric Tariff Original Volume No. 10,15,8711,200403150800,200403150859,ES,ISNE,NEPOOL Mass HUB,F,ST,H,P,Energy,100,50,$/MWH,0,5000
|
18
|
+
T11,The Electric Company,Utility A,38495837,FERC Electric Tariff Original Volume No. 10,15,8711,200403150800,200403150859,ES,ISNE,NEPOOL Mass HUB,F,ST,H,P,Energy,-10,60,$/MWH,0,-600
|
19
|
+
T12,The Electric Company,Utility A,38495837,FERC Electric Tariff Original Volume No. 10,15,8711,200403150900,200403150959,ES,ISNE,NEPOOL Mass HUB,F,ST,H,P,Energy,100,55,$/MWH,0,5500
|
20
|
+
T12,The Electric Company,Utility A,38495837,FERC Electric Tariff Original Volume No. 10,15,8711,200403150900,200403150959,ES,ISNE,NEPOOL Mass HUB,F,ST,H,P,Energy,-5,59,$/MWH,0,-295
|
21
|
+
T13,The Electric Company,Utility A,38495837,FERC Electric Tariff Original Volume No. 10,15,8711,200403151000,200403151059,ES,ISNE,NEPOOL Mass HUB,F,ST,H,P,Energy,100,62,$/MWH,0,6200
|
22
|
+
T13,The Electric Company,Utility A,38495837,FERC Electric Tariff Original Volume No. 10,15,8711,200403151000,200403151059,ES,ISNE,NEPOOL Mass HUB,F,ST,H,P,Energy,-10,60,$/MWH,0,-600
|
23
|
+
T14,The Electric Company,Utility A,38495837,FERC Electric Tariff Original Volume No. 10,15,8711,200403151100,200403151159,ES,ISNE,NEPOOL Mass HUB,F,ST,H,P,Energy,100,62,$/MWH,0,6200
|
24
|
+
T14,The Electric Company,Utility A,38495837,FERC Electric Tariff Original Volume No. 10,15,8711,200403151100,200403151159,ES,ISNE,NEPOOL Mass HUB,F,ST,H,P,Energy,-10,59,$/MWH,0,-590
|
25
|
+
T15,The Electric Company,Utility B,493758794,FERC Electric Tariff Original Volume No. 10,7,8712,200402140200,200402140259,EP,NYIS,Zone A,F,ST,H,FP,Booked out power,60,30,$/MWH,0,1800
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
ENV['RACK_ENV'] = 'test'
|
3
|
+
ENV['CSV2API_ROOT'] = 'spec/fixtures'
|
4
|
+
|
5
|
+
require 'simplecov'
|
6
|
+
require 'rack/test'
|
7
|
+
|
8
|
+
SimpleCov.start
|
9
|
+
require 'csv2api'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.order = 'random'
|
13
|
+
end
|
14
|
+
|
15
|
+
def load_fixture(csv_file)
|
16
|
+
path = File.join(File.dirname(__FILE__), 'fixtures', "#{csv_file}.csv")
|
17
|
+
File.read(path)
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: csv2api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonah Ruiz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.8.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-test
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.6.2
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.6.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sinatra
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.4.5
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.4.5
|
97
|
+
description: Auto-create json APIs from csv files. Instantaneously
|
98
|
+
email:
|
99
|
+
- jonah@pixelhipsters.com
|
100
|
+
executables:
|
101
|
+
- csv2api
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- ".ruby-gemset"
|
109
|
+
- ".ruby-version"
|
110
|
+
- ".travis.yml"
|
111
|
+
- Changelog.md
|
112
|
+
- Gemfile
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.md
|
115
|
+
- Rakefile
|
116
|
+
- bin/csv2api
|
117
|
+
- config.ru
|
118
|
+
- csv2api.gemspec
|
119
|
+
- lib/csv2api.rb
|
120
|
+
- lib/csv2api/cli.rb
|
121
|
+
- lib/csv2api/parser.rb
|
122
|
+
- lib/csv2api/server.rb
|
123
|
+
- lib/csv2api/utils.rb
|
124
|
+
- lib/csv2api/version.rb
|
125
|
+
- spec/csv2api/csv2api_spec.rb
|
126
|
+
- spec/csv2api/parser_spec.rb
|
127
|
+
- spec/csv2api/server_spec.rb
|
128
|
+
- spec/csv2api/utils_spec.rb
|
129
|
+
- spec/fixtures/tasks.csv
|
130
|
+
- spec/fixtures/transaction.csv
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
homepage: https://github.com/jonahoffline/csv2api
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 2.0.0
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.2.2
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: Auto-create json API endpoints from csv files.
|
156
|
+
test_files:
|
157
|
+
- spec/csv2api/csv2api_spec.rb
|
158
|
+
- spec/csv2api/parser_spec.rb
|
159
|
+
- spec/csv2api/server_spec.rb
|
160
|
+
- spec/csv2api/utils_spec.rb
|
161
|
+
- spec/fixtures/tasks.csv
|
162
|
+
- spec/fixtures/transaction.csv
|
163
|
+
- spec/spec_helper.rb
|