asmodis-rlsm 0.2.2 → 0.2.03

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.
@@ -19,7 +19,7 @@
19
19
  require File.join(File.dirname(__FILE__), 'monkey_patching')
20
20
  require File.join(File.dirname(__FILE__), 'dfa')
21
21
 
22
- # A Monoid is a set of elements with an associative binary operation and a neutral element.
22
+ # A Monoid is a set of elements with an associative binary operation and a neutral element.require File.join(File.dirname(__FILE__), 'base_ext', 'object_ext')
23
23
  module RLSM
24
24
  class Monoid
25
25
 
@@ -20,4 +20,3 @@ require File.join(File.dirname(__FILE__), 'monoid')
20
20
  require File.join(File.dirname(__FILE__), 'mgen')
21
21
  require File.join(File.dirname(__FILE__), 'dfa')
22
22
  require File.join(File.dirname(__FILE__), 'rlsm_regexp')
23
- require File.join(File.dirname(__FILE__), 'monoid_db.rb')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asmodis-rlsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.03
5
5
  platform: ruby
6
6
  authors:
7
7
  - asmodis
@@ -11,16 +11,8 @@ cert_chain: []
11
11
 
12
12
  date: 2008-10-19 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: sqlite3-ruby
17
- version_requirement:
18
- version_requirements: !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
23
- version:
14
+ dependencies: []
15
+
24
16
  description: RLSM contains the three classes DFA, Monoid and REgExp for work with regular languages.
25
17
  email: g.diemant@gmx.net
26
18
  executables: []
@@ -39,8 +31,6 @@ files:
39
31
  - lib/rlsm_regexp.rb
40
32
  - lib/dfa.rb
41
33
  - lib/rlsm.rb
42
- - lib/monoid_db.rb
43
- - data/monoids.db
44
34
  has_rdoc: true
45
35
  homepage: http://github.org/asmodis/rlsm
46
36
  post_install_message:
@@ -63,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
53
  version:
64
54
  requirements: []
65
55
 
66
- rubyforge_project: none
56
+ rubyforge_project:
67
57
  rubygems_version: 1.2.0
68
58
  signing_key:
69
59
  specification_version: 2
Binary file
@@ -1,85 +0,0 @@
1
- require "rubygems"
2
- require "sqlite3"
3
- require "singleton"
4
-
5
- module RLSM
6
- class MonoidDB
7
- include Singleton
8
-
9
- attr_reader :db
10
-
11
- def self.query(query, &block)
12
- if block_given?
13
- instance.db.execute(query, &block)
14
- else
15
- instance.db.execute(query)
16
- end
17
- end
18
-
19
- def self.find(params = {}, &block)
20
- if block_given?
21
- query construct_query(params), &block
22
- else
23
- query construct_query(params)
24
- end
25
- end
26
-
27
- def self.count(params = {})
28
- q = construct_query(params).sub('T binop F',
29
- "T count(*), total(syntactic) F")
30
- query(q).first.map { |x| x.to_i }
31
- end
32
-
33
- def self.statistic
34
- res = instance.db.execute2 <<SQL
35
- SELECT
36
- m_order AS 'Order',
37
- count(*) AS 'Total',
38
- total(syntactic) AS 'Syntactic',
39
- total(is_group) AS 'Groups',
40
- total(commutative) AS 'Commutative',
41
- total(aperiodic) AS 'Aperiodic',
42
- total(idempotent) AS 'Idempotent'
43
- FROM monoids
44
- GROUP BY m_order
45
- ORDER BY 'Order' ASC;
46
- SQL
47
-
48
- desc = res.shift
49
- res.map! { |row| row.map { |x| x.to_i } }
50
- res.unshift desc
51
-
52
- res
53
- end
54
-
55
- private
56
- def initialize
57
- db_name = File.join(File.dirname(__FILE__), '..', 'data', 'monoids.db')
58
- @db = SQLite3::Database.open(db_name)
59
- end
60
-
61
- def self.construct_query(params)
62
- limit = ""
63
- if params[:limit]
64
- limit = "\nLIMIT #{params[:limit]}"
65
- params.delete :limit
66
- if params[:offset]
67
- limit += " OFFSET #{params[:offset]}"
68
- end
69
- end
70
-
71
- order_by = "\nORDER BY binop #{params[:ordering] || 'ASC'}"
72
-
73
- params.delete :ordering
74
-
75
- q = "SELECT binop FROM monoids"
76
-
77
- if params.size > 0
78
- q += "\nWHERE "
79
- q += params.to_a.map { |k,v| k.to_s + '=' + v.to_s }.join(' AND ')
80
- end
81
-
82
- q + order_by + limit + ";"
83
- end
84
- end
85
- end