netprint 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.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Netprint
2
2
 
3
- A library to upload file to netprint(https://www.printing.ne.jp/)
3
+ A library to use netprint(https://www.printing.ne.jp/)
4
4
 
5
5
  ## Installation
6
6
 
@@ -25,6 +25,29 @@ n.login
25
25
  registration_code = n.upload('/path/to/file.pdf')
26
26
  ```
27
27
 
28
+ ### Upload Options
29
+
30
+ ```ruby
31
+ n.upload('/path/to/file.pdf', {
32
+
33
+ # Netprint::PAPER_SIZE::A3
34
+ # Netprint::PAPER_SIZE::A4(default)
35
+ # Netprint::PAPER_SIZE::B4
36
+ # Netprint::PAPER_SIZE::B5
37
+ # Netprint::PAPER_SIZE::L
38
+ :paper_size => Netprint::PAPER_SIZE::B4,
39
+
40
+ # Netprint::COLOR::SELECT_WHEN_PRINT(default)
41
+ # Netprint::COLOR::BW
42
+ # Netprint::COLOR::COLOR
43
+ :color => Netprint::COLOR::BW,
44
+
45
+ :secret_code => '1234',
46
+ :email => 'foo@example.com'
47
+ })
48
+ ```
49
+
50
+
28
51
  ## Contributing
29
52
 
30
53
  1. Fork it
@@ -15,25 +15,23 @@ module Netprint
15
15
  end
16
16
 
17
17
  def login
18
- page = mechanize.get(login_url)
18
+ page = mechanize.get(url.login)
19
19
  @session_id = page.links[0].href.match(/s=([^&]+)/)[1]
20
20
  end
21
21
 
22
- def upload(filename)
22
+ def upload(filename, options = {})
23
23
  raise 'not logged in' unless login?
24
24
 
25
+ options = Options.new(options)
26
+
25
27
  Dir.mktmpdir do |dir|
26
28
  upload_filename = (Pathname(dir) + ([Time.now.to_f.to_s, File.basename(filename)].join('_'))).to_s
27
29
  cp filename, upload_filename
28
30
 
29
- page = mechanize.get(upload_url)
31
+ page = mechanize.get(url.upload)
30
32
  page = page.form_with(:name => 'uploadform') do |form|
31
33
  form.file_uploads.first.file_name = upload_filename
32
- form['papersize'] = '0'
33
- form['color'] = '0'
34
- form['number'] = '0'
35
- form['secretcodesw'] = '0'
36
- form['mailsw'] = '0'
34
+ options.apply(form)
37
35
  end.submit
38
36
 
39
37
  raise UploadError if page.search('//img[@src="/img/icn_error.jpg"]').size == 1
@@ -52,7 +50,7 @@ module Netprint
52
50
  code = nil
53
51
 
54
52
  loop do
55
- page = mechanize.get(list_url)
53
+ page = mechanize.get(url.list)
56
54
  _, registered_name, status = page.search('//tr[@bgcolor="#CFCFE6"][1]/td')
57
55
 
58
56
  if status.text =~ /^[0-9A-Z]{8}+$/
@@ -68,21 +66,8 @@ module Netprint
68
66
  code
69
67
  end
70
68
 
71
- def upload_url
72
- expand_url(:s => @session_id, :c => 0, :m => 1)
73
- end
74
-
75
- def list_url
76
- expand_url(:s => @session_id, :c => 0, :m => 0)
77
- end
78
-
79
- def login_url
80
- expand_url(:i => userid, :p => password)
81
- end
82
-
83
- def expand_url(params)
84
- Addressable::Template.new('https://www.printing.ne.jp/cgi-bin/mn.cgi?{-join|&|i,p,s,c,m}').
85
- expand(params)
69
+ def url
70
+ URL.new(@session_id, userid, password)
86
71
  end
87
72
 
88
73
  def mechanize
@@ -0,0 +1,20 @@
1
+ module Netprint
2
+ module PAPERSIZE
3
+ A4 = '0'
4
+ A3 = '1'
5
+ B4 = '2'
6
+ B5 = '3'
7
+ L = '4'
8
+ end
9
+
10
+ module COLOR
11
+ SELECT_WHEN_PRINT = '1'
12
+ BW = '0'
13
+ COLOR = '2'
14
+ end
15
+
16
+ module CODE_TYPE
17
+ ALNUM = '0'
18
+ NUM = '1'
19
+ end
20
+ end
@@ -0,0 +1,32 @@
1
+ module Netprint
2
+ class Options
3
+ attr_reader :options
4
+
5
+ def initialize(options = {})
6
+ @options = {
7
+ :paper_size => PAPERSIZE::A4,
8
+ :color => COLOR::BW,
9
+ :code_type => CODE_TYPE::ALNUM,
10
+ :secret_code => nil,
11
+ :email => nil
12
+ }.merge(options)
13
+ end
14
+
15
+ def apply(form)
16
+ check_radiobutton(form, 'papersize', options[:paper_size])
17
+ check_radiobutton(form, 'color', options[:color])
18
+ check_radiobutton(form, 'number', options[:code_type])
19
+ check_radiobutton(form, 'secretcodesw', options[:secret_code] =~ /^\d{4}$/ ? '1' : '0')
20
+ check_radiobutton(form, 'mailsw', options[:email] ? '1' : '0')
21
+
22
+ form['secretcode'] = options[:secret_code] if options[:secret_code] =~ /^\d{4}$/
23
+ form['mailaddr'] = options[:email] if options[:email]
24
+ end
25
+
26
+ private
27
+
28
+ def check_radiobutton(form, name, value)
29
+ form.radiobutton_with(:name => name, :value => value).check
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ module Netprint
2
+ class URL
3
+ def initialize(session_id, userid, password)
4
+ @session_id = session_id
5
+ @userid = userid
6
+ @password = password
7
+ end
8
+
9
+ def login
10
+ expand(:i => @userid, :p => @password)
11
+ end
12
+
13
+ def upload
14
+ expand(:s => @session_id, :c => 0, :m => 1)
15
+ end
16
+
17
+ def list
18
+ expand(:s => @session_id, :c => 0, :m => 0)
19
+ end
20
+
21
+ private
22
+
23
+ def expand(params)
24
+ Addressable::Template.new(template).
25
+ expand(params).
26
+ to_str
27
+ end
28
+
29
+ def template
30
+ Addressable::VERSION::STRING >= '2.2.7' ?
31
+ 'https://www.printing.ne.jp/cgi-bin/mn.cgi{?i,p,s,c,m}' :
32
+ 'https://www.printing.ne.jp/cgi-bin/mn.cgi?{-join|&|i,p,s,c,m}'
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module Netprint
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/netprint.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  require 'addressable/template'
2
- require 'addressable/uri'
3
2
  require 'mechanize'
4
3
 
5
4
  require 'netprint/version'
5
+ require 'netprint/constants'
6
6
  require 'netprint/agent'
7
+ require 'netprint/url'
7
8
  require 'netprint/error'
9
+ require 'netprint/options'
8
10
 
9
11
  module Netprint
10
12
  # Your code goes here...
data/netprint.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_development_dependency('rspec', ['~> 2.8.0'])
19
19
  gem.add_development_dependency('netprint')
20
+ gem.add_development_dependency('webmock')
20
21
  gem.add_dependency('mechanize', '2.5.1')
21
- gem.add_dependency('addressable', '2.2.6')
22
+ gem.add_dependency('addressable')
22
23
  end
data/spec/list.html ADDED
@@ -0,0 +1,11 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: text/html
3
+ Server: Microsoft-IIS/6.0
4
+ X-Powered-By: ASP.NET
5
+ Date: Thu, 18 Oct 2012 08:42:54 GMT
6
+ Connection: close
7
+
8
+ <html>
- ->
1
9
  selvalue = curfrm.papersize[i].value;
2
10
  curfrm.submit();
3
11
  for(var i=0;i<curfrm.papersize.length;i++)
4
12
  if(curfrm.papersize[i].checked==true)
5
13
  j=j+1;
6
14
 
7
- ->
8
15
  var _gaq = _gaq || [];
9
16
  _gaq.push(['_setAccount', 'UA-3871039-1']);
10
17
  _gaq.push(['_trackPageview']);
11
18
  (function() {
12
19
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
13
20
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
14
21
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
15
22
  })();
23
+
24
+
25
+
@@ -4,11 +4,10 @@ include Netprint
4
4
 
5
5
  describe Agent do
6
6
  before do
7
- unless ENV['NETPRINT_USERID'] && ENV['NETPRINT_PASSWORD']
8
- raise 'set environment variable NETPRINT_USERID and NETPRINT_PASSWORD before running spec'
9
- end
7
+ @agent = Agent.new('user_id', 'password')
10
8
 
11
- @agent = Agent.new(ENV['NETPRINT_USERID'], ENV['NETPRINT_PASSWORD'])
9
+ stub_request(:get, 'https://www.printing.ne.jp/cgi-bin/mn.cgi?i=user_id&p=password').
10
+ to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list.html')).read)
12
11
  end
13
12
 
14
13
  it 'should login' do
@@ -20,6 +19,13 @@ describe Agent do
20
19
  end
21
20
 
22
21
  it 'should upload' do
22
+ stub_request(:get, 'https://www.printing.ne.jp/cgi-bin/mn.cgi?c=0&m=1&s=qwertyuiopoiuytrewq').
23
+ to_return(open(File.expand_path(File.dirname(__FILE__) + '/../upload.html')).read)
24
+ stub_request(:post, 'https://www.printing.ne.jp/cgi-bin/mn.cgi?c=0&m=1&s=qwertyuiopoiuytrewq').
25
+ to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list.html')).read)
26
+ stub_request(:get, 'https://www.printing.ne.jp/cgi-bin/mn.cgi?c=0&m=0&s=qwertyuiopoiuytrewq').
27
+ to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list.html')).read)
28
+
23
29
  filename = File.expand_path(File.dirname(__FILE__) + '/../foo.pdf')
24
30
  @agent.login
25
31
 
@@ -0,0 +1,139 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ include Netprint
4
+
5
+ describe Options do
6
+ subject do
7
+ Options.new(options)
8
+ end
9
+
10
+ let(:options) { {} }
11
+
12
+ describe '#apply' do
13
+ context 'default' do
14
+ it do
15
+ form = Object.new
16
+ form.should be_checked('papersize', PAPERSIZE::A4)
17
+ form.should be_checked('color', COLOR::BW)
18
+ form.should be_checked('number', CODE_TYPE::ALNUM)
19
+ form.should be_checked('secretcodesw', '0')
20
+ form.should be_checked('mailsw', '0')
21
+
22
+ form.should_not_receive(:[]=)
23
+
24
+ subject.apply(form)
25
+ end
26
+ end
27
+
28
+ context 'with secret code' do
29
+ let(:options) { { :secret_code => '0123' } }
30
+
31
+ it do
32
+ form = Object.new
33
+ form.should be_checked('papersize', PAPERSIZE::A4)
34
+ form.should be_checked('color', COLOR::BW)
35
+ form.should be_checked('number', CODE_TYPE::ALNUM)
36
+ form.should be_checked('secretcodesw', '1')
37
+ form.should be_checked('mailsw', '0')
38
+
39
+ form.should_receive(:[]=).with('secretcode', '0123')
40
+
41
+ subject.apply(form)
42
+ end
43
+ end
44
+
45
+ context 'with email' do
46
+ let(:options) { { :email => 'test@example.com' } }
47
+
48
+ it do
49
+ form = Object.new
50
+ form.should be_checked('papersize', PAPERSIZE::A4)
51
+ form.should be_checked('color', COLOR::BW)
52
+ form.should be_checked('number', CODE_TYPE::ALNUM)
53
+ form.should be_checked('secretcodesw', '0')
54
+ form.should be_checked('mailsw', '1')
55
+
56
+ form.should_receive(:[]=).with('mailaddr', 'test@example.com')
57
+
58
+ subject.apply(form)
59
+ end
60
+ end
61
+
62
+ context 'with paper size' do
63
+ let(:options) { { :paper_size => PAPERSIZE::B4 } }
64
+
65
+ it do
66
+ form = Object.new
67
+ form.should be_checked('papersize', PAPERSIZE::B4)
68
+ form.should be_checked('color', COLOR::BW)
69
+ form.should be_checked('number', CODE_TYPE::ALNUM)
70
+ form.should be_checked('secretcodesw', '0')
71
+ form.should be_checked('mailsw', '0')
72
+
73
+ form.should_not_receive(:[]=)
74
+
75
+ subject.apply(form)
76
+ end
77
+ end
78
+
79
+ context 'with color' do
80
+ let(:options) { { :color => COLOR::COLOR } }
81
+
82
+ it do
83
+ form = Object.new
84
+ form.should be_checked('papersize', PAPERSIZE::A4)
85
+ form.should be_checked('color', COLOR::COLOR)
86
+ form.should be_checked('number', CODE_TYPE::ALNUM)
87
+ form.should be_checked('secretcodesw', '0')
88
+ form.should be_checked('mailsw', '0')
89
+
90
+ form.should_not_receive(:[]=)
91
+
92
+ subject.apply(form)
93
+ end
94
+ end
95
+
96
+ context 'with code type' do
97
+ let(:options) { { :code_type => CODE_TYPE::NUM } }
98
+
99
+ it do
100
+ form = Object.new
101
+ form.should be_checked('papersize', PAPERSIZE::A4)
102
+ form.should be_checked('color', COLOR::BW)
103
+ form.should be_checked('number', CODE_TYPE::NUM)
104
+ form.should be_checked('secretcodesw', '0')
105
+ form.should be_checked('mailsw', '0')
106
+
107
+ form.should_not_receive(:[]=)
108
+
109
+ subject.apply(form)
110
+ end
111
+ end
112
+
113
+ context 'with all options' do
114
+ let(:options) {
115
+ {
116
+ :paper_size => PAPERSIZE::B5,
117
+ :color => COLOR::SELECT_WHEN_PRINT,
118
+ :code_type => CODE_TYPE::NUM,
119
+ :secret_code => '0987',
120
+ :email => 'foo@example.com'
121
+ }
122
+ }
123
+
124
+ it do
125
+ form = Object.new
126
+ form.should be_checked('papersize', PAPERSIZE::B5)
127
+ form.should be_checked('color', COLOR::SELECT_WHEN_PRINT)
128
+ form.should be_checked('number', CODE_TYPE::NUM)
129
+ form.should be_checked('secretcodesw', '1')
130
+ form.should be_checked('mailsw', '1')
131
+
132
+ form.should_receive(:[]=).with('secretcode', '0987')
133
+ form.should_receive(:[]=).with('mailaddr', 'foo@example.com')
134
+
135
+ subject.apply(form)
136
+ end
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ include Netprint
4
+
5
+ describe URL do
6
+ subject do
7
+ URL.new(s, i, p)
8
+ end
9
+
10
+ let(:i) { 'username' }
11
+ let(:p) { 'password' }
12
+
13
+ context 'logged in' do
14
+ let(:s) { 'xxxxxxxx' }
15
+
16
+ its(:login) { should eql('https://www.printing.ne.jp/cgi-bin/mn.cgi?i=username&p=password') }
17
+ its(:upload) { should eql('https://www.printing.ne.jp/cgi-bin/mn.cgi?s=xxxxxxxx&c=0&m=1') }
18
+ its(:list) { should eql('https://www.printing.ne.jp/cgi-bin/mn.cgi?s=xxxxxxxx&c=0&m=0') }
19
+ end
20
+
21
+ context 'not logged in' do
22
+ let(:s) { nil }
23
+
24
+ its(:login) { should eql('https://www.printing.ne.jp/cgi-bin/mn.cgi?i=username&p=password') }
25
+ end
26
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,6 @@
1
+ require 'rspec'
1
2
  require 'netprint'
3
+ require 'webmock/rspec'
2
4
 
3
5
  # This file was generated by the `rspec --init` command. Conventionally, all
4
6
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
@@ -17,3 +19,12 @@ RSpec.configure do |config|
17
19
  # --seed 1234
18
20
  config.order = 'random'
19
21
  end
22
+
23
+ RSpec::Matchers.define :be_checked do |name, value|
24
+ match do |form|
25
+ radiobutton = Object.new
26
+ radiobutton.should_receive(:check)
27
+
28
+ form.should_receive(:radiobutton_with).with(:name => name, :value => value).and_return(radiobutton)
29
+ end
30
+ end
data/spec/upload.html ADDED
@@ -0,0 +1,372 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: text/html
3
+ Server: Microsoft-IIS/6.0
4
+ X-Powered-By: ASP.NET
5
+ Date: Thu, 18 Oct 2012 08:57:07 GMT
6
+ Connection: close
7
+
8
+ <html>
9
+ <head><title>�l�b�g�v�����g</title>
10
+ <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
11
+ <link rel="stylesheet" href="/home.css" type="text/css">
12
+ <style type="text/css">
13
+ <!--
14
+ a:link{ text-decoration:underline;}
15
+ a:visited{ text-decoration:underline;}
16
+ a:hover{ text-decoration:underline;}
17
+ a:active{ text-decoration:underline;}
18
+ -->
19
+ </style>
20
+ <script language="JavaScript">
21
+ <!--
22
+ window.onunload = function() {};
23
+ var repeatcnt = 0;
24
+ function CheckIsRepeat(){
25
+ if (++repeatcnt>1){
26
+ return true;
27
+ } else {
28
+ return false;
29
+ }
30
+ }
31
+ function setcheck(checktype)
32
+ {var lop;
33
+ for (lop = 0;lop < document.mform.length;lop++){
34
+ if (document.mform.elements[lop].type == "checkbox")
35
+ document.mform.elements[lop].checked = checktype;}};
36
+ function ChangePCount(pc)
37
+ {var ct = pc.options[pc.selectedIndex].value;
38
+ location.href = "/cgi-bin/mn.cgi?s=9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ&c=0&pcount="+ct;}
39
+ function setNoLimit(obj) {
40
+ var len = obj.lyear.options.length;
41
+ obj.lyear.selectedIndex = len-1;
42
+ obj.lmon.selectedIndex = 11;
43
+ obj.lday.selectedIndex = 30;
44
+ }
45
+ function SetRadioDisable(curfrm)
46
+ {
47
+ repeatcnt = 0;
48
+
49
+ var selvalue = "";
50
+ var i;
51
+
52
+ for(i=0;i<curfrm.papersize.length;i++){
53
+ if(curfrm.papersize[i].checked == true){
54
+ selvalue = curfrm.papersize[i].value;
55
+ }
56
+ }
57
+ if (selvalue == "4"){
58
+ for(i=0;i<curfrm.color.length;i++)
59
+ {
60
+ if(curfrm.color[i].value == "2" )
61
+ { curfrm.color[i].disabled = false;
62
+ curfrm.color[i].checked = true; }
63
+ else
64
+ { curfrm.color[i].disabled = true; }
65
+ }
66
+ for(i=0;i<curfrm.duplextype.length;i++)
67
+ {
68
+ if(curfrm.duplextype[i].value == "0" )
69
+ { curfrm.duplextype[i].disabled = false;
70
+ curfrm.duplextype[i].checked = true; }
71
+ else
72
+ { curfrm.duplextype[i].disabled = true; }
73
+ }
74
+ }else{
75
+ for(i=0;i<curfrm.color.length;i++)
76
+ {
77
+ curfrm.color[i].disabled = false;
78
+ }
79
+ for(i=0;i<curfrm.duplextype.length;i++)
80
+ {
81
+ curfrm.duplextype[i].disabled = false;
82
+ }
83
+ }
84
+ }
85
+ function SetDuplexType(curfrm)
86
+ {
87
+ var selvalue = "";
88
+ var i;
89
+ selvalue = curfrm.lsize.value;
90
+ if (selvalue == "1"){
91
+ for(i=0;i<curfrm.duplextype.length;i++)
92
+ {
93
+ if(curfrm.duplextype[i].value == "0" )
94
+ { curfrm.duplextype[i].disabled = false;
95
+ curfrm.duplextype[i].checked = true; }
96
+ else
97
+ { curfrm.duplextype[i].disabled = true; }
98
+ }
99
+ }else{
100
+ for(i=0;i<curfrm.color.length;i++)
101
+ {
102
+ curfrm.color[i].disabled = false;
103
+ }
104
+ for(i=0;i<curfrm.duplextype.length;i++)
105
+ {
106
+ curfrm.duplextype[i].disabled = false;
107
+ }
108
+ }
109
+ }
110
+ function SetMValue(curfrm, mvalue)
111
+ {
112
+ curfrm.m.value = mvalue;
113
+ }
114
+ function SetSubmitURL(curfrm,mvalue){
115
+ SetMValue(curfrm, mvalue);
116
+ var filename = curfrm.file1.value;
117
+ if(filename.match(/\.(docx|pptx|xlsx)$/i)){
118
+ curfrm.action="https://www2.printing.ne.jp/cgi-bin/mn.cgi";
119
+ curfrm.submit();
120
+ }else{
121
+ curfrm.action="https://www.printing.ne.jp/cgi-bin/mn.cgi";
122
+ curfrm.submit();
123
+ }
124
+ }
125
+ function SetMagnification(){
126
+ var mmag;
127
+ var lurl;
128
+ if(document.uploadform.magnification.value === ""){
129
+ mmag = "1";
130
+ }else{
131
+ mmag = document.uploadform.magnification.value;
132
+ }
133
+ lurl = "/cgi-bin/mn.cgi?s=9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ&m=120&magnification="+mmag;
134
+ var ret = window.showModalDialog(lurl, 'pop1', 'dialogWidth=500px; dialogHeight=240px; menubar=no; toolbar=no; scrollbars=yes; center=yes; status=0;');
135
+
136
+ if (ret){
137
+ document.getElementById("magnification").value = ret[0];
138
+ document.getElementById("magnificationstr").innerHTML = ret[1];
139
+ }
140
+ }
141
+ function SetMagnification2(){
142
+ var mmag;
143
+ var lurl;
144
+ if(document.replaceform.magnification.value === ""){
145
+ mmag = "1";
146
+ }else{
147
+ mmag = document.replaceform.magnification.value;
148
+ }
149
+ lurl = "/cgi-bin/mn.cgi?s=9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ&m=120&magnification="+mmag;
150
+
151
+ var ret = window.showModalDialog(lurl, 'pop1', 'dialogWidth=500px; dialogHeight=240px; menubar=no; toolbar=no; scrollbars=yes; center=yes; status=0;');
152
+
153
+ if (ret){
154
+ document.getElementById("magnification").value = ret[0];
155
+ document.getElementById("magnificationstr").innerHTML = ret[1];
156
+ }
157
+
158
+ }
159
+ function checkPapersizeRadio(curfrm){
160
+ var j=0;
161
+ for(var i=0;i<curfrm.papersize.length;i++)
162
+ {
163
+ if(curfrm.papersize[i].checked==true)
164
+ j=j+1;
165
+ }
166
+
167
+ if(j==0)
168
+ {
169
+ alert("�p���T�C�Y��I�������������B");
170
+ document.getElementById("papersizetr").style.backgroundColor = "yellow";
171
+ return(1);
172
+ } else {
173
+ return(0);
174
+ }
175
+ }
176
+ function checkRadioAndSubmit(curfrm,mode){
177
+ var chkrep = CheckIsRepeat();
178
+
179
+ if (chkrep == false){
180
+ var i = checkPapersizeRadio(curfrm);
181
+ if (i == 0){
182
+ SetSubmitURL(curfrm,mode);
183
+ }
184
+ }
185
+ }
186
+ function checkFileExtAndSetPaper(curfrm){
187
+ var filename = document.getElementById("filename1").value;
188
+ var paperL = document.getElementById("paperL");
189
+ if(paperL){
190
+ if(filename.match(/\.(jpeg|jpg|jpe)$/i)){
191
+ document.getElementById("paperL").disabled = false;
192
+ }else{
193
+ document.getElementById("paperL").disabled = true;
194
+ if ( document.getElementById("paperL").checked == true ){
195
+ document.getElementById("paperA4").checked = true;
196
+ SetRadioDisable(curfrm)
197
+ alert("�p���T�C�Y��A4�ɕύX���܂����B");
198
+ }
199
+ }
200
+ }
201
+ }
202
+ function ChkUA(){
203
+ if (navigator.userAgent.indexOf('iPhone') > 0) {
204
+ var flag = confirm("�����p�̒[������l�b�g�v�����g�������p���������ɂ�iPhone/iPad�ŃA�v���i�����j�̃C���X�g�[�����K�v�ł��BApp Store�Ɉړ����܂����H");
205
+ if (flag){
206
+ window.location.href = "itms://itunes.apple.com/us/app/netprint/id372351201?mt=8";
207
+ }
208
+ }else if(navigator.userAgent.indexOf('iPad') > 0) {
209
+ var flag = confirm("�����p�̒[������l�b�g�v�����g�������p���������ɂ�iPhone/iPad�ŃA�v���i�����j�̃C���X�g�[�����K�v�ł��BApp Store�Ɉړ����܂����H");
210
+ if (flag){
211
+ window.location.href = "itms://itunes.apple.com/us/app/netprint/id372351201?mt=8";
212
+ }
213
+ }else if(navigator.userAgent.indexOf('Android') > 0) {
214
+ var flag = confirm("�����p�̒[������l�b�g�v�����g�������p���������ɂ�Android�ŃA�v���i�����j�̃C���X�g�[�����K�v�ł��BGoogle Play�Ɉړ����܂����H");
215
+ if (flag){
216
+ window.location.href = "https://play.google.com/store/apps/details?id=jp.co.fujixerox.np.activity";
217
+ }
218
+ }
219
+ }
220
+ -->
221
+ </script>
222
+ <script type="text/javascript">
223
+ var _gaq = _gaq || [];
224
+ _gaq.push(['_setAccount', 'UA-3871039-1']);
225
+ _gaq.push(['_trackPageview']);
226
+ (function() {
227
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
228
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
229
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
230
+ })();
231
+ </script>
232
+ </head>
233
+ <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
234
+ <table border="0" cellspacing="0" cellpadding="0" align="center" height="100%">
235
+ <tr valign="top">
236
+ <td align="right" background="/img/bk1.jpg">
237
+ <table width="15" border="0" cellspacing="0" cellpadding="0" background="/img/bk1.jpg" height="100">
238
+ <tr><td valign="top"><img src="/img/bk1.jpg" width="15" height="5"></td></tr>
239
+ </table>
240
+ </td>
241
+ <td align="center" width="750">
242
+ <form name="m1form" action="/cgi-bin/mn.cgi" method="post">
243
+ <input type="hidden" name="s" value="9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ"><input type="hidden" name="c" value="0">
244
+ <table width="750" border="0" cellspacing="0" cellpadding="0">
245
+ <tr><td valign="top">
246
+ <table width="750" border="0" cellspacing="0" cellpadding="0" height="50" background="/img/head.jpg">
247
+ <tr valign="top"><td valign="middle" align="right"><a href="/cgi-bin/mn.cgi?s=9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ&m=5"><img src="/img/btn_logout.jpg" width="61" height="21" hspace="10" alt="���O�A�E�g" border="0"></a></td></tr>
248
+
249
+ </table>
250
+ </td></tr>
251
+ <tr><td valign="top">
252
+ <table width="750" border="0" cellspacing="0" cellpadding="0" bgcolor="#4965A2">
253
+ <tr valign="top">
254
+ <td>
255
+ <table border="0" cellspacing="4" cellpadding="0" bgcolor="#4965A2">
256
+ <tr valign="top">
257
+
258
+ <td><a href="http://www.sej.co.jp/index.html" target="_blank"><img src="/img/btn_se.jpg" width="121" height="21" alt="�Z�u���C���u���X�܌���" border="0" name="Image11"></a></td>
259
+ <td><a href="/help/0210_filetouroku.htm" target="_blank"><img src=/img/btn_guide.jpg border=0 width="61" height="21" alt="�V�����E�B���h�E�ő���K�C�h��\�����܂�"></a></td>
260
+ <td><a href="/expert/index.html" target="_blank"><img src="/img/btn_tatsujin.jpg" width="61" height="21" alt="�B�l�̕���" border="0" name="Image22"></a></td>
261
+ <td><a href="/cgi-bin/mn.cgi?s=9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ&m=64" target="_blank"><img src="/img/btn_tech.jpg" width="111" height="21" alt="�Z�p�I�Ȃ��₢���킹" border="0" name="Image31"></a></td>
262
+ <td><a href="javascript:;" onclick="window.open('/cgi-bin/mn.cgi?s=9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ&m=110','pop1','width=330,height=235,scrollbars=no');"><img src=/img/btn_price.jpg border=0 width="36" height="21" alt="����"></a></td>
263
+
264
+ </tr>
265
+ </table>
266
+ </td>
267
+ <td align="right">
268
+ <table border="0" cellspacing="4" cellpadding="0" bgcolor="#91a7c7">
269
+ <tr valign="top">
270
+ <td><a href="/cgi-bin/mn.cgi?s=9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ&m=95"><img src="/img/btn_jisseki.jpg" width="72" height="21" alt="���p����" border="0" name="Image1"></a></td>
271
+ <td><a href="/cgi-bin/mn.cgi?s=9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ&m=30"><img src="/img/btn_user_shusei.jpg" width="124" height="21" alt="���[�U�[���̏C��" border="0" name="Image1"></a></td>
272
+ <td><a href="/cgi-bin/user.cgi?m=50&s=9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ"><img src="/img/btn_user_sakujo.jpg" width="124" height="21" alt="���[�U�[���̍폜" border="0" name="Image2"></a></td>
273
+ </tr>
274
+ </table>
275
+ </td></tr>
276
+ </table>
277
+ </td></tr>
278
+ <tr><td valign="top">
279
+ <table border="0" cellspacing="0" cellpadding="8" width="100%" bgcolor="#91a7c7" height="30">
280
+ <tr><td><font color="#FFFFFF" class="text14-b">�V�K�t�@�C���̓o�^</font></td></tr>
281
+ </table>
282
+ </form>
283
+ <form name="uploadform" enctype="multipart/form-data" method="post">
284
+ <input type="hidden" name="s" value="9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ"><input type="hidden" name="c" value="0"><input type=hidden name="m" value="2">
285
+ �e���ڂ�ݒ肵�A[�o�^����]���N���b�N���Ă��������B<br>
286
+ <br><br>
287
+ <table border=0>
288
+ <tr><td width=25%><b>�t�@�C�� : </b></td><td width=75%><input type=file name=file1 id=filename1 size=60 src=/img/btn_browse.jpg border=0 onChange=checkFileExtAndSetPaper(document.uploadform)></td></tr>
289
+ <tr><td></td><td><font color="red">���o�^�”\�ȃt�@�C���T�C�Y�ɂ͐���������܂��̂ŁA�����ӂ��������B</font></td><tr>
290
+ <tr>
291
+ <td colspan=2>�@</td>
292
+ </tr>
293
+ <tr id=papersizetr>
294
+ <td><b>�p���T�C�Y :</b></td>
295
+ <td>
296
+ <input type="radio" name=papersize id=paperA4 value=0 onClick="SetRadioDisable(document.uploadform)"><span class="text12">A4</span>
297
+ <input type="radio" name=papersize id=paperA3 value=1 onClick="SetRadioDisable(document.uploadform)"><span class="text12">A3</span>
298
+ <input type="radio" name=papersize id=paperB4 value=2 onClick="SetRadioDisable(document.uploadform)"><span class="text12">B4</span>
299
+ <input type="radio" name=papersize id=paperB5 value=3 onClick="SetRadioDisable(document.uploadform)"><span class="text12">B5</span>
300
+ <input type="radio" name=papersize id=paperL value=4 onClick="SetRadioDisable(document.uploadform)"><span class="text12">L�T�C�Y</span>
301
+ </td>
302
+ </tr>
303
+ <tr><td></td><td><font color="red">���K���I�������������B</font></td><tr>
304
+ <tr><td colspan=2>�@</td></tr>
305
+ <tr><td><b>�v�����g���p���T�C�Y :</b></td><td>�v�����g���I���i�k�T�C�Y�������j
306
+ </td></tr>
307
+ <tr><td colspan=2>�@</td></tr>
308
+ <tr><td width=20% valign=top><b>�J���[���[�h : </b></td><td width=80%>[�v�����g���ɑI��]�ɐݒ肷��ƁA�v�����g���ɃJ���[�Ńv�����g���邩<br>�����Ńv�����g���邩��I���ł��܂��B</td></tr>
309
+ <tr><td></td><td> <input type=radio name=color value=1 checked>�v�����g���ɑI��
310
+ <input type=radio name=color value=2>�J���[
311
+ <input type=radio name=color value=0>����</td>
312
+ </tr>
313
+ <tr><td colspan=2>�@</td></tr>
314
+ <tr><td><b>�\��ԍ��^�C�v :</b></td><td width=80%>[�����̂�]�ɐݒ肷��ƁA�v�����g�\��ԍ��𐔎��݂̂Ŕ��s���܂��B</td></tr>
315
+ <tr><td></td><td> <input type=radio name=number value=0 checked>�p����
316
+ <input type=radio name=number value=1>�����̂�</td></tr>
317
+ <tr><td colspan=2>�@</td></tr>
318
+ <tr><td><b>�Ïؔԍ� :</b></td><td>�Ïؔԍ���ݒ肷��ƁA�v�����g���ɂ����Ŏw�肵���Ïؔԍ����K�v�ɂȂ�܂��B</td></tr>
319
+ <tr><td> </td><td><input type=radio name=secretcodesw value=0 checked>�ݒ肵�Ȃ�
320
+ <input type=radio name=secretcodesw value=1>�ݒ肷��@<input type=text name=secretcode size=8 value=""><font class="text10">�@4���̈Ïؔԍ��𔼊p�����œ��͂��Ă��������B</font></td></tr>
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+ <input type=hidden name=duplextype value=9>
330
+ <tr><td colspan=2>�@</td></tr>
331
+ <tr><td><b>���̑��ݒ� :</b></td>
332
+ <td><table>
333
+ <tr>
334
+ <td width=75% id="magnificationstr">�����o�� </td>
335
+ <td><input type=button value=" ���̑��ݒ� " onclick="SetMagnification()">
336
+ <input type=hidden id="magnification" name="magnification" value="1">
337
+ <input type=hidden name=re value=1>
338
+ </td>
339
+ </tr>
340
+ </table>
341
+ </td>
342
+ </tr>
343
+ <tr><td colspan=2>�@</td></tr>
344
+ <tr><td><b>�o�^���ʒʒm :</b></td><td> </td></tr>
345
+ <tr><td> </td><td><input type="radio" name="mailsw" value="0" checked>�ʒm���Ȃ�
346
+ <input type="radio" name="mailsw" value="1">�ʒm����@<input type="text" name="mailaddr" size="30" maxlength="260" value=""><font class="text10">�@���[���A�h���X(1�ӏ��̂�)����͂��Ă��������B</font></td></tr>
347
+ </table>
348
+ <br><br>
349
+ <table border="0" cellspacing="0" cellpadding="8" width="100%" height="30">
350
+ <tr><td>
351
+ <center>
352
+ <a href="javascript:void(0);" onClick="checkRadioAndSubmit(document.uploadform,2);return false;"><img name=upload src=/img/btn_register.jpg width=70 height=20 border=0 alt="��L�̓��e�Ńt�@�C����o�^���܂�"></a>&nbsp;
353
+ <a href="/cgi-bin/mn.cgi?s=9L69b6j4jJ3BPUTrjS6NaiT1FfHdgYwQ&c=0&m=0"><img src=/img/btn_cancel2.jpg border=0 width=80 height=20 alt="�L�����Z��"></a>
354
+ </center>
355
+ </td></tr>
356
+ </table>
357
+ <script type="text/javascript">
358
+ ChkUA();
359
+ </script>
360
+
361
+ </td></tr>
362
+ <tr><td valign="top"><img src="/img/foot.jpg" width="750" height="20" alt="(C)Copyright Fuji Xerox Co., Ltd. All rights reserved."></td></tr>
363
+ </table>
364
+ </form>
365
+ </td>
366
+ <td align="left" background="/img/bk2.jpg">
367
+ <table width="15" border="0" cellspacing="0" cellpadding="0" background="/img/bk2.jpg" height="100">
368
+ <tr><td valign="top"><img src="/img/bk2.jpg" width="15" height="5"></td></tr>
369
+ </table>
370
+ </td></tr>
371
+ </table>
372
+ </body></html>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netprint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: webmock
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: mechanize
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -64,17 +80,17 @@ dependencies:
64
80
  requirement: !ruby/object:Gem::Requirement
65
81
  none: false
66
82
  requirements:
67
- - - '='
83
+ - - ! '>='
68
84
  - !ruby/object:Gem::Version
69
- version: 2.2.6
85
+ version: '0'
70
86
  type: :runtime
71
87
  prerelease: false
72
88
  version_requirements: !ruby/object:Gem::Requirement
73
89
  none: false
74
90
  requirements:
75
- - - '='
91
+ - - ! '>='
76
92
  - !ruby/object:Gem::Version
77
- version: 2.2.6
93
+ version: '0'
78
94
  description: A library to upload file to netprint
79
95
  email:
80
96
  - youpy@buycheapviagraonlinenow.com
@@ -90,12 +106,19 @@ files:
90
106
  - Rakefile
91
107
  - lib/netprint.rb
92
108
  - lib/netprint/agent.rb
109
+ - lib/netprint/constants.rb
93
110
  - lib/netprint/error.rb
111
+ - lib/netprint/options.rb
112
+ - lib/netprint/url.rb
94
113
  - lib/netprint/version.rb
95
114
  - netprint.gemspec
96
115
  - spec/foo.pdf
116
+ - spec/list.html
97
117
  - spec/netprint/agent_spec.rb
118
+ - spec/netprint/options_spec.rb
119
+ - spec/netprint/url_spec.rb
98
120
  - spec/spec_helper.rb
121
+ - spec/upload.html
99
122
  homepage: ''
100
123
  licenses: []
101
124
  post_install_message:
@@ -110,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
133
  version: '0'
111
134
  segments:
112
135
  - 0
113
- hash: 1936634862440199456
136
+ hash: 1537278400618148257
114
137
  required_rubygems_version: !ruby/object:Gem::Requirement
115
138
  none: false
116
139
  requirements:
@@ -119,14 +142,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
142
  version: '0'
120
143
  segments:
121
144
  - 0
122
- hash: 1936634862440199456
145
+ hash: 1537278400618148257
123
146
  requirements: []
124
147
  rubyforge_project:
125
- rubygems_version: 1.8.23
148
+ rubygems_version: 1.8.24
126
149
  signing_key:
127
150
  specification_version: 3
128
151
  summary: A library to upload file to netprint
129
152
  test_files:
130
153
  - spec/foo.pdf
154
+ - spec/list.html
131
155
  - spec/netprint/agent_spec.rb
156
+ - spec/netprint/options_spec.rb
157
+ - spec/netprint/url_spec.rb
132
158
  - spec/spec_helper.rb
159
+ - spec/upload.html