maimailog 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d948843f76ae075112c6549a948fd49089270ad
4
- data.tar.gz: e0e70d2ca5e8b514135244dbfd472e66719ea4e4
3
+ metadata.gz: 8f1cfed698f19ef0a7b9428bc80bfcf306b0370d
4
+ data.tar.gz: a87905ea4a6a39032fa9cf2b3f22bc1373e485ab
5
5
  SHA512:
6
- metadata.gz: 51599d299ba7e3bda4144b7ab5e3a05ba68fb470b6de2bcfd4fde11798daeadfd99846a293ebf9979c54cb94c0621a9fae2fc5ac547930a7dad1c78be6e8246f
7
- data.tar.gz: d838dbea125de0f018fa0947821ce1ac6160ed0ca03ac82d8235d948b173503919bfeffd62b90b3b2d5b29ad34106278a8f57c00c69b94701491d7da1da8ef12
6
+ metadata.gz: 3333dc29f0bf2de219123e14e4a050e66a1991b3826f5185df8df98f12515b6d3232e812ba069d1b02c1a0d84d1e068ad79fc79aa288206608e1cbdf154de58b
7
+ data.tar.gz: f171622fb468b49925a124637df6e057a7416ce7a1ec6175dbe38d6d82d15b1d069c78903b0da566c677e5b1e7cc8ae4099bedaaa305514923cb4bf0dbce9f05
data/.gitignore CHANGED
@@ -21,4 +21,6 @@ tmp
21
21
  *.a
22
22
  mkmf.log
23
23
  maimailog.iml
24
- .idea
24
+ .idea
25
+ vendor
26
+ .bin
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ -fd
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.2
5
+ bundler_args: --jobs=2
6
+ script: bundle exec rspec
7
+ branches:
8
+ only:
9
+ - master
10
+ env:
11
+ global:
12
+ - secure: "QSJasTVQQXuNes134v4iQLGBz3FQmLzGszd2u7Pa1HKHK8NfWyugVKx/nAnbvjziTj2JugAsLURqQNe+gw46oRPhOjiGAcG5aFYFR5/tCXNi5WpFOymG6jNIRFaZT9mFzHel07q1Z2CL+OrTZuONsVF3Dxykwg0Cm89huQa12YI="
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Maimailog
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/maimailog.svg)](http://badge.fury.io/rb/maimailog)
4
+ [![Build Status](https://travis-ci.org/utahta/maimailog.svg?branch=master)](https://travis-ci.org/utahta/maimailog)
5
+
6
+ Description
7
+ -----------
3
8
  maimai のプレイ履歴を取得する
4
9
 
5
10
  ## Installation
data/bin/maimailog ADDED
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'maimailog'
4
+ require 'thor'
5
+ require 'io/console'
6
+ require 'json'
7
+
8
+ class Cli < Thor
9
+ desc "status [OPTION]", "get maimai status"
10
+ option :user_id, type: :string, required: true, aliases: '-u', desc: 'maimainet user id'
11
+ option :password, type: :string, default: '', aliases: '-p', desc: 'maimainet password'
12
+ def status
13
+ user_id, password = parse_login_options
14
+
15
+ c = Maimailog::Crawler::Status.new
16
+ data = c.fetch(user_id, password)
17
+ puts JSON.dump({ name: data.name, rating: data.rating, rating_max: data.rating_max })
18
+ end
19
+
20
+ desc "history [OPTION]", "get maimai play data history"
21
+ option :user_id, type: :string, required: true, aliases: '-u', desc: 'maimainet user id'
22
+ option :password, type: :string, default: '', aliases: '-p', desc: 'maimainet password'
23
+ def history
24
+ user_id, password = parse_login_options
25
+
26
+ c = Maimailog::Crawler::History.new
27
+ c.login(user_id, password)
28
+ json = []
29
+ c.fetch_all do |data|
30
+ json << {
31
+ date: data.date,
32
+ difficulty: data.difficulty,
33
+ name: data.name,
34
+ judge: {
35
+ perfect: data.judge.perfect,
36
+ great: data.judge.great,
37
+ good: data.judge.good,
38
+ miss: data.judge.miss,
39
+ total: data.judge.total
40
+ },
41
+ score: {
42
+ rate: data.score.rate,
43
+ tap: data.score.tap,
44
+ hold: data.score.hold,
45
+ slide: data.score.slide,
46
+ break: data.score.break,
47
+ total: data.score.total,
48
+ tap_max: data.score.tap_max,
49
+ hold_max: data.score.hold_max,
50
+ slide_max: data.score.slide_max,
51
+ break_max: data.score.break_max,
52
+ total_max: data.score.total_max
53
+ }
54
+ }
55
+ end
56
+ puts json
57
+ end
58
+
59
+ private
60
+
61
+ def parse_login_options()
62
+ user_id = options[:user_id]
63
+ password = options[:password] || ''
64
+ if password.empty?
65
+ print "enter password: "
66
+ password = STDIN.noecho(&:gets).strip
67
+ puts ''
68
+ end
69
+ [user_id, password]
70
+ end
71
+ end
72
+
73
+ Cli.start(ARGV)
@@ -19,7 +19,7 @@ module Maimailog
19
19
 
20
20
  def date(page)
21
21
  str = page.search('//div[@class="accordion"]/h3').text[/[\d]{4}-[\d]{2}-[\d]{2} [\d]{2}:[\d]{2}/]
22
- DateTime.strptime(str, '%Y-%m-%d %H:%M')
22
+ DateTime.strptime("#{str} JST", '%Y-%m-%d %H:%M %Z')
23
23
  end
24
24
 
25
25
  def difficulty(page)
@@ -1,3 +1,3 @@
1
1
  module Maimailog
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/maimailog.gemspec CHANGED
@@ -18,8 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake"
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rspec', '~> 3.1.0'
23
24
 
24
25
  spec.add_dependency 'mechanize', '~> 2.7.3'
26
+ spec.add_dependency 'thor', '~> 0.19.1'
25
27
  end
@@ -0,0 +1,25 @@
1
+ require 'rspec'
2
+
3
+ describe 'Maimailog' do
4
+
5
+ context 'Login' do
6
+ it 'ログインできること' do
7
+ c = Maimailog::Crawler::Base.new
8
+ page = c.login(LOGIN_ID, LOGIN_PASSWD)
9
+ uri = "#{page.uri.scheme}://#{page.uri.host}#{page.uri.path}"
10
+ expect(uri).to eq 'https://maimai-net.com/maimai-mobile/home.html'
11
+ end
12
+ end
13
+
14
+ context 'History' do
15
+ it '過去データが1件取得できること' do
16
+ c = Maimailog::Crawler::History.new
17
+ c.login(LOGIN_ID, LOGIN_PASSWD)
18
+ c.fetch_all do |data|
19
+ expect(data.instance_of? Maimailog::Data::Detail).to eq true
20
+ break
21
+ end
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,2 @@
1
+ LOGIN_ID = ENV['MAIMAILOG_USER_ID']
2
+ LOGIN_PASSWD = ENV['MAIMAILOG_PASSWD']
@@ -0,0 +1,98 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ require 'maimailog'
18
+ require 'spec_config'
19
+
20
+ RSpec.configure do |config|
21
+ # rspec-expectations config goes here. You can use an alternate
22
+ # assertion/expectation library such as wrong or the stdlib/minitest
23
+ # assertions if you prefer.
24
+ config.expect_with :rspec do |expectations|
25
+ # This option will default to `true` in RSpec 4. It makes the `description`
26
+ # and `failure_message` of custom matchers include text for helper methods
27
+ # defined using `chain`, e.g.:
28
+ # be_bigger_than(2).and_smaller_than(4).description
29
+ # # => "be bigger than 2 and smaller than 4"
30
+ # ...rather than:
31
+ # # => "be bigger than 2"
32
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
33
+ end
34
+
35
+ # rspec-mocks config goes here. You can use an alternate test double
36
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
37
+ config.mock_with :rspec do |mocks|
38
+ # Prevents you from mocking or stubbing a method that does not exist on
39
+ # a real object. This is generally recommended, and will default to
40
+ # `true` in RSpec 4.
41
+ mocks.verify_partial_doubles = true
42
+ end
43
+
44
+ # Run specs in random order to surface order dependencies. If you find an
45
+ # order dependency and want to debug it, you can fix the order by providing
46
+ # the seed, which is printed after each run.
47
+ # --seed 1234
48
+ config.order = :random
49
+
50
+ # The settings below are suggested to provide a good initial experience
51
+ # with RSpec, but feel free to customize to your heart's content.
52
+ =begin
53
+ # These two settings work together to allow you to limit a spec run
54
+ # to individual examples or groups you care about by tagging them with
55
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
56
+ # get run.
57
+ config.filter_run :focus
58
+ config.run_all_when_everything_filtered = true
59
+
60
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
61
+ # For more details, see:
62
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
63
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
64
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
65
+ config.disable_monkey_patching!
66
+
67
+ # This setting enables warnings. It's recommended, but in some cases may
68
+ # be too noisy due to issues in dependencies.
69
+ config.warnings = true
70
+
71
+ # Many RSpec users commonly either run the entire suite or an individual
72
+ # file, and it's useful to allow more verbose output when running an
73
+ # individual spec file.
74
+ if config.files_to_run.one?
75
+ # Use the documentation formatter for detailed output,
76
+ # unless a formatter has already been configured
77
+ # (e.g. via a command-line flag).
78
+ config.default_formatter = 'doc'
79
+ end
80
+
81
+ # Print the 10 slowest examples and example groups at the
82
+ # end of the spec run, to help surface which specs are running
83
+ # particularly slow.
84
+ config.profile_examples = 10
85
+
86
+ # Run specs in random order to surface order dependencies. If you find an
87
+ # order dependency and want to debug it, you can fix the order by providing
88
+ # the seed, which is printed after each run.
89
+ # --seed 1234
90
+ config.order = :random
91
+
92
+ # Seed global randomization in this process using the `--seed` CLI option.
93
+ # Setting this allows you to use `--seed` to deterministically reproduce
94
+ # test failures related to randomization by passing the same `--seed` value
95
+ # as the one that triggered the failure.
96
+ Kernel.srand config.seed
97
+ =end
98
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maimailog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - utahta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-09 00:00:00.000000000 Z
11
+ date: 2014-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
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: 3.1.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.1.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: mechanize
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,18 +66,36 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: 2.7.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.19.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.19.1
55
83
  description: get the maimai play log
56
84
  email:
57
85
  - labs.ninxit@gmail.com
58
- executables: []
86
+ executables:
87
+ - maimailog
59
88
  extensions: []
60
89
  extra_rdoc_files: []
61
90
  files:
62
91
  - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
63
94
  - Gemfile
64
95
  - LICENSE.txt
65
96
  - README.md
66
97
  - Rakefile
98
+ - bin/maimailog
67
99
  - lib/maimailog.rb
68
100
  - lib/maimailog/crawler/base.rb
69
101
  - lib/maimailog/crawler/error.rb
@@ -73,6 +105,9 @@ files:
73
105
  - lib/maimailog/data/status.rb
74
106
  - lib/maimailog/version.rb
75
107
  - maimailog.gemspec
108
+ - spec/maimailog_spec.rb
109
+ - spec/spec_config.rb
110
+ - spec/spec_helper.rb
76
111
  homepage: https://github.com/utahta/maimailog
77
112
  licenses:
78
113
  - MIT
@@ -97,4 +132,7 @@ rubygems_version: 2.2.2
97
132
  signing_key:
98
133
  specification_version: 4
99
134
  summary: get the maimai play log
100
- test_files: []
135
+ test_files:
136
+ - spec/maimailog_spec.rb
137
+ - spec/spec_config.rb
138
+ - spec/spec_helper.rb