rumx 0.0.4 → 0.0.5

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/History.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Rumx Changelog
2
2
  =====================
3
3
 
4
+ 0.0.5
5
+
6
+ - Allow default values for operation arguments.
7
+ - Add json mime type.
8
+
4
9
  0.0.4
5
10
 
6
11
  - Fix bug where embedded beans and bean-lists of base classes weren't included.
@@ -10,9 +10,9 @@ class MyBean
10
10
  bean_reader :readable_my_writer, :float, 'My secret access to the write-only attribute my_writer'
11
11
 
12
12
  bean_operation :my_operation, :string, 'My operation', [
13
- [ :arg_int, :integer, 'An int argument' ],
14
- [ :arg_float, :float, 'A float argument' ],
15
- [ :arg_string, :string, 'A string argument' ]
13
+ [ :arg_int, :integer, 'An int argument', 42 ],
14
+ [ :arg_float, :float, 'A float argument' ], # No default value
15
+ [ :arg_string, :string, 'A string argument', 'My default value' ]
16
16
  ]
17
17
 
18
18
  def initialize
data/lib/rumx/argument.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  module Rumx
2
2
  class Argument
3
- attr_reader :name, :type, :description
3
+ attr_reader :name, :type, :description, :default_value
4
4
 
5
- def initialize(name, type_name, description)
6
- @name = name.to_sym
7
- @type = Type.find(type_name)
8
- @description = description
5
+ def initialize(name, type_name, description, default_value=nil)
6
+ @name = name.to_sym
7
+ @type = Type.find(type_name)
8
+ @description = description
9
+ @default_value = default_value
9
10
  end
10
11
  end
11
12
  end
data/lib/rumx/bean.rb CHANGED
@@ -89,7 +89,7 @@ module Rumx
89
89
  #]
90
90
  def bean_operation(name, type, description, args)
91
91
  arguments = args.map do |arg|
92
- raise 'Invalid bean_operation format' unless arg.kind_of?(Array) && arg.size == 3
92
+ raise 'Invalid bean_operation format' unless arg.kind_of?(Array) && (arg.size == 3 || arg.size == 4)
93
93
  Argument.new(*arg)
94
94
  end
95
95
  bean_operations_local << Operation.new(name, type, description, arguments)
@@ -1,4 +1,4 @@
1
1
  - if attribute.allow_write
2
- %input{ :type => 'text', :name => param_name, :size => 30, :value => value }
2
+ %input{ :type => 'text', :name => param_name, :size => 30, :value => escape_html(value) }
3
3
  - else
4
- %span= value
4
+ %span= escape_html(value)
@@ -24,7 +24,7 @@
24
24
  %tr
25
25
  %td Value:
26
26
  %td
27
- %input{ :type => 'text', :name => arg.name, :size => 30 }
27
+ %input{ :type => 'text', :name => arg.name, :size => 30, :value => arg.default_value.to_s }
28
28
  %input{ :type => 'submit', :value => 'Execute' }
29
29
 
30
30
  %p#results
@@ -6,7 +6,7 @@
6
6
  %td Name
7
7
  %td Description
8
8
  %td Returns
9
- %td{:colspan => 4} Arguments
9
+ %td{:colspan => 5} Arguments
10
10
  %tr
11
11
  %td &nbsp;
12
12
  %td &nbsp;
@@ -15,6 +15,7 @@
15
15
  %td Name
16
16
  %td Description
17
17
  %td Type
18
+ %td Default Value
18
19
  %tbody
19
20
  - bean.bean_each_operation do |operation, rel_path|
20
21
  %tr
@@ -34,3 +35,4 @@
34
35
  %td= arg.name
35
36
  %td= arg.description
36
37
  %td= arg.type
38
+ %td= arg.default_value
data/lib/rumx/server.rb CHANGED
@@ -7,6 +7,7 @@ module Rumx
7
7
  class Server < Sinatra::Base
8
8
  configure do
9
9
  enable :logging
10
+ mime_type :json, 'application/json'
10
11
  end
11
12
 
12
13
  set :root, File.join(File.dirname(__FILE__), 'server')
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rumx
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.4
5
+ version: 0.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brad Pardee
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-11-15 00:00:00 Z
13
+ date: 2011-12-02 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sinatra