brief 1.17.11 → 1.17.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c338f0419802a428afee51277086fdd0af705e9
4
- data.tar.gz: 3801fd8ded5d5c0c53808467f721fd044fad8c46
3
+ metadata.gz: d170a325dbe79ce3163e94ce7ac7186c0be87bf4
4
+ data.tar.gz: 02e7a1e5d07f52d51c487dee733fcc42ad868ac3
5
5
  SHA512:
6
- metadata.gz: e8de6380c5ab6d49c4462d1f7d287d28565a6b29eed38df01d420e1ec95791170401ff4d9700b0f3a7d4ad395a8b13fa0719295e67190d4496da516e67038019
7
- data.tar.gz: fafe0bbae1283ea11dce3ad833bb5b0297ad94a3118e56d01bcd7cdf64995c8d3a130dbc1255fc3746d1201c5ef50e1b33ddcb300a1c42d603b527ac7c39a98b
6
+ metadata.gz: b3de2eb1990f299af651e84a1fde89b60b73f852961520b9dfbd83efe15bb5b1b618ca56f1e653191311e6bfb607ebacd848f359a9217bf962f6b90151c66e59
7
+ data.tar.gz: 416d0d43e957bb395eab38b1db2c981f53d6f4284553987ef121414be645ec4d037a1ffcc0f6606f80d2cbfa30fdb1a6a6b1b5b92752f86f708f3f556a2db40a
@@ -11,10 +11,18 @@ command 'change' do |c|
11
11
  c.action do |args, options|
12
12
  options.default(root: Pathname(Brief.pwd), operator: "eq")
13
13
  attribute = args.shift
14
- paths = args.map {|a| Dir[options.root.join(a)] }.flatten
15
14
 
16
- briefcase = Brief.case(true)
17
- documents = briefcase.documents_at(*paths)
15
+ briefcase = $briefcase || Brief.case
16
+
17
+ path_args = args.select { |arg| arg.is_a?(String) && arg.match(/\.md$/) }
18
+
19
+ path_args.select! do |arg|
20
+ briefcase.root.join(arg).exist?
21
+ end
22
+
23
+ path_args.map! { |p| briefcase.root.join(p) }
24
+
25
+ documents = briefcase.documents_at(*path_args)
18
26
 
19
27
  if options.from
20
28
  #attribute = attribute.to_sym.send(options.operator)
@@ -26,11 +34,15 @@ command 'change' do |c|
26
34
  puts "No documents match this selection"
27
35
  end
28
36
 
29
- if options.dry_run
30
- puts documents
31
- end
37
+ models = documents.map(&:to_model)
32
38
 
33
- documents
39
+ models.each do |model|
40
+ briefcase.log("Changing #{ attribute } from #{ model.data[attribute] } to #{ options.to }")
41
+
42
+ unless options.dry_run
43
+ model.set_data_attribute(attribute, options.to)
44
+ end
45
+ end
34
46
  end
35
47
  end
36
48
 
@@ -115,7 +115,7 @@ module Brief
115
115
 
116
116
  def combined_data_and_content
117
117
  return content if data.nil? || data.empty?
118
- frontmatter.to_hash.to_yaml + "---\n\n#{ content }"
118
+ data.to_hash.to_yaml + "---\n\n#{ content }"
119
119
  end
120
120
 
121
121
  def data
@@ -81,6 +81,12 @@ module Brief
81
81
  end
82
82
  end
83
83
 
84
+ def set_data_attribute(attribute, value)
85
+ document.data.send("#{attribute}=", value)
86
+ document.save
87
+ value
88
+ end
89
+
84
90
  def exists?
85
91
  document && document.path && document.path.exist?
86
92
  end
@@ -1,5 +1,11 @@
1
1
  module Brief
2
2
  module Model::Persistence
3
3
  extend ActiveSupport::Concern
4
+
5
+ def set_data_attribute(attribute, value)
6
+ document.data.send("#{attribute}=", value)
7
+ document.save
8
+ value
9
+ end
4
10
  end
5
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brief
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.11
4
+ version: 1.17.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Soeder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-23 00:00:00.000000000 Z
11
+ date: 2015-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie