dl-nippo-helper 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e81555452fc167f0903c88a760c4e3c1459268e0
4
+ data.tar.gz: dcb18fea97375e304c447d312f7c8e8ec04c64c7
5
+ SHA512:
6
+ metadata.gz: 2a430cfc90fdb74276ec6ac167e3860a7eacf770b4c55e5be6b6545905e5ea999b598c2f725e653d45a2bfa8ae8b47c8a8e680fc571ce98d1b83e1fea1b326bb
7
+ data.tar.gz: 10afb0407f324dcffe7512db87cc96bdf7f3929d454d01cf9b1bde95c8790c994465fe2015f535d658d33d4f127492a26a62800117d6b26a057a3b13c89a81f0
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.swp
11
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nippo.gemspec
4
+ gem 'rspec', '3.4.0'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Hiroyasu OHYAMA
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,41 @@
1
+ # Nippo
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nippo`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'nippo'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install nippo
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nippo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'nippo'
4
+ require 'optparse'
5
+
6
+ module Nippo
7
+ TASK_TITLE = '定常業務'
8
+ TASK_CODE = '03000800159'
9
+
10
+ def self.register_task(opts)
11
+ server = Nippo::Server.new({
12
+ :server => opts[:server],
13
+ :auth_user => opts[:auth_u],
14
+ :auth_passwd => opts[:auth_p],
15
+ :login_user => opts[:login_u],
16
+ :login_passwd => opts[:login_p],
17
+ :day => opts[:day],
18
+ :month => opts[:month],
19
+ :year => opts[:year],
20
+ :code => TASK_CODE,
21
+ :title => TASK_TITLE,
22
+ :context => Nippo::Task.get_context,
23
+ })
24
+ begin
25
+ if server.login
26
+ server.set_am_task
27
+ server.set_rest
28
+ server.set_pm_task
29
+ server.submit
30
+
31
+ puts "Successfull to upload"
32
+ else
33
+ puts "ERROR: failed to login, please check your id/password."
34
+ end
35
+ rescue Exception => e
36
+ p e
37
+ end
38
+ end
39
+ end
40
+
41
+ options = {}
42
+ parser = OptionParser.new do |opt|
43
+ opt.banner = <<-EOS
44
+ Usage: register [parameters]
45
+
46
+ Parameters (All parameters are mandatory for registry):
47
+ EOS
48
+ #opt.banner = "All options are compulsory for registry"
49
+ opt.on('-d [day]', '--day', 'the day to register (DEFAULT: today)') { |value|
50
+ options[:day] = value }
51
+ opt.on('-m [mon]', '--month', 'the month to register (DEFAULT: current month)') { |value|
52
+ options[:month] = value }
53
+ opt.on('-y [year]', '--year', 'the year to register (DEFAULT: current year)') { |value|
54
+ options[:year] = value }
55
+ opt.on('-s hostaddr', '--server', 'host address of Nippo servalueice') { |value|
56
+ options[:server] = value }
57
+ opt.on('-U uid', '--basic_user', 'userid of BASIC authentication') { |value|
58
+ options[:auth_u] = value }
59
+ opt.on('-P passwd', '--basic_password', 'password to access Nippo servalueice') {|value|
60
+ options[:auth_p] = value }
61
+ opt.on('-u uid', '--login_user', 'userid of your-self to login') { |value|
62
+ options[:login_u] = value }
63
+ opt.on('-p passwd', '--login_password', 'password which is related to your account') { |value|
64
+ options[:login_p] = value }
65
+
66
+ opt.parse! ARGV
67
+ end
68
+
69
+ DEFAULT_KEYS = [:day, :month, :year, :server, :auth_u, :auth_p, :login_u, :login_p]
70
+ def set_default_params(opts)
71
+ ret = {}
72
+ DEFAULT_KEYS.each do |key|
73
+ value = opts[key]
74
+
75
+ ret[key] = case key
76
+ when :day
77
+ value != nil ? value : Time.now.day
78
+ when :month
79
+ value != nil ? value : Time.now.month
80
+ when :year
81
+ value != nil ? value : Time.now.year
82
+ else
83
+ value
84
+ end
85
+ end
86
+
87
+ ret
88
+ end
89
+ def is_valid? opts
90
+ DEFAULT_KEYS.all? do |key|
91
+ opts[key] != nil
92
+ end
93
+ end
94
+
95
+ options = set_default_params(options)
96
+ unless is_valid?(options)
97
+ puts parser.help
98
+ exit 1
99
+ end
100
+
101
+ Nippo.register_task(options)
data/lib/nippo.rb ADDED
@@ -0,0 +1,12 @@
1
+ require "nippo/version"
2
+ require "nippo/server"
3
+ require "nippo/task"
4
+
5
+ module Nippo
6
+ # load plugins
7
+ plugin_path = File.dirname(__FILE__) + "/plugin"
8
+
9
+ Dir["#{plugin_path}/*"].each do |file|
10
+ require file
11
+ end
12
+ end
@@ -0,0 +1,126 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+
4
+ module Nippo
5
+ class Server
6
+ def initialize(opts)
7
+ @host = opts[:server]
8
+ @basic_user = opts[:auth_user]
9
+ @basic_passwd = opts[:auth_passwd]
10
+
11
+ @login_user = opts[:login_user]
12
+ @login_passwd = opts[:login_passwd]
13
+
14
+ @task_code = opts[:code]
15
+ @task_title = opts[:title]
16
+ @task_context = opts[:context]
17
+
18
+ @day = opts[:day].to_i < 10 ? "0#{opts[:day]}" : opts[:day]
19
+ @month = opts[:month].to_i < 10 ? "0#{opts[:month]}" : opts[:month]
20
+ @year = opts[:year]
21
+
22
+ @logged_in = false
23
+ @cookie = nil
24
+ end
25
+
26
+ def login
27
+ resp = post({
28
+ :path => 'new_nippou/users/login',
29
+ :data => {
30
+ 'data[User][userid]' => @login_user,
31
+ 'data[User][password]' => @login_passwd,
32
+ 'logincheck' => '',
33
+ },
34
+ })
35
+ @cookie = resp.get_fields('set-cookie').map{|x| x.split(';').first}.join(';')
36
+
37
+ # When login processin is successful, responce code 302 (Net::HTTPFound) is returned.
38
+ @logged_in = resp.class == Net::HTTPFound
39
+ end
40
+ def set_am_task
41
+ post({
42
+ :path => "new_nippou/inputs/nippou/#{@year}/#{@month}/#{@day}/#am",
43
+ :data => {
44
+ 'data[Amtask][name]' => @task_code,
45
+ 'data[Amtask][taskcodename]' => @task_code,
46
+ 'data[Amtask][title]' => @task_title.encode('EUC-JP'),
47
+ 'data[Amtask][SH]' => '10',
48
+ 'data[Amtask][SM]' => '00',
49
+ 'data[Amtask][EH]' => '13',
50
+ 'data[Amtask][EM]' => '00',
51
+ 'data[Amtask][comment]' => @task_context.encode('EUC-JP'),
52
+ 'data[Amtask][plan]' => '',
53
+ 'data[Amtask][subject]' => '',
54
+ 'data[Amtask][opinion]' => '',
55
+ 'data[Amtask][other]' => '',
56
+ 'amregist' => '1',
57
+ 'data[Amtask][id]' => '',
58
+ },
59
+ })
60
+ end
61
+
62
+ def set_pm_task
63
+ post({
64
+ :path => "new_nippou/inputs/nippou/#{@year}/#{@month}/#{@day}/#pm",
65
+ :data => {
66
+ 'data[Pmtask][name]' => @task_code,
67
+ 'data[Pmtask][taskcodename]' => @task_code,
68
+ 'data[Pmtask][title]' => @task_title.encode('EUC-JP'),
69
+ 'data[Pmtask][SH]' => '14',
70
+ 'data[Pmtask][SM]' => '00',
71
+ 'data[Pmtask][EH]' => '19',
72
+ 'data[Pmtask][EM]' => '00',
73
+ 'data[Pmtask][comment]' => @task_context.encode('EUC-JP'),
74
+ 'data[Pmtask][plan]' => '',
75
+ 'data[Pmtask][subject]' => '',
76
+ 'data[Pmtask][opinion]' => '',
77
+ 'data[Pmtask][other]' => '',
78
+ 'pmregist' => '1',
79
+ 'data[Pmtask][id]' => '',
80
+ },
81
+ })
82
+ end
83
+
84
+ def set_rest
85
+ post({
86
+ :path => "new_nippou/inputs/nippou/#{@year}/#{@month}/#{@day}/#rest",
87
+ :data => {
88
+ 'data[Rest][SH]' => '13',
89
+ 'data[Rest][SM]' => '00',
90
+ 'data[Rest][EH]' => '14',
91
+ 'data[Rest][EM]' => '00',
92
+ 'registresttime' => '登録'.encode('EUC-JP'),
93
+ },
94
+ })
95
+ end
96
+
97
+ def submit
98
+ post({
99
+ :path => "new_nippou/inputs/nippouend/#{@year}/#{@month}/#{@day}/",
100
+ :data => {
101
+ 'data[Mail][memo]' => '',
102
+ },
103
+ })
104
+ end
105
+
106
+ def logged_in?
107
+ @logged_in
108
+ end
109
+
110
+ private
111
+ def post(opts)
112
+ url = URI.parse("http://#{@host}/#{opts[:path]}")
113
+
114
+ # setting request parameters
115
+ req = Net::HTTP::Post.new(url.path)
116
+ req.basic_auth(@basic_user, @basic_passwd)
117
+ req.set_form_data(opts[:data])
118
+ req['Cookie'] = @cookie
119
+
120
+ # send http post request
121
+ Net::HTTP.new(url.host, url.port).start do |http|
122
+ http.request(req)
123
+ end
124
+ end
125
+ end
126
+ end
data/lib/nippo/task.rb ADDED
@@ -0,0 +1,11 @@
1
+ module Nippo
2
+ class Task
3
+ def self.get_context
4
+ ret = ""
5
+ while s = STDIN.gets
6
+ s.chomp =~ /^exit|^EXIT/ ? break : ret += s
7
+ end
8
+ ret
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Nippo
2
+ VERSION = "0.9.0"
3
+ end
File without changes
@@ -0,0 +1,27 @@
1
+ module Nippo
2
+ # this class generate random task
3
+ class Task
4
+ DEFAULT_LENGTH = 4
5
+
6
+ PATTERN = [
7
+ '* タスク整理',
8
+ '* チームミーティング',
9
+ '* ドキュメント整理',
10
+ '* 1on1',
11
+ '* 社外ミーティング',
12
+ '* 資料作成',
13
+ '* 打ち合わせ',
14
+ '* 開発',
15
+ '* 報告書作成',
16
+ '* 案件対応',
17
+ ]
18
+
19
+ def self.get_context
20
+ ret = ""
21
+ DEFAULT_LENGTH.times do
22
+ ret += PATTERN[rand(PATTERN.size)] + "\n"
23
+ end
24
+ ret
25
+ end
26
+ end
27
+ end
data/nippo.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nippo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dl-nippo-helper"
8
+ spec.version = Nippo::VERSION
9
+ spec.authors = ["Hiroyasu OHYAMA"]
10
+ spec.email = ["user.localhost2000@gmail.com"]
11
+
12
+ spec.summary = %q{An useful tool to register daily task}
13
+ spec.description = %q{You can automate the task to register your nippo at the end of each month.}
14
+ spec.homepage = "https://rubygems.org/gems/dl-nippo-helper"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = ""
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "bin"
27
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec"
33
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dl-nippo-helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Hiroyasu OHYAMA
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-21 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.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
+ description: You can automate the task to register your nippo at the end of each month.
56
+ email:
57
+ - user.localhost2000@gmail.com
58
+ executables:
59
+ - nippo-register
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - .rspec
65
+ - .travis.yml
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/nippo-register
72
+ - lib/nippo.rb
73
+ - lib/nippo/server.rb
74
+ - lib/nippo/task.rb
75
+ - lib/nippo/version.rb
76
+ - lib/plugin/.gitkeep
77
+ - lib/plugin/xaas.rb
78
+ - nippo.gemspec
79
+ homepage: https://rubygems.org/gems/dl-nippo-helper
80
+ licenses:
81
+ - MIT
82
+ metadata:
83
+ allowed_push_host: ''
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.0.14.1
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: An useful tool to register daily task
104
+ test_files: []