jp_ski 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-18mode # JRuby in 1.8 mode
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ #- rbx-2.1.1
7
+ - 1.8.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jp_ski.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Toshimasa Oguni
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,35 @@
1
+ # JpSki
2
+
3
+ [![Build Status](https://travis-ci.org/tsmsogn/jp_ski.svg?branch=master)](https://travis-ci.org/tsmsogn/jp_ski)
4
+
5
+ Japan ski areas
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'jp_ski'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install jp_ski
22
+
23
+ ## Usage
24
+
25
+ Get all ski areas
26
+
27
+ JpSki::Ski.all
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it ( https://github.com/[my-github-username]/jp_ski/fork )
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
data/jp_ski.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jp_ski/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jp_ski"
8
+ spec.version = JpSki::VERSION
9
+ spec.authors = ["Toshimasa Oguni"]
10
+ spec.email = ["tsmsogn@gmail.com"]
11
+ spec.summary = %q{Japan ski area.}
12
+ spec.description = %q{Japan ski area.}
13
+ spec.homepage = ""
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{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,13 @@
1
+ require 'yaml'
2
+
3
+ module JpSki
4
+ # Mapping
5
+ module Mapping
6
+ filepath = File.join(File.dirname(__FILE__), '../../yml/ski.yml')
7
+ @data = YAML.load_file(filepath)
8
+
9
+ def self.data
10
+ @data
11
+ end
12
+ end
13
+ end
data/lib/jp_ski/ski.rb ADDED
@@ -0,0 +1,20 @@
1
+ module JpSki
2
+ # Ski
3
+ class Ski
4
+ attr_accessor :name, :pref, :area
5
+
6
+ def self.build(name, pref, area)
7
+ ski = new
8
+ ski.name = name
9
+ ski.pref = pref
10
+ ski.area = area
11
+ ski
12
+ end
13
+
14
+ def self.all
15
+ Mapping.data.map do |ski|
16
+ build(ski[:name], ski[:pref], ski[:area])
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module JpSki
2
+ VERSION = "0.0.1"
3
+ end
data/lib/jp_ski.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "jp_ski/version"
2
+ require "jp_ski/mapping"
3
+ require "jp_ski/ski"
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe JpSki do
4
+ it 'has a version number' do
5
+ expect(JpSki::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe JpSki::Mapping do
4
+ describe '.data' do
5
+ it 'return all ski areas loaded from YAML' do
6
+ expect(described_class.data.count).to eq 563
7
+ end
8
+ end
9
+ end
data/spec/ski_spec.rb ADDED
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe JpSki::Ski do
6
+ let(:ski) { JpSki::Ski.build('foo', 'bar', 'baz') }
7
+ subject { ski }
8
+
9
+ it { is_expected.to respond_to(:name) }
10
+ it { is_expected.to respond_to(:pref) }
11
+ it { is_expected.to respond_to(:area) }
12
+ it { expect(ski.name).to eq 'foo' }
13
+ it { expect(ski.pref).to eq 'bar' }
14
+ it { expect(ski.area).to eq 'baz' }
15
+
16
+ describe '.all' do
17
+ let(:skis) { JpSki::Ski.all }
18
+
19
+ it { expect(skis.first).to be_an_instance_of(JpSki::Ski) }
20
+ it { expect(skis.first.name).to eq '石狩平原スキー場' }
21
+ it { expect(skis.first.pref).to eq '北海道' }
22
+ it { expect(skis.first.area).to eq '北海道' }
23
+ it { expect(skis.count).to eq 563 }
24
+ end
25
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'jp_ski'