serialbar 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 +9 -0
- data/.rspec +2 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +56 -0
- data/README.rdoc +42 -0
- data/Rakefile +7 -0
- data/bin/serialbar +6 -0
- data/lib/serialbar/adapter.rb +36 -0
- data/lib/serialbar/adapters/file_system.rb +9 -0
- data/lib/serialbar/adapters/mongoid.rb +14 -0
- data/lib/serialbar/adapters/mysql.rb +0 -0
- data/lib/serialbar/adapters/postgresql.rb +0 -0
- data/lib/serialbar/cli.rb +89 -0
- data/lib/serialbar/exceptions.rb +7 -0
- data/lib/serialbar/generators/README +1 -0
- data/lib/serialbar/generators/boiler_plate.rb +37 -0
- data/lib/serialbar/generators/mongoid_example.yml +24 -0
- data/lib/serialbar/generators/test.rb +1 -0
- data/lib/serialbar/helpers.rb +7 -0
- data/lib/serialbar/listener.rb +124 -0
- data/lib/serialbar/scratch.rb +41 -0
- data/lib/serialbar/version.rb +3 -0
- data/lib/serialbar.rb +6 -0
- data/serialbar.gemspec +29 -0
- data/serialbar.sublime-project +9 -0
- data/serialbar.sublime-workspace +556 -0
- data/seriallisten.rb +99 -0
- data/spec/data_file_spec.rb +18 -0
- data/spec/listener_spec.rb +47 -0
- data/spec/mongoid_spec.rb +4 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/shared_examples_for_modules.rb +38 -0
- data/spec/test.rb +42 -0
- metadata +198 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
#dummy class
|
4
|
+
class Ascoltatore
|
5
|
+
include Serialbar::Listener
|
6
|
+
end
|
7
|
+
|
8
|
+
class Listener
|
9
|
+
include Serialbar::Listener
|
10
|
+
def parse(string)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec.describe Ascoltatore do
|
15
|
+
it_behaves_like Serialbar::Listener
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
@obj = described_class.new
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should raise error if parse is missing' do
|
22
|
+
expect { @obj.parse_missing? }.to raise_error(Serialbar::Exceptions::NoParseMethodError, "Parse method not implemented")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
RSpec.describe Listener do
|
27
|
+
it_behaves_like Serialbar::Listener
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
@obj = described_class.new
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should not raise error if parse is present' do
|
34
|
+
expect{@obj.parse_missing?}.not_to raise_error
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should raise a PortNotInitialized exception if setup has not been called' do
|
38
|
+
expect{@obj.port_initialized?}.to raise_error(Serialbar::Exceptions::PortNotInitialized, "Call setup on listener class to initialize serial port")
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should return a serialport object' do
|
42
|
+
pending("No serialports on this computer")
|
43
|
+
this_should_not_get_executed
|
44
|
+
@obj.setup("/dev/ttyS0") # don't have serialports on this test computer
|
45
|
+
expect (@obj.serial_port).to be_instance_of SerialPort
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'serialbar'
|
3
|
+
|
4
|
+
Dir["./spec/support/**/*.rb"].each {|f| require f}
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# Setting this config option `false` removes rspec-core's monkey patching of the
|
8
|
+
# top level methods like `describe`, `shared_examples_for` and `shared_context`
|
9
|
+
# on `main` and `Module`. The methods are always available through the `RSpec`
|
10
|
+
# module like `RSpec.describe` regardless of this setting.
|
11
|
+
# For backwards compatibility this defaults to `true`.
|
12
|
+
#
|
13
|
+
# https://relishapp.com/rspec/rspec-core/v/3-0/docs/configuration/global-namespace-dsl
|
14
|
+
config.expose_dsl_globally = false
|
15
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
RSpec.shared_examples_for Serialbar::Adapter do
|
2
|
+
context 'with an instance' do
|
3
|
+
#before(:each) do
|
4
|
+
# @obj = described_class.new
|
5
|
+
#end
|
6
|
+
# test instance methods here
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'class methods' do
|
10
|
+
it 'should be an adapted class' do
|
11
|
+
expect(described_class).to respond_to :foo
|
12
|
+
end
|
13
|
+
|
14
|
+
it "responds to configure adapter" do
|
15
|
+
expect(described_class).to respond_to :configure_adapter
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
RSpec.shared_examples_for Serialbar::Listener do
|
22
|
+
context 'with an instance' do
|
23
|
+
before(:each) do
|
24
|
+
@obj = described_class.new
|
25
|
+
end
|
26
|
+
|
27
|
+
# test instance methods here
|
28
|
+
it 'should be an instance of listener' do
|
29
|
+
expect(@obj).to be_instance_of(described_class)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should response to test listener method' do
|
33
|
+
expect(@obj.listener?).to eq(true)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/spec/test.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' )
|
2
|
+
|
3
|
+
require 'serialbox'
|
4
|
+
|
5
|
+
class DataFile
|
6
|
+
include Serialbox::Adapter
|
7
|
+
configure_adapter :mongoid
|
8
|
+
field :time
|
9
|
+
field :experiment
|
10
|
+
store_in session: "default"
|
11
|
+
end
|
12
|
+
|
13
|
+
class PhPoint < DataFile
|
14
|
+
field :ph
|
15
|
+
end
|
16
|
+
|
17
|
+
class EhPoint < DataFile
|
18
|
+
field :eh
|
19
|
+
end
|
20
|
+
|
21
|
+
class Listener
|
22
|
+
include Serialbox::Listener
|
23
|
+
|
24
|
+
#def parse #parse the input
|
25
|
+
# p = PhPoint.new({ph: "5", time: Time.now, experiment: "TEST0001"})
|
26
|
+
# p.save
|
27
|
+
#end
|
28
|
+
|
29
|
+
#how does it poll the port, or wait for input?
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
l = Listener.new("creature")
|
34
|
+
l.setup
|
35
|
+
#l.run
|
36
|
+
|
37
|
+
#p = PhPoint.new({ph: "5", time: Time.now, experiment: "TEST0001"})
|
38
|
+
#p.save
|
39
|
+
#points = PhPoint.where(experiment: "TEST0001")
|
40
|
+
#points.each do |point|
|
41
|
+
# puts point.time
|
42
|
+
#end
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: serialbar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Bramble
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.0.0
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.0.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: mongoid
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.1'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 3.1.6
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '3.1'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 3.1.6
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: serialport
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '1.3'
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.3.0
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.3'
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 1.3.0
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: thor
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0.19'
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.19.1
|
97
|
+
type: :runtime
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.19'
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 0.19.1
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
name: timers
|
109
|
+
requirement: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - "~>"
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '3.0'
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 3.0.0
|
117
|
+
type: :runtime
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '3.0'
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 3.0.0
|
127
|
+
description: Parse and save incoming data to storage, default mongodb
|
128
|
+
email:
|
129
|
+
- jbramble82@hotmail.com
|
130
|
+
executables:
|
131
|
+
- serialbar
|
132
|
+
extensions: []
|
133
|
+
extra_rdoc_files: []
|
134
|
+
files:
|
135
|
+
- ".gitignore"
|
136
|
+
- ".rspec"
|
137
|
+
- Gemfile
|
138
|
+
- Gemfile.lock
|
139
|
+
- README.rdoc
|
140
|
+
- Rakefile
|
141
|
+
- bin/serialbar
|
142
|
+
- lib/serialbar.rb
|
143
|
+
- lib/serialbar/adapter.rb
|
144
|
+
- lib/serialbar/adapters/file_system.rb
|
145
|
+
- lib/serialbar/adapters/mongoid.rb
|
146
|
+
- lib/serialbar/adapters/mysql.rb
|
147
|
+
- lib/serialbar/adapters/postgresql.rb
|
148
|
+
- lib/serialbar/cli.rb
|
149
|
+
- lib/serialbar/exceptions.rb
|
150
|
+
- lib/serialbar/generators/README
|
151
|
+
- lib/serialbar/generators/boiler_plate.rb
|
152
|
+
- lib/serialbar/generators/mongoid_example.yml
|
153
|
+
- lib/serialbar/generators/test.rb
|
154
|
+
- lib/serialbar/helpers.rb
|
155
|
+
- lib/serialbar/listener.rb
|
156
|
+
- lib/serialbar/scratch.rb
|
157
|
+
- lib/serialbar/version.rb
|
158
|
+
- serialbar.gemspec
|
159
|
+
- serialbar.sublime-project
|
160
|
+
- serialbar.sublime-workspace
|
161
|
+
- seriallisten.rb
|
162
|
+
- spec/data_file_spec.rb
|
163
|
+
- spec/listener_spec.rb
|
164
|
+
- spec/mongoid_spec.rb
|
165
|
+
- spec/spec_helper.rb
|
166
|
+
- spec/support/shared_examples_for_modules.rb
|
167
|
+
- spec/test.rb
|
168
|
+
homepage: https://github.com/jonbramble/serialbar/
|
169
|
+
licenses:
|
170
|
+
- MIT
|
171
|
+
metadata: {}
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
requirements: []
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 2.2.2
|
189
|
+
signing_key:
|
190
|
+
specification_version: 4
|
191
|
+
summary: An adapter gem between incomming serial port data and storage
|
192
|
+
test_files:
|
193
|
+
- spec/data_file_spec.rb
|
194
|
+
- spec/listener_spec.rb
|
195
|
+
- spec/mongoid_spec.rb
|
196
|
+
- spec/spec_helper.rb
|
197
|
+
- spec/support/shared_examples_for_modules.rb
|
198
|
+
- spec/test.rb
|