pinstripe 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -2
  3. data/.slick +0 -0
  4. data/Gemfile.lock +1 -8
  5. data/README.md +2 -3
  6. data/Rakefile +1 -0
  7. data/package.json +3 -2
  8. data/pinstripe.gemspec +12 -13
  9. data/rollup.config.js +2 -2
  10. data/web/javascripts/index.js +2 -0
  11. metadata +11 -95
  12. data/.pinstripe +0 -3
  13. data/exe/pinstripe +0 -4
  14. data/lib/pinstripe.rb +0 -24
  15. data/lib/pinstripe/call_handler.rb +0 -12
  16. data/lib/pinstripe/command.rb +0 -20
  17. data/lib/pinstripe/commands/list_commands.rb +0 -16
  18. data/lib/pinstripe/commands/start_console.rb +0 -14
  19. data/lib/pinstripe/concern.rb +0 -19
  20. data/lib/pinstripe/database.rb +0 -56
  21. data/lib/pinstripe/database/row.rb +0 -48
  22. data/lib/pinstripe/database/table.rb +0 -131
  23. data/lib/pinstripe/database/table_alias_manager.rb +0 -20
  24. data/lib/pinstripe/database/union.rb +0 -20
  25. data/lib/pinstripe/helper.rb +0 -20
  26. data/lib/pinstripe/helpers.rb +0 -8
  27. data/lib/pinstripe/inflector.rb +0 -28
  28. data/lib/pinstripe/inflector/inflections.rb +0 -122
  29. data/lib/pinstripe/monkey_patches/pluralize.rb +0 -8
  30. data/lib/pinstripe/monkey_patches/require_all.rb +0 -18
  31. data/lib/pinstripe/monkey_patches/singularize.rb +0 -8
  32. data/lib/pinstripe/monkey_patches/to_params_hash.rb +0 -20
  33. data/lib/pinstripe/params_hash.rb +0 -44
  34. data/lib/pinstripe/project.rb +0 -29
  35. data/lib/pinstripe/registry.rb +0 -46
  36. data/lib/pinstripe/resource_factories/call_handler.rb +0 -8
  37. data/lib/pinstripe/resource_factories/env.rb +0 -9
  38. data/lib/pinstripe/resource_factories/environment.rb +0 -8
  39. data/lib/pinstripe/resource_factories/project.rb +0 -8
  40. data/lib/pinstripe/resource_factory.rb +0 -32
  41. data/lib/pinstripe/resource_provider.rb +0 -50
  42. data/lib/pinstripe/version.rb +0 -3
  43. data/lib/pinstripe/workspace.rb +0 -8
  44. data/pinstripe +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2cb947e0311ba670442c2bc3863299bf54c9d918420b44b1ebc52f8fe58b5d9
4
- data.tar.gz: 50acc4e1919747618d584a0866e5226d58493d3e512fbd10828687c24213b884
3
+ metadata.gz: 9fb674820f1e763fa7a6b6648403ba9feacece4ce4969e7b6b133056bb03ae82
4
+ data.tar.gz: f70cf7c2e95ec5daea8c1f9d7f4f45b9f1d7d5716b06bd741ccee0fd9cb35c77
5
5
  SHA512:
6
- metadata.gz: fed3bc212e47bc4a7eab9ffc39f4474d15511edb44216da14196801615b059be9e6993edb67e90f593c1b5b9e8610487b63ee996312460132feeee3673c26e9f
7
- data.tar.gz: e84b52f0d8d53235a21452eda448c87639b9b22d38898a971ca94fccd251e09771e53faefbb4611feb642bb430e29c4052ac5a6fea5a1de01741852da29e5c98
6
+ metadata.gz: d1e079f7f8f8a153fc23b050429b2f9ca73904b2942b9163745c74d05a3313317a94d57cf73ab031e9b7d680b4568f6a7347b4f681b8ce7ccfd85ccf76aafecf
7
+ data.tar.gz: 316709cd24a7cb813e15349013b04eef9aead4e4d4975abc2da87d2fe5063bdb801a1d6c65dc1f1d0bee1b281618aec99c566670c9edc1c912d0bb0d29d986bd
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
-
3
2
  node_modules/
4
3
  pkg/
5
- web/javascripts/bundle.*
4
+ dist/
5
+ *-bundle.js*
6
+ .DS_Store
data/.slick ADDED
File without changes
@@ -1,24 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pinstripe (0.1.2)
4
+ pinstripe (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- minitest (5.14.0)
10
- mysql2 (0.5.3)
11
- rake (13.0.1)
12
9
 
13
10
  PLATFORMS
14
11
  ruby
15
12
 
16
13
  DEPENDENCIES
17
- bundler (~> 2.0)
18
- minitest (~> 5.0)
19
- mysql2 (~> 0.5)
20
14
  pinstripe!
21
- rake (~> 13.0)
22
15
 
23
16
  BUNDLED WITH
24
17
  2.0.2
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
 
2
- # Pinstripe Suit
3
-
4
- Welcome to Pinstripe. An entrepreneurial full stack web framework!
2
+ # Welcome to Pinstripe JS
5
3
 
4
+ Pinstripe makes the UI of your web application run much faster, by only updating the parts of the DOM that change when loading html content from your server. Thus removing the performance cost of a full page reload.
data/Rakefile CHANGED
@@ -5,6 +5,7 @@ Rake::TestTask.new(:test) do |t|
5
5
  t.libs << "test"
6
6
  t.libs << "lib"
7
7
  t.test_files = FileList["test/**/*_test.rb"]
8
+ t.warning = false
8
9
  end
9
10
 
10
11
  task :default => :test
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "pinstripe",
3
- "version": "0.1.0",
4
- "main": "web/javascripts/bundle.js",
3
+ "description": "Pinstripe makes the UI of your web application run much faster, by only updating the parts of the DOM that change when loading html content from your server. Thus removing the performance cost of a full page reload.",
4
+ "version": "0.2.0",
5
+ "main": "web/javascripts/index-bundle.js",
5
6
  "module": "web/javascripts/_pinstripe/index.js",
6
7
  "license": "MIT",
7
8
  "scripts": {
@@ -1,14 +1,15 @@
1
- lib = File.expand_path("lib", __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "pinstripe/version"
1
+
2
+ require 'JSON'
3
+
4
+ package_json = JSON.parse(File.read(File.expand_path("package.json", __dir__)))
4
5
 
5
6
  Gem::Specification.new do |spec|
6
7
  spec.name = "pinstripe"
7
- spec.version = Pinstripe::VERSION
8
+ spec.version = package_json["version"]
8
9
  spec.authors = ["Jody Salt"]
9
10
  spec.email = ["jody@jodysalt.com"]
10
11
 
11
- spec.summary = "An entrepreneurial full stack web framework!"
12
+ spec.summary = package_json["description"]
12
13
  spec.license = "MIT"
13
14
 
14
15
  #spec.description = %q{TODO: Write a longer description or delete this line.}
@@ -23,16 +24,14 @@ Gem::Specification.new do |spec|
23
24
  # Specify which files should be added to the gem when it is released.
24
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
26
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ out = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ out << 'web/javascripts/index-bundle.js'
29
+ out << 'web/javascripts/index-bundle.js.map'
30
+ out
27
31
  end
32
+
28
33
  spec.bindir = "exe"
29
34
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
31
-
32
- spec.add_development_dependency "mysql2", "~> 0.5"
33
-
34
- spec.add_development_dependency "bundler", "~> 2.0"
35
- spec.add_development_dependency "rake", "~> 13.0"
36
- spec.add_development_dependency "minitest", "~> 5.0"
35
+ #spec.require_paths = []
37
36
 
38
37
  end
@@ -3,9 +3,9 @@ import resolve from "rollup-plugin-node-resolve"
3
3
 
4
4
  export default [
5
5
  {
6
- input: 'web/javascripts/_pinstripe/index.js',
6
+ input: 'web/javascripts/index.js',
7
7
  output: {
8
- file: `web/javascripts/bundle.js`,
8
+ file: 'web/javascripts/index-bundle.js',
9
9
  format: 'iife',
10
10
  sourcemap: true
11
11
  },
@@ -0,0 +1,2 @@
1
+
2
+ import './_pinstripe'
metadata CHANGED
@@ -1,119 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinstripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jody Salt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-22 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: mysql2
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.5'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.5'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '13.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '13.0'
55
- - !ruby/object:Gem::Dependency
56
- name: minitest
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '5.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '5.0'
11
+ date: 2020-06-07 00:00:00.000000000 Z
12
+ dependencies: []
69
13
  description:
70
14
  email:
71
15
  - jody@jodysalt.com
72
- executables:
73
- - pinstripe
16
+ executables: []
74
17
  extensions: []
75
18
  extra_rdoc_files: []
76
19
  files:
77
20
  - ".gitignore"
78
- - ".pinstripe"
21
+ - ".slick"
79
22
  - Gemfile
80
23
  - Gemfile.lock
81
24
  - LICENSE
82
25
  - README.md
83
26
  - Rakefile
84
- - exe/pinstripe
85
- - lib/pinstripe.rb
86
- - lib/pinstripe/call_handler.rb
87
- - lib/pinstripe/command.rb
88
- - lib/pinstripe/commands/list_commands.rb
89
- - lib/pinstripe/commands/start_console.rb
90
- - lib/pinstripe/concern.rb
91
- - lib/pinstripe/database.rb
92
- - lib/pinstripe/database/row.rb
93
- - lib/pinstripe/database/table.rb
94
- - lib/pinstripe/database/table_alias_manager.rb
95
- - lib/pinstripe/database/union.rb
96
- - lib/pinstripe/helper.rb
97
- - lib/pinstripe/helpers.rb
98
- - lib/pinstripe/inflector.rb
99
- - lib/pinstripe/inflector/inflections.rb
100
- - lib/pinstripe/monkey_patches/pluralize.rb
101
- - lib/pinstripe/monkey_patches/require_all.rb
102
- - lib/pinstripe/monkey_patches/singularize.rb
103
- - lib/pinstripe/monkey_patches/to_params_hash.rb
104
- - lib/pinstripe/params_hash.rb
105
- - lib/pinstripe/project.rb
106
- - lib/pinstripe/registry.rb
107
- - lib/pinstripe/resource_factories/call_handler.rb
108
- - lib/pinstripe/resource_factories/env.rb
109
- - lib/pinstripe/resource_factories/environment.rb
110
- - lib/pinstripe/resource_factories/project.rb
111
- - lib/pinstripe/resource_factory.rb
112
- - lib/pinstripe/resource_provider.rb
113
- - lib/pinstripe/version.rb
114
- - lib/pinstripe/workspace.rb
115
27
  - package.json
116
- - pinstripe
117
28
  - pinstripe.gemspec
118
29
  - rollup.config.js
119
30
  - web/javascripts/_pinstripe/event_wrapper.js
@@ -135,6 +46,9 @@ files:
135
46
  - web/javascripts/_pinstripe/util/index.js
136
47
  - web/javascripts/_pinstripe/util/unescape_html.js
137
48
  - web/javascripts/_pinstripe/virtual_node.js
49
+ - web/javascripts/index-bundle.js
50
+ - web/javascripts/index-bundle.js.map
51
+ - web/javascripts/index.js
138
52
  - yarn.lock
139
53
  homepage:
140
54
  licenses:
@@ -158,5 +72,7 @@ requirements: []
158
72
  rubygems_version: 3.0.6
159
73
  signing_key:
160
74
  specification_version: 4
161
- summary: An entrepreneurial full stack web framework!
75
+ summary: Pinstripe makes the UI of your web application run much faster, by only updating
76
+ the parts of the DOM that change when loading html content from your server. Thus
77
+ removing the performance cost of a full page reload.
162
78
  test_files: []
data/.pinstripe DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "name" => "pinstripe"
3
- }
@@ -1,4 +0,0 @@
1
-
2
- require("pinstripe")
3
-
4
- Pinstripe::Command.run(*ARGV)
@@ -1,24 +0,0 @@
1
-
2
- require "pinstripe/monkey_patches/require_all"
3
-
4
- module Pinstripe
5
-
6
- require_all("pinstripe/monkey_patches")
7
- require_all("pinstripe")
8
-
9
- class << self
10
-
11
- def resource_provider
12
- @resource_provider ||= ResourceProvider.new
13
- end
14
-
15
- def call(env)
16
- resource_provider.reset do
17
- resource_provider["env"] = env
18
- resource_provider["call_handler"].handle_call
19
- end
20
- end
21
-
22
- end
23
-
24
- end
@@ -1,12 +0,0 @@
1
-
2
- require "pinstripe/helpers"
3
-
4
- class Pinstripe::CallHandler
5
-
6
- include Pinstripe::Helpers
7
-
8
- def handle_call
9
- [200, {"Content-Type" => "text/plain"}, ["Hello World!"]]
10
- end
11
-
12
- end
@@ -1,20 +0,0 @@
1
-
2
- require "pinstripe/registry"
3
-
4
- class Pinstripe::Command
5
-
6
- extend Pinstripe::Registry
7
-
8
- def initialize(*args)
9
-
10
- end
11
-
12
- def self.run(name = 'list-commands', *args)
13
- create(name, *args).run
14
- end
15
-
16
- def run
17
- puts "No such command \"#{self.class.name}\""
18
- end
19
-
20
- end
@@ -1,16 +0,0 @@
1
-
2
- require "pinstripe/command"
3
-
4
- Pinstripe::Command.define "list-commands" do
5
-
6
- def run
7
- puts ""
8
- puts "The following commands are available:"
9
- puts ""
10
- Pinstripe::Command.registered_classes.keys.sort.each do |name|
11
- puts " * #{name}"
12
- end
13
- puts ""
14
- end
15
-
16
- end
@@ -1,14 +0,0 @@
1
-
2
- require "pinstripe/command"
3
-
4
- Pinstripe::Command.define "start-console" do
5
-
6
- def run
7
- require "irb"
8
- IRB.setup nil
9
- IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context
10
- require "irb/ext/multi-irb"
11
- IRB.irb nil, Pinstripe::Workspace.new
12
- end
13
-
14
- end
@@ -1,19 +0,0 @@
1
-
2
- module Pinstripe::Concern
3
-
4
- def missing_method_calls
5
- @missing_method_calls ||= []
6
- end
7
-
8
- def included(_module)
9
- missing_method_calls.each do |missing_method_call|
10
- args, block = missing_method_call
11
- _module.send *args, &block
12
- end
13
- end
14
-
15
- def method_missing(*args, &block)
16
- missing_method_calls << [args, block]
17
- end
18
-
19
- end
@@ -1,56 +0,0 @@
1
-
2
- require "mysql2"
3
-
4
- class Pinstripe::Database
5
-
6
- attr_reader :config
7
-
8
- def initialize(config = {})
9
- @config = config.to_params_hash
10
- end
11
-
12
- def client
13
- @client ||= Mysql2::Client.new({
14
- :host => @config.host || '127.0.0.1',
15
- :port => @config.port || 3306,
16
- :username => @config.username || 'root',
17
- :password => @config.password || '',
18
- :database => @config.name
19
- })
20
- end
21
-
22
- def query(*query)
23
- out = []
24
- query = query.flatten
25
- while(query.length > 0)
26
- sql_fragment = query.shift.to_s
27
- sql_fragment.gsub! /\?/ do |match|
28
- value = query.shift
29
- if value.kind_of?(Pinstripe::Database::Table)
30
- value.instance_eval{ @alias }
31
- else
32
- sanitize(value)
33
- end
34
- end
35
- out << sql_fragment
36
- end
37
- out.join(' ')
38
- end
39
-
40
- def sanitize(value)
41
- value.kind_of?(Numeric) ? value : "'#{client.escape(value)}'"
42
- end
43
-
44
- def method_missing(name, *args, &block)
45
- if args.length == 0
46
- if Union.registered_classes[name]
47
- Union.create(name, self)
48
- else
49
- Table.create(name, self)
50
- end
51
- else
52
- super
53
- end
54
- end
55
-
56
- end
@@ -1,48 +0,0 @@
1
-
2
- class Pinstripe::Database::Row
3
-
4
- extend Pinstripe::Registry
5
-
6
- class << self
7
-
8
- attr_accessor :table_class
9
-
10
- def register(name, options = {})
11
- if options[:abstract]
12
- union_class = Pinstripe::Database::Union.for(name.pluralize, :register_if_not_exists => true)
13
- union_class.table_classes << table_class if !union_class.table_classes.include?(table_class)
14
- else
15
- super(name)
16
- @table_class = Pinstripe::Database::Table.for(name.pluralize, :register_if_not_exists => true)
17
- field "id", "type" => "integer"
18
- end
19
- end
20
-
21
- def has_many(name, *args, &block)
22
- table_class.has_many(name, *args, &block)
23
- class_eval("def #{name}; self.class.table_class.new(@database).id_eq(id).#{name}; end")
24
- end
25
-
26
- def has_one(name, *args, &block)
27
- table_class.has_one(name, *args, &block)
28
- class_eval("def #{name}; self.class.table_class.new(@database).id_eq(id).#{name}.first; end")
29
- end
30
-
31
- def belongs_to(name, *args, &block)
32
- table_class.belongs_to(name, *args, &block)
33
- class_eval("def #{name}; self.class.table_class.new(@database).id_eq(id).#{name}.first; end")
34
- end
35
-
36
- def field(*args, &block)
37
- table_class.column(*args, &block)
38
- end
39
-
40
- end
41
-
42
- def initialize(database, data = {})
43
- @database = database
44
- @data = data
45
- @altered_data = {}
46
- end
47
-
48
- end
@@ -1,131 +0,0 @@
1
-
2
- require "pinstripe/registry"
3
-
4
- class Pinstripe::Database::Table
5
-
6
- extend Pinstripe::Registry
7
-
8
- class << self
9
-
10
- def relationships
11
- @relationships ||= {}.to_params_hash
12
- end
13
-
14
- def has_many(name, options = {})
15
- relationships[name] = {
16
- "name" => name.to_s,
17
- "collection_name" => name.to_s,
18
- "from_key" => "id",
19
- "to_key" => "#{self.name.singularize}_id",
20
- "cascade_delete" => "true"
21
- }
22
- relationships[name].merge!(options)
23
- class_eval("def #{name}; join('#{name}'); end")
24
- end
25
-
26
- def has_one(name, options = {})
27
- relationships[name] = {
28
- "name" => name.to_s,
29
- "collection_name" => name.pluralize,
30
- "from_key" => "id",
31
- "to_key" => "#{self.name.singularize}_id",
32
- "cascade_delete" => "true"
33
- }
34
- relationships[name].merge!(options)
35
- class_eval("def #{name}; join('#{name}'); end")
36
- end
37
-
38
- def belongs_to(name, options = {})
39
- relationships[name] = {
40
- "name" => name.to_s,
41
- "collection_name" => name.pluralize,
42
- "from_key" => "#{name}_id",
43
- "to_key" => "id",
44
- "cascade_delete" => "false"
45
- }
46
- relationships[name].merge!(options)
47
- class_eval("def #{name}; join('#{name}'); end")
48
- end
49
-
50
- def columns
51
- @columns ||= {}.to_params_hash
52
- end
53
-
54
- def column(name, options = {})
55
- columns[name] = {
56
- "name" => name.to_s,
57
- "type" => "string"
58
- }
59
- columns[name].merge!(options)
60
- class_eval("def #{name}_eq(value); where('?.`#{name}` = ?', self, value); end")
61
- end
62
-
63
- def scope(name, &block)
64
- #call block with join parents as arguments
65
- end
66
-
67
- end
68
-
69
- def initialize(database, join_parent = nil, join_relationship_name = nil, table_alias_manager = Pinstripe::Database::TableAliasManager.new)
70
- @database = database
71
- @join_parent = join_parent
72
- @join_relationship_name = join_relationship_name
73
- @table_alias_manager = table_alias_manager
74
- @joins = []
75
- @predicates = []
76
- @alias = table_alias_manager.generate_alias(self.class.name)
77
- end
78
-
79
- def clone
80
- out = super
81
- out.instance_eval do
82
- @joins = @joins.clone
83
- @predicates = @predicates.clone
84
- end
85
- out
86
- end
87
-
88
- def back(count = 1)
89
- current = self
90
- count.times do
91
- previous = current
92
- current = current.instance_eval{ @join_parent }.clone
93
- current.instance_eval{ @joins << previous }
94
- end
95
- current
96
- end
97
-
98
- def join(relationship_name)
99
- collection_name = self.class.relationships[relationship_name].collection_name
100
- Pinstripe::Database::Table.create(collection_name, @database, self, relationship_name, @table_alias_manager)
101
- end
102
-
103
- def where(*predicate)
104
- out = clone
105
- out.instance_eval{ @predicates << predicate.flatten }
106
- out
107
- end
108
-
109
- def first
110
-
111
- end
112
-
113
- def each
114
-
115
- end
116
-
117
- def all
118
-
119
- end
120
-
121
- def generate_predicate_sql
122
- out = []
123
-
124
- out.join(' and ')
125
- end
126
-
127
- def generate_select_sql
128
-
129
- end
130
-
131
- end
@@ -1,20 +0,0 @@
1
-
2
- class Pinstripe::Database::TableAliasManager
3
-
4
- def initialize
5
- @alias_counters = {}
6
- end
7
-
8
- def generate_alias(name)
9
- name = name.to_s
10
- @alias_counters[name] = 0 if @alias_counters[name].nil?
11
- @alias_counters[name] += 1
12
-
13
- if @alias_counters[name] == 1
14
- name
15
- else
16
- "#{name}#{@alias_counters[name]}"
17
- end
18
- end
19
-
20
- end
@@ -1,20 +0,0 @@
1
-
2
- require "pinstripe/registry"
3
-
4
- class Pinstripe::Database::Union
5
-
6
- extend Pinstripe::Registry
7
-
8
- class << self
9
-
10
- def table_classes
11
- @table_classes ||= []
12
- end
13
-
14
- end
15
-
16
- def initialize(database)
17
- @database = database
18
- end
19
-
20
- end
@@ -1,20 +0,0 @@
1
-
2
- require "pinstripe/registry"
3
- require "pinstripe/helpers"
4
-
5
- class Pinstripe::Helper
6
-
7
- extend Pinstripe::Registry
8
-
9
- include Pinstripe::Helpers
10
-
11
- def self.register(name)
12
- super
13
- Pinstripe::Helpers.class_eval("def #{name}(*args, &block); ::Pinstripe::Helper.create(\"#{name}\").call(*args, &block); end")
14
- end
15
-
16
- def call(*args, &block)
17
-
18
- end
19
-
20
- end
@@ -1,8 +0,0 @@
1
-
2
- module Pinstripe::Helpers
3
-
4
- def database
5
- @database ||= Pinstripe::Database.new
6
- end
7
-
8
- end
@@ -1,28 +0,0 @@
1
-
2
-
3
- module Pinstripe::Inflector
4
-
5
- require "pinstripe/inflector/inflections"
6
-
7
- class << self
8
-
9
- def pluralize(word)
10
- word = word.to_s
11
- Inflections.pluralize_rules.each do |rule|
12
- pattern, replacement = rule
13
- return word.sub(pattern, replacement) if word.match?(pattern)
14
- end
15
- end
16
-
17
- def singularize(word)
18
- word = word.to_s
19
- Inflections.singularize_rules.each do |rule|
20
- pattern, replacement = rule
21
- return word.sub(pattern, replacement) if word.match?(pattern)
22
- end
23
- end
24
-
25
- end
26
-
27
-
28
- end
@@ -1,122 +0,0 @@
1
-
2
- module Pinstripe::Inflector::Inflections
3
-
4
- instance_eval do
5
- @pluralize_rules = []
6
- @singularize_rules = []
7
- end
8
-
9
- class << self
10
-
11
- attr_accessor :pluralize_rules
12
- attr_accessor :singularize_rules
13
-
14
- def plural(*args)
15
- pluralize_rules.prepend(args)
16
- end
17
-
18
- def singular(*args)
19
- singularize_rules.prepend(args)
20
- end
21
-
22
- def irregular(singular, plural)
23
- s0 = singular[0]
24
- srest = singular[1..-1]
25
-
26
- p0 = plural[0]
27
- prest = plural[1..-1]
28
-
29
- if s0.upcase == p0.upcase
30
- plural(/(#{s0})#{srest}$/i, '\1' + prest)
31
- plural(/(#{p0})#{prest}$/i, '\1' + prest)
32
-
33
- singular(/(#{s0})#{srest}$/i, '\1' + srest)
34
- singular(/(#{p0})#{prest}$/i, '\1' + srest)
35
- else
36
- plural(/#{s0.upcase}(?i)#{srest}$/, p0.upcase + prest)
37
- plural(/#{s0.downcase}(?i)#{srest}$/, p0.downcase + prest)
38
- plural(/#{p0.upcase}(?i)#{prest}$/, p0.upcase + prest)
39
- plural(/#{p0.downcase}(?i)#{prest}$/, p0.downcase + prest)
40
-
41
- singular(/#{s0.upcase}(?i)#{srest}$/, s0.upcase + srest)
42
- singular(/#{s0.downcase}(?i)#{srest}$/, s0.downcase + srest)
43
- singular(/#{p0.upcase}(?i)#{prest}$/, s0.upcase + srest)
44
- singular(/#{p0.downcase}(?i)#{prest}$/, s0.downcase + srest)
45
- end
46
- end
47
-
48
- def uncountable(singular_and_plural)
49
- irregular(singular_and_plural, singular_and_plural)
50
- end
51
-
52
- end
53
-
54
- plural(/$/, "s")
55
- plural(/s$/i, "s")
56
- plural(/^(ax|test)is$/i, '\1es')
57
- plural(/(octop|vir)us$/i, '\1i')
58
- plural(/(octop|vir)i$/i, '\1i')
59
- plural(/(alias|status)$/i, '\1es')
60
- plural(/(bu)s$/i, '\1ses')
61
- plural(/(buffal|tomat)o$/i, '\1oes')
62
- plural(/([ti])um$/i, '\1a')
63
- plural(/([ti])a$/i, '\1a')
64
- plural(/sis$/i, "ses")
65
- plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves')
66
- plural(/(hive)$/i, '\1s')
67
- plural(/([^aeiouy]|qu)y$/i, '\1ies')
68
- plural(/(x|ch|ss|sh)$/i, '\1es')
69
- plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices')
70
- plural(/^(m|l)ouse$/i, '\1ice')
71
- plural(/^(m|l)ice$/i, '\1ice')
72
- plural(/^(ox)$/i, '\1en')
73
- plural(/^(oxen)$/i, '\1')
74
- plural(/(quiz)$/i, '\1zes')
75
-
76
- singular(/s$/i, "")
77
- singular(/(ss)$/i, '\1')
78
- singular(/(n)ews$/i, '\1ews')
79
- singular(/([ti])a$/i, '\1um')
80
- singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '\1sis')
81
- singular(/(^analy)(sis|ses)$/i, '\1sis')
82
- singular(/([^f])ves$/i, '\1fe')
83
- singular(/(hive)s$/i, '\1')
84
- singular(/(tive)s$/i, '\1')
85
- singular(/([lr])ves$/i, '\1f')
86
- singular(/([^aeiouy]|qu)ies$/i, '\1y')
87
- singular(/(s)eries$/i, '\1eries')
88
- singular(/(m)ovies$/i, '\1ovie')
89
- singular(/(x|ch|ss|sh)es$/i, '\1')
90
- singular(/^(m|l)ice$/i, '\1ouse')
91
- singular(/(bus)(es)?$/i, '\1')
92
- singular(/(o)es$/i, '\1')
93
- singular(/(shoe)s$/i, '\1')
94
- singular(/(cris|test)(is|es)$/i, '\1is')
95
- singular(/^(a)x[ie]s$/i, '\1xis')
96
- singular(/(octop|vir)(us|i)$/i, '\1us')
97
- singular(/(alias|status)(es)?$/i, '\1')
98
- singular(/^(ox)en/i, '\1')
99
- singular(/(vert|ind)ices$/i, '\1ex')
100
- singular(/(matr)ices$/i, '\1ix')
101
- singular(/(quiz)zes$/i, '\1')
102
- singular(/(database)s$/i, '\1')
103
-
104
- irregular("person", "people")
105
- irregular("man", "men")
106
- irregular("child", "children")
107
- irregular("sex", "sexes")
108
- irregular("move", "moves")
109
- irregular("zombie", "zombies")
110
-
111
- uncountable "equipment"
112
- uncountable "information"
113
- uncountable "rice"
114
- uncountable "money"
115
- uncountable "species"
116
- uncountable "series"
117
- uncountable "fish"
118
- uncountable "sheep"
119
- uncountable "jeans"
120
- uncountable "police"
121
-
122
- end
@@ -1,8 +0,0 @@
1
-
2
- class Object
3
-
4
- def pluralize
5
- Pinstripe::Inflector.pluralize(to_s)
6
- end
7
-
8
- end
@@ -1,18 +0,0 @@
1
-
2
- module Kernel
3
-
4
- def require_all(path)
5
- $LOAD_PATH.each do |current_load_path|
6
- candidate_path = "#{current_load_path}/#{path}"
7
- require path if File.exists?("#{candidate_path}.rb") || File.exists?("#{candidate_path}.ruby")
8
-
9
- if Dir.exists?(candidate_path)
10
- Dir.open(candidate_path).each do |item|
11
- item = item.sub(/(\.[^\.]+)$/, '')
12
- require_all("#{path}/#{item}") if item != '..' && item != '.'
13
- end
14
- end
15
- end
16
- end
17
-
18
- end
@@ -1,8 +0,0 @@
1
-
2
- class Object
3
-
4
- def singularize
5
- Pinstripe::Inflector.singularize(to_s)
6
- end
7
-
8
- end
@@ -1,20 +0,0 @@
1
-
2
- require "pinstripe/params_hash"
3
-
4
- class Hash
5
-
6
- def to_params_hash
7
- Pinstripe::ParamsHash.new(self)
8
- end
9
-
10
- end
11
-
12
- class Array
13
-
14
- def to_params_hash
15
- out = Pinstripe::ParamsHash.new
16
- each_with_index{|value, key| out[key] = value}
17
- out
18
- end
19
-
20
- end
@@ -1,44 +0,0 @@
1
-
2
- class Pinstripe::ParamsHash < Hash
3
-
4
- def initialize(hash = {})
5
- merge!(hash)
6
- end
7
-
8
- def []=(key, value)
9
- super(key.to_s, normalize_value(value))
10
- end
11
-
12
- def[](key)
13
- super(key.to_s)
14
- end
15
-
16
- def merge!(hash)
17
- hash.each{|key, value| self[key] = value }
18
- end
19
-
20
- def merge(hash)
21
- out = clone
22
- out.merge!(hash)
23
- out
24
- end
25
-
26
- def method_missing(name, *args, &block)
27
- if args.length == 0 && !block
28
- self[name]
29
- else
30
- super
31
- end
32
- end
33
-
34
- private
35
-
36
- def normalize_value(value)
37
- if value.respond_to? :to_params_hash
38
- value.to_params_hash
39
- else
40
- value.to_s
41
- end
42
- end
43
-
44
- end
@@ -1,29 +0,0 @@
1
-
2
- require "bundler"
3
-
4
- class Pinstripe::Project
5
-
6
- attr_reader :root_path, :load_paths
7
-
8
- def initialize
9
- @root_path = find_path(Dir.pwd, ".pinstripe")
10
- @load_paths = $LOAD_PATH.map{|load_path| find_path(load_path, ".pinstripe") }.compact
11
- end
12
-
13
- private
14
-
15
- def find_path(path, file_name)
16
- current_path = path
17
- while true
18
- candidate_file_path = "#{current_path}/#{file_name}"
19
- return current_path if File.file?(candidate_file_path)
20
- if matches = current_path.match(/\A(.*)\/([^\/]+)\z/)
21
- current_path = matches[1]
22
- else
23
- break
24
- end
25
- end
26
- nil
27
- end
28
-
29
- end
@@ -1,46 +0,0 @@
1
-
2
- module Pinstripe::Registry
3
-
4
- attr_reader :name
5
-
6
- def registered?
7
- registered_classes.values.include? self
8
- end
9
-
10
- def registered_classes
11
- @registered_classes ||= superclass.respond_to?(:registered_classes) ? superclass.registered_classes : {}
12
- end
13
-
14
- def register(name, &block)
15
- raise "Class has already been registered" if registered?
16
- name = name.to_s
17
- instance_eval{ @name = name }
18
- registered_classes[name] = self
19
- self
20
- end
21
-
22
- def define(name, *args, &block)
23
- klass = Class.new(self)
24
- klass.register(name, *args)
25
- klass.class_eval(&block) if block
26
- klass
27
- end
28
-
29
- def for(name, options = {})
30
- name = name.to_s
31
- registered_classes[name] || begin
32
- klass = Class.new(self)
33
- if options[:register_if_not_exists]
34
- klass.register name
35
- else
36
- klass.instance_eval{ @name = name }
37
- end
38
- klass
39
- end
40
- end
41
-
42
- def create(name, *args, &block)
43
- self.for(name).new(*args, &block)
44
- end
45
-
46
- end
@@ -1,8 +0,0 @@
1
-
2
- Pinstripe::ResourceFactory.define "call_handler" do
3
-
4
- def create
5
- Pinstripe::CallHandler.new
6
- end
7
-
8
- end
@@ -1,9 +0,0 @@
1
-
2
- Pinstripe::ResourceFactory.define "env" do
3
-
4
- def create
5
- {}
6
- end
7
-
8
- end
9
-
@@ -1,8 +0,0 @@
1
-
2
- Pinstripe::ResourceFactory.define "environment" do
3
-
4
- def create
5
- ENV["RACK_ENV"] || "development"
6
- end
7
-
8
- end
@@ -1,8 +0,0 @@
1
-
2
- Pinstripe::ResourceFactory.define "project", :shared => true do
3
-
4
- def create
5
- Pinstripe::Project.new
6
- end
7
-
8
- end
@@ -1,32 +0,0 @@
1
-
2
- require "pinstripe/registry"
3
- require "pinstripe/helper"
4
-
5
- class Pinstripe::ResourceFactory
6
-
7
- extend Pinstripe::Registry
8
-
9
- class << self
10
- def register(name, options = {})
11
- super(name)
12
-
13
- @shared = options.to_params_hash.shared == "true"
14
-
15
- Pinstripe::Helper.define name do
16
- def call
17
- ::Pinstripe.resource_provider[self.class.name]
18
- end
19
- end
20
- end
21
-
22
- def shared?
23
- @shared
24
- end
25
-
26
- end
27
-
28
- def create
29
-
30
- end
31
-
32
- end
@@ -1,50 +0,0 @@
1
-
2
-
3
- class Pinstripe::ResourceProvider
4
-
5
- attr_reader :shared_resources
6
-
7
- def initialize
8
- @shared_resources = {}
9
- @mutex = Mutex.new
10
- end
11
-
12
- def thead_resources
13
- Thread.current["PINSTRIPE_RESOURCES"] ||= {}
14
- end
15
-
16
- def [](name)
17
- name = name.to_s
18
-
19
- return thead_resources[name] if !thead_resources[name].nil?
20
- return shared_resources[name] if !shared_resources[name].nil?
21
-
22
- resource_factory = Pinstripe::ResourceFactory.create(name)
23
-
24
- if resource_factory.class.shared?
25
- @mutex.synchronize { shared_resources[name] ||= resource_factory.create }
26
- shared_resources[name]
27
- else
28
- thead_resources[name] = resource_factory.create
29
- thead_resources[name]
30
- end
31
- end
32
-
33
- def []=(name, value)
34
- thead_resources[name.to_s] = value
35
- self
36
- end
37
-
38
- def reset(shared = false, thread = true, &block)
39
- previous_shared_resources = shared_resources
40
- previous_thread_resources = thread_resources
41
- @mutex.syncronize { @shared_resources = {} } if shared
42
- Thread.current["PINSTRIPE_RESOURCES"] = {} if thread
43
- if block
44
- block.call
45
- @mutex.synchronize { @shared_resources = previous_shared_resources } if shared
46
- Thread.current["PINSTRIPE_RESOURCES"] = previous_thread_resources if thread
47
- end
48
- end
49
-
50
- end
@@ -1,3 +0,0 @@
1
- module Pinstripe
2
- VERSION = "0.1.2"
3
- end
@@ -1,8 +0,0 @@
1
-
2
- require "pinstripe/helpers"
3
-
4
- class Pinstripe::Workspace
5
-
6
- include Pinstripe::Helpers
7
-
8
- end
data/pinstripe DELETED
@@ -1,4 +0,0 @@
1
- lib = File.expand_path("lib", __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
-
4
- load "#{__dir__}/exe/pinstripe"